RFC: Merge java.net.URL

Gary Benson gbenson@redhat.com
Wed Jan 10 16:31:00 GMT 2007


Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
> 
> Gary> The special cases are six years old, and GCJ seems to run fine
> Gary> without them, passing make check, etc, but I wanted to see if
> Gary> anyone knows of special weird cases in which this could break.
> 
> I remember adding this to fix a bug (perhaps a false memory, since
> the ChangeLog says Andrew did it :-), but I don't remember exactly
> what it was.  Something about Class.forName requiring URL which
> required Class.forName, resulting in a crash.
> 
> I did some digging but it wasn't very helpful... this change came
> in via a jumbo patch back in the day:
> 
>     http://gcc.gnu.org/ml/java-patches/2000-q2/msg00194.html

Yeah, I saw some of that.  From the comment it looked as though it
might have had something to do with statically linked executables,
but the attached test program shows handlers for both file and core
have been created by the time main() is called, so...

Cheers,
Gary
-------------- next part --------------
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Map;
import java.util.Iterator;

class Test
{
  public static void main(String[] args)
  {
    try
      {
	Field field = URL.class.getDeclaredField("ph_cache");
	field.setAccessible(true);
	Map<?, ?> cache = (Map<?, ?>) field.get(null);

	Iterator<?> iter = cache.entrySet().iterator();
	while (iter.hasNext())
	  {
	    Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next();

	    System.out.println("\"" + entry.getKey() + "\" => " +
			       entry.getValue());
	  }
      }
    catch (Exception e)
      {
	e.printStackTrace();
      }
  }
}


More information about the Java-patches mailing list