diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 0dd92c8b436ea..cf08f441e15ab 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -234,6 +234,7 @@ nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ nonstatic_field(InstanceKlass, _source_debug_extension, const char*) \ nonstatic_field(InstanceKlass, _inner_classes, Array<jushort>*) \ + nonstatic_field(InstanceKlass, _nest_members, Array<jushort>*) \ nonstatic_field(InstanceKlass, _nonstatic_field_size, int) \ nonstatic_field(InstanceKlass, _static_field_size, int) \ nonstatic_field(InstanceKlass, _static_oop_field_count, u2) \ @@ -241,6 +242,7 @@ volatile_nonstatic_field(InstanceKlass, _init_state, InstanceKlass::ClassState) \ volatile_nonstatic_field(InstanceKlass, _init_thread, JavaThread*) \ nonstatic_field(InstanceKlass, _itable_len, int) \ + nonstatic_field(InstanceKlass, _nest_host_index, u2) \ nonstatic_field(InstanceKlass, _reference_type, u1) \ volatile_nonstatic_field(InstanceKlass, _oop_map_cache, OopMapCache*) \ nonstatic_field(InstanceKlass, _jni_ids, JNIid*) \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index fba4f890dca10..b13171745bba3 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -77,12 +77,14 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc constants = new MetadataField(type.getAddressField("_constants"), 0); sourceDebugExtension = type.getAddressField("_source_debug_extension"); innerClasses = type.getAddressField("_inner_classes"); + nestMembers = type.getAddressField("_nest_members"); nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0); staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0); staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0); nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0); initState = new CIntField(type.getCIntegerField("_init_state"), 0); itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0); + nestHostIndex = new CIntField(type.getCIntegerField("_nest_host_index"), 0); if (VM.getVM().isJvmtiSupported()) { breakpoints = type.getAddressField("_breakpoints"); } @@ -142,12 +144,14 @@ public InstanceKlass(Address addr) { private static MetadataField constants; private static AddressField sourceDebugExtension; private static AddressField innerClasses; + private static AddressField nestMembers; private static CIntField nonstaticFieldSize; private static CIntField staticFieldSize; private static CIntField staticOopFieldCount; private static CIntField nonstaticOopMapSize; private static CIntField initState; private static CIntField itableLen; + private static CIntField nestHostIndex; private static AddressField breakpoints; // type safe enum for ClassState from instanceKlass.hpp @@ -374,6 +378,7 @@ public int getAllFieldsCount() { public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); } public long getItableLen() { return itableLen.getValue(this); } + public short getNestHostIndex() { return (short) nestHostIndex.getValue(this); } public long majorVersion() { return getConstants().majorVersion(); } public long minorVersion() { return getConstants().minorVersion(); } public Symbol getGenericSignature() { return getConstants().getGenericSignature(); } @@ -900,6 +905,11 @@ public U1Array getFieldTypeAnnotations(int fieldIndex) { } } + public U2Array getNestMembers() { + Address addr = getAddress().getAddressAt(nestMembers.getOffset()); + return VMObjectFactory.newObject(U2Array.class, addr); + } + //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java index 6b05bd836dbf2..e1d40b586b42e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java @@ -52,6 +52,8 @@ protected void debugMessage(String message) { protected short _sourceFileIndex; protected short _innerClassesIndex; + protected short _nestHostIndex; + protected short _nestMembersIndex; protected short _syntheticIndex; protected short _deprecatedIndex; protected short _constantValueIndex; @@ -143,6 +145,14 @@ else if(cpConstType == JVM_CONSTANT_Long || _innerClassesIndex = (innerClassesIndex != null)? innerClassesIndex.shortValue() : 0; if (DEBUG) debugMessage("InnerClasses index = " + _innerClassesIndex); + Short nestHostIndex = utf8ToIndex.get("NestHost"); + _nestHostIndex = (nestHostIndex != null)? nestHostIndex.shortValue() : 0; + if (DEBUG) debugMessage("NestHost index = " + _nestHostIndex); + + Short nestMembersIndex = utf8ToIndex.get("NestMembers"); + _nestMembersIndex = (nestMembersIndex != null)? nestMembersIndex.shortValue() : 0; + if (DEBUG) debugMessage("NestMembers index = " + _nestMembersIndex); + Short bootstrapMethodsIndex = utf8ToIndex.get("BootstrapMethods"); _bootstrapMethodsIndex = (bootstrapMethodsIndex != null) ? bootstrapMethodsIndex.shortValue() : 0; // field attributes @@ -780,6 +790,17 @@ protected void writeClassAttributes() throws IOException { if (numInnerClasses != 0) classAttributeCount++; + short nestHost = klass.getNestHostIndex(); + if (nestHost != 0) { + classAttributeCount++; + } + + U2Array nestMembers = klass.getNestMembers(); + final int numNestMembers = nestMembers.length(); + if (numNestMembers != 0) { + classAttributeCount++; + } + int bsmCount = klass.getConstants().getBootstrapMethodsCount(); if (bsmCount != 0) { classAttributeCount++; @@ -835,6 +856,23 @@ protected void writeClassAttributes() throws IOException { } } + if (nestHost != 0) { + writeIndex(_nestHostIndex); + final int nestHostAttrLen = 2; + dos.writeInt(nestHostAttrLen); + dos.writeShort(nestHost); + } + + if (numNestMembers != 0) { + writeIndex(_nestMembersIndex); + final int nestMembersAttrLen = 2 + numNestMembers * 2; + dos.writeInt(nestMembersAttrLen); + dos.writeShort(numNestMembers); + for (int index = 0; index < numNestMembers; index++) { + dos.writeShort(nestMembers.at(index)); + } + } + // write bootstrap method attribute, if any if (bsmCount != 0) { ConstantPool cpool = klass.getConstants();