Anonymous class

yumin qi yumin.qi at
Fri Jan 25 08:52:14 UTC 2019


  I have a question of anonymous class. We know the anonymous class with a
host_klass, and the flag is set when the InstanceKlass is created after the
class parsed. In case of a regular java class file, the flag will be set
correctly but for the case it is not set:
  SystemDictionary::parse_stream or resolve_from_stream, which is called
from JVM_DefineClassWithSource or jni_defineClass. The stack trace like:

#1  0x00007f1127291ce7 in
class_loader=..., protection_domain=...,d__=0x7f0f04001000) at
#1  0x00007f1127291ce7 in SystemDictionary::resolve_from_stream
(class_name=0x7f0ee40243f0, class_loader=..., protection_doma
    st=0x7f0f0a5f3850, verify=true, __the_thread__=0x7f0f04001000)
#2  0x00007f1126f3cadb in jvm_define_class_common (env=0x7f0f04001220,
name=0x7f0f0a5f3e60 "com/google/common/collect/Iterato
    loader=0x7f0f0a5f3f20, buf=0x7f0ee401e210 "\312\376\272\276", len=943,
    source=0x7f0f0a5f3a60 "jar:file:/home/<...>/lib/guava-19.0.jar!/",
verify=1 '\001', __the_thread__=0x7f0f04001000) at
#3  0x00007f1126f3d019 in JVM_DefineClassWithSource (env=0x7f0f04001220,
name=0x7f0f0a5f3e60 "com/google/common/collect/Itera
    loader=0x7f0f0a5f3f20, buf=0x7f0ee401e210 "\312\376\272\276", len=943,
    source=0x7f0f0a5f3a60 "jar:file:/home/<...>/lib/guava-19.0.jar!/") at
#4  0x00007f112581214f in Java_java_lang_ClassLoader_defineClass1 ()
#5  0x00007f11118f5402 in ?? ()
#6  0x00007f0f0a5f3f48 in ?? ()
#7  0x00007f0f0a5f3f70 in ?? ()
#8  0x0000000755dbbc28 in ?? ()

The class name is$3, and it is an
anonymous class.
This is an example using Guava. I also can reproduce with jdk13.

The field after parsing:

 _nonstatic_oop_map_size = 1,
  _is_marked_dependent = false,
  _has_unloaded_dependent = false,
  _misc_flags = 38,      ////// <------------ not set for anonymous
  _minor_version = 0,
  _major_version = 50,
  _init_thread = 0x0,
  _vtable_len = 8,
  _itable_len = 8,

  This path is from a custom loader defining a anonymous class, does not
set anonymous correctly for the flag. Is this a bug? If in java land,
supply a host as parameter,  it can be set correctly in VM part. Should I
file a bug for it?


More information about the jdk-dev mailing list