AnonymousClassLoader and ClassLoader
Rémi Forax
forax at univ-mlv.fr
Fri Apr 25 08:47:30 PDT 2008
John Rose a écrit :
> On Apr 24, 2008, at 2:26 AM, Rémi Forax wrote:
>
>> In my opinion, getResource() is not the only method that makes this
>> assumption
>
> The getResource method probably needs to be adjusted since anonymous
> classes have names that are intentionally distorted. The anonymous
> class name ends with "/${hashcode}" so that attempts to do forName
> will rapidly fail, and so that it is clear which classes are anonymous.
Are you sure hashcode are unique and never creates a name collisions ?
> The logic for Class.resolveName needs to take this case into account
> if resources are to work. (I assume that it is a good idea for them
> to "work", but maybe it's not.) It's a good question, and a nice
> experiment.
>
> -- John
Perhaps it's a good idea to try to surface isAnonymousClass() a Java level
or even better getHostClass() (or getAnonymousHostClass()).
I will try to create a patch for that this week-end, i seems to be a
good idea
to try to understand the VM internals.
Another experiment,
trying to resolve an anonymous class using ClassLoader.resolveClass()
leads to a crash in SystemDictionnary.
Step to reproduce, change sun.misc.Launcher by the one in attachement,
I have chnage the application classloader to load all non bootstrap
class as anonymous one
(see findClass) but when it tries to call resolveClass() (in
ClassLoader.loadClass()) on an anonymous class,
the VM crashs.
I don't know if trying to resolve an anonymous class is legal or not.
The following lines are a cut&paste of the crash using the fastdebug VM
(patched with anonk and callcc).
Rémi
[forax at localhost eclipse]$ java -davinci -Xbootclasspath/p:classes -cp
test/classes:/usr/local/java/demo/jfc/SwingSet2/SwingSet2.jar
AllAnonymousLauncher SwingSet2
load anonymous AllAnonymousLauncher
resource sun.misc.URLClassPath$FileLoader$1 at f6a746
anonymous loaded class AllAnonymousLauncher/26208195
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/systemDictionary.cpp:850
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error
(/home/forax/java/workspace/davinci/sources/hotspot/src/share/vm/classfile/systemDictionary.cpp:850),
pid=15414, tid=3084950416
# Error: assert(kk == k(),"should be present in dictionary")
#
# Java VM: OpenJDK Client VM (12.0-b01-internal-fastdebug mixed mode
linux-x86)
# An error report file with more information is saved as:
# /home/forax/java/workspace/davinci/eclipse/hs_err_pid15414.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Current thread is 3084950416
Dumping core ...
Abandon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Launcher.java
Type: text/x-java
Size: 22642 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20080425/e9883d05/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AllAnonymousLauncher.java
Type: text/x-java
Size: 533 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20080425/e9883d05/attachment-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hs_err_pid15414.log
Type: text/x-log
Size: 10082 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20080425/e9883d05/attachment-0002.bin
More information about the mlvm-dev
mailing list