This is an automated email from the ASF dual-hosted git repository. lkishalmi pushed a commit to branch release100 in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
commit 558b2e79abae0f82780a5858b22b31580b74cbe6 Author: arusinha <arunava.si...@oracle.com> AuthorDate: Tue Sep 25 23:00:22 2018 -0700 [NETBEANS-804]: Support for JDK 11 classfiles changes --- .../apisupport/project/universe/AbstractEntry.java | 1 + java/classfile/apichanges.xml | 12 ++ java/classfile/manifest.mf | 3 +- .../modules/classfile/CPConstantDynamicInfo.java | 54 ++++++ .../netbeans/modules/classfile/ConstantPool.java | 10 +- .../modules/classfile/JDK11ClassFilesTest.java | 183 +++++++++++++++++++++ .../debugger/jpda/projects/ConstantPool.java | 11 ++ .../moduletask/classfile/ConstantPool.java | 43 +++++ .../src/org/netbeans/PatchByteCode.java | 1 + 9 files changed, 315 insertions(+), 3 deletions(-) diff --git a/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/AbstractEntry.java b/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/AbstractEntry.java index 7ae4a36..d8eaa38 100644 --- a/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/AbstractEntry.java +++ b/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/AbstractEntry.java @@ -194,6 +194,7 @@ abstract class AbstractEntry implements ModuleEntry { case 10: // CONSTANT_Methodref case 11: // CONSTANT_InterfaceMethodref case 12: // CONSTANT_NameAndType + case 17: // CONSTANT_ConstantDynamic case 18: //CONSTANT_InvokeDynamic skip(input, 4); break; diff --git a/java/classfile/apichanges.xml b/java/classfile/apichanges.xml index 7c72598..37f6916 100644 --- a/java/classfile/apichanges.xml +++ b/java/classfile/apichanges.xml @@ -83,6 +83,18 @@ is the proper place. <!-- ACTUAL CHANGES BEGIN HERE: --> <changes> + <change id="Java11Support"> + <api name="general"/> + <summary>Support for Java 11 classfile enhancements.</summary> + <version major="1" minor="56"/> + <date day="26" month="9" year="2018"/> + <author login="arusinha"/> + <compatibility addition="yes"/> + <description> + Java 11 added a new constant pool entry type to support the constantDynamic instruction. + </description> + <class package="org.netbeans.modules.classfile" name="CPConstantDynamicInfo"/> + </change> <change id="JDK9-ModulePackages-ModuleMainClass-ModuleTarget"> <api name="general"/> <summary>Introduced ModulePackages, ModuleMainClass, ModuleTarget attributes</summary> diff --git a/java/classfile/manifest.mf b/java/classfile/manifest.mf index bdfd746..566b41d 100644 --- a/java/classfile/manifest.mf +++ b/java/classfile/manifest.mf @@ -1,5 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.classfile/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/classfile/Bundle.properties -OpenIDE-Module-Specification-Version: 1.55.1 - +OpenIDE-Module-Specification-Version: 1.55.2 diff --git a/java/classfile/src/org/netbeans/modules/classfile/CPConstantDynamicInfo.java b/java/classfile/src/org/netbeans/modules/classfile/CPConstantDynamicInfo.java new file mode 100644 index 0000000..036b221 --- /dev/null +++ b/java/classfile/src/org/netbeans/modules/classfile/CPConstantDynamicInfo.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.classfile; + +/** + * A class representing the CONSTANT_ConstantDynamic constant pool type. + * + * @author arusinha + * @since 1.56 + */ +public class CPConstantDynamicInfo extends CPEntry { + int iBootstrapMethod; + int iNameAndType; + + CPConstantDynamicInfo(ConstantPool pool, int iBootstrapMethod, int iNameAndType) { + super(pool); + this.iBootstrapMethod = iBootstrapMethod; + this.iNameAndType = iNameAndType; + } + + public int getTag() { + return ConstantPool.CONSTANT_ConstantDynamic; + } + + public int getBootstrapMethod() { + return iBootstrapMethod; + } + + public int getNameAndType() { + return iNameAndType; + } + + @Override + public String toString() { + return getClass().getName() + ": bootstrapMethod=" + iBootstrapMethod //NOI18N + + ", nameAndType=" + iNameAndType; //NOI18N + } +} diff --git a/java/classfile/src/org/netbeans/modules/classfile/ConstantPool.java b/java/classfile/src/org/netbeans/modules/classfile/ConstantPool.java index 5c93f83..c290a62 100644 --- a/java/classfile/src/org/netbeans/modules/classfile/ConstantPool.java +++ b/java/classfile/src/org/netbeans/modules/classfile/ConstantPool.java @@ -48,6 +48,7 @@ public final class ConstantPool { static final int CONSTANT_NameAndType = 12; static final int CONSTANT_MethodHandle = 15; static final int CONSTANT_MethodType = 16; + static final int CONSTANT_ConstantDynamic = 17; static final int CONSTANT_InvokeDynamic = 18; static final int CONSTANT_Module = 19; static final int CONSTANT_Package = 20; @@ -255,7 +256,14 @@ public final class ConstantPool { newEntry = new CPMethodTypeInfo(this, index); break; } - + + case CONSTANT_ConstantDynamic: { + int bootstrapMethod = cpr.readUnsignedShort(); + int nameAndType = cpr.readUnsignedShort(); + newEntry = new CPConstantDynamicInfo(this, bootstrapMethod, nameAndType); + break; + } + case CONSTANT_InvokeDynamic: { int bootstrapMethod = cpr.readUnsignedShort(); int nameAndType = cpr.readUnsignedShort(); diff --git a/java/classfile/test/unit/src/org/netbeans/modules/classfile/JDK11ClassFilesTest.java b/java/classfile/test/unit/src/org/netbeans/modules/classfile/JDK11ClassFilesTest.java new file mode 100644 index 0000000..e8129fc --- /dev/null +++ b/java/classfile/test/unit/src/org/netbeans/modules/classfile/JDK11ClassFilesTest.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.classfile; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Arrays; +import junit.framework.TestCase; +import static junit.framework.TestCase.assertEquals; +import org.netbeans.modules.classfile.CPMethodHandleInfo.ReferenceKind; + +/** + * + * @author arusinha + */ +public class JDK11ClassFilesTest extends TestCase { + + public JDK11ClassFilesTest(String testName) { + super(testName); + } + + public void testDefenderMethods() throws Exception { + InputStream classData = new ByteArrayInputStream(DATA); + ClassFile classFile = new ClassFile(classData); + + CPConstantDynamicInfo constDynamic = (CPConstantDynamicInfo) classFile.getConstantPool().get(2); + assertEquals(ConstantPool.CONSTANT_ConstantDynamic, constDynamic.getTag()); + BootstrapMethod bootstrapMethod = classFile.getBootstrapMethods().get(constDynamic.getBootstrapMethod()); + assertEquals("[17, 18, 17]", Arrays.toString(bootstrapMethod.getArguments())); + CPMethodHandleInfo bootstrapMH = (CPMethodHandleInfo) classFile.getConstantPool().get(bootstrapMethod.getMethodRef()); + assertEquals(ConstantPool.CONSTANT_MethodHandle, bootstrapMH.getTag()); + assertEquals(ReferenceKind.invokeStatic, bootstrapMH.getReferenceKind()); + CPMethodInfo bootstrapMethodInfo = (CPMethodInfo) classFile.getConstantPool().get(bootstrapMH.getReference()); + assertEquals("Object metafactory(MethodHandles$Lookup,String,Class,MethodType,MethodHandle,MethodType)", bootstrapMethodInfo.getFullMethodName()); + CPNameAndTypeInfo nameAndType = (CPNameAndTypeInfo) classFile.getConstantPool().get(constDynamic.getNameAndType()); + assertEquals("Ljava/lang/Runnable;", nameAndType.getDescriptor()); + assertEquals("run", nameAndType.getName()); + CPMethodTypeInfo methodType = (CPMethodTypeInfo) classFile.getConstantPool().get(17); + assertEquals(ConstantPool.CONSTANT_MethodType, methodType.getTag()); + CPUTF8Info descriptor = (CPUTF8Info) classFile.getConstantPool().get(methodType.getDescriptor()); + assertEquals("()V", descriptor.getName()); + } + + /* + The bytecode array was generate from the below class + public class LDC { + private Runnable get() { + return () -> { + }; + } + } + + */ + private static final byte[] DATA = { + (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x38, (byte) 0x00, (byte) 0x26, (byte) 0x0A, (byte) 0x00, (byte) 0x04, (byte) 0x00, + (byte) 0x0E, (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x13, (byte) 0x07, + (byte) 0x00, (byte) 0x14, (byte) 0x07, (byte) 0x00, (byte) 0x15, (byte) 0x01, (byte) 0x00, + (byte) 0x06, (byte) 0x3C, (byte) 0x69, (byte) 0x6E, (byte) 0x69, (byte) 0x74, (byte) 0x3E, + (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x28, (byte) 0x29, (byte) 0x56, (byte) 0x01, + (byte) 0x00, (byte) 0x04, (byte) 0x43, (byte) 0x6F, (byte) 0x64, (byte) 0x65, (byte) 0x01, + (byte) 0x00, (byte) 0x0F, (byte) 0x4C, (byte) 0x69, (byte) 0x6E, (byte) 0x65, (byte) 0x4E, + (byte) 0x75, (byte) 0x6D, (byte) 0x62, (byte) 0x65, (byte) 0x72, (byte) 0x54, (byte) 0x61, + (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x67, + (byte) 0x65, (byte) 0x74, (byte) 0x01, (byte) 0x00, (byte) 0x16, (byte) 0x28, (byte) 0x29, + (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, + (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x52, (byte) 0x75, (byte) 0x6E, + (byte) 0x6E, (byte) 0x61, (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x3B, (byte) 0x01, + (byte) 0x00, (byte) 0x0C, (byte) 0x6C, (byte) 0x61, (byte) 0x6D, (byte) 0x62, (byte) 0x64, + (byte) 0x61, (byte) 0x24, (byte) 0x67, (byte) 0x65, (byte) 0x74, (byte) 0x24, (byte) 0x30, + (byte) 0x01, (byte) 0x00, (byte) 0x0A, (byte) 0x53, (byte) 0x6F, (byte) 0x75, (byte) 0x72, + (byte) 0x63, (byte) 0x65, (byte) 0x46, (byte) 0x69, (byte) 0x6C, (byte) 0x65, (byte) 0x01, + (byte) 0x00, (byte) 0x08, (byte) 0x4C, (byte) 0x44, (byte) 0x43, (byte) 0x2E, (byte) 0x6A, + (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x0C, (byte) 0x00, (byte) 0x05, (byte) 0x00, + (byte) 0x06, (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x42, (byte) 0x6F, (byte) 0x6F, + (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x72, (byte) 0x61, (byte) 0x70, (byte) 0x4D, + (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6F, (byte) 0x64, (byte) 0x73, (byte) 0x0F, + (byte) 0x06, (byte) 0x00, (byte) 0x16, (byte) 0x10, (byte) 0x00, (byte) 0x06, (byte) 0x0F, + (byte) 0x06, (byte) 0x00, (byte) 0x17, (byte) 0x0C, (byte) 0x00, (byte) 0x18, (byte) 0x00, + (byte) 0x19, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x4C, (byte) 0x44, (byte) 0x43, + (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, + (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x4F, + (byte) 0x62, (byte) 0x6A, (byte) 0x65, (byte) 0x63, (byte) 0x74, (byte) 0x0A, (byte) 0x00, + (byte) 0x1A, (byte) 0x00, (byte) 0x1B, (byte) 0x0A, (byte) 0x00, (byte) 0x03, (byte) 0x00, + (byte) 0x1C, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x72, (byte) 0x75, (byte) 0x6E, + (byte) 0x01, (byte) 0x00, (byte) 0x14, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, + (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, + (byte) 0x52, (byte) 0x75, (byte) 0x6E, (byte) 0x6E, (byte) 0x61, (byte) 0x62, (byte) 0x6C, + (byte) 0x65, (byte) 0x3B, (byte) 0x07, (byte) 0x00, (byte) 0x1D, (byte) 0x0C, (byte) 0x00, + (byte) 0x1E, (byte) 0x00, (byte) 0x22, (byte) 0x0C, (byte) 0x00, (byte) 0x0B, (byte) 0x00, + (byte) 0x06, (byte) 0x01, (byte) 0x00, (byte) 0x22, (byte) 0x6A, (byte) 0x61, (byte) 0x76, + (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, + (byte) 0x69, (byte) 0x6E, (byte) 0x76, (byte) 0x6F, (byte) 0x6B, (byte) 0x65, (byte) 0x2F, + (byte) 0x4C, (byte) 0x61, (byte) 0x6D, (byte) 0x62, (byte) 0x64, (byte) 0x61, (byte) 0x4D, + (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x66, (byte) 0x61, (byte) 0x63, (byte) 0x74, + (byte) 0x6F, (byte) 0x72, (byte) 0x79, (byte) 0x01, (byte) 0x00, (byte) 0x0B, (byte) 0x6D, + (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x66, (byte) 0x61, (byte) 0x63, (byte) 0x74, + (byte) 0x6F, (byte) 0x72, (byte) 0x79, (byte) 0x07, (byte) 0x00, (byte) 0x24, (byte) 0x01, + (byte) 0x00, (byte) 0x06, (byte) 0x4C, (byte) 0x6F, (byte) 0x6F, (byte) 0x6B, (byte) 0x75, + (byte) 0x70, (byte) 0x01, (byte) 0x00, (byte) 0x0C, (byte) 0x49, (byte) 0x6E, (byte) 0x6E, + (byte) 0x65, (byte) 0x72, (byte) 0x43, (byte) 0x6C, (byte) 0x61, (byte) 0x73, (byte) 0x73, + (byte) 0x65, (byte) 0x73, (byte) 0x01, (byte) 0x00, (byte) 0xB7, (byte) 0x28, (byte) 0x4C, + (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, + (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x69, (byte) 0x6E, (byte) 0x76, (byte) 0x6F, + (byte) 0x6B, (byte) 0x65, (byte) 0x2F, (byte) 0x4D, (byte) 0x65, (byte) 0x74, (byte) 0x68, + (byte) 0x6F, (byte) 0x64, (byte) 0x48, (byte) 0x61, (byte) 0x6E, (byte) 0x64, (byte) 0x6C, + (byte) 0x65, (byte) 0x73, (byte) 0x24, (byte) 0x4C, (byte) 0x6F, (byte) 0x6F, (byte) 0x6B, + (byte) 0x75, (byte) 0x70, (byte) 0x3B, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, + (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, + (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B, + (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, + (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x43, (byte) 0x6C, (byte) 0x61, + (byte) 0x73, (byte) 0x73, (byte) 0x3B, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, + (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, + (byte) 0x69, (byte) 0x6E, (byte) 0x76, (byte) 0x6F, (byte) 0x6B, (byte) 0x65, (byte) 0x2F, + (byte) 0x4D, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6F, (byte) 0x64, (byte) 0x54, + (byte) 0x79, (byte) 0x70, (byte) 0x65, (byte) 0x3B, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, + (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, + (byte) 0x2F, (byte) 0x69, (byte) 0x6E, (byte) 0x76, (byte) 0x6F, (byte) 0x6B, (byte) 0x65, + (byte) 0x2F, (byte) 0x4D, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6F, (byte) 0x64, + (byte) 0x48, (byte) 0x61, (byte) 0x6E, (byte) 0x64, (byte) 0x6C, (byte) 0x65, (byte) 0x3B, + (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, + (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x69, (byte) 0x6E, (byte) 0x76, + (byte) 0x6F, (byte) 0x6B, (byte) 0x65, (byte) 0x2F, (byte) 0x4D, (byte) 0x65, (byte) 0x74, + (byte) 0x68, (byte) 0x6F, (byte) 0x64, (byte) 0x54, (byte) 0x79, (byte) 0x70, (byte) 0x65, + (byte) 0x3B, (byte) 0x29, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, + (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x4F, + (byte) 0x62, (byte) 0x6A, (byte) 0x65, (byte) 0x63, (byte) 0x74, (byte) 0x3B, (byte) 0x07, + (byte) 0x00, (byte) 0x25, (byte) 0x01, (byte) 0x00, (byte) 0x25, (byte) 0x6A, (byte) 0x61, + (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, + (byte) 0x2F, (byte) 0x69, (byte) 0x6E, (byte) 0x76, (byte) 0x6F, (byte) 0x6B, (byte) 0x65, + (byte) 0x2F, (byte) 0x4D, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6F, (byte) 0x64, + (byte) 0x48, (byte) 0x61, (byte) 0x6E, (byte) 0x64, (byte) 0x6C, (byte) 0x65, (byte) 0x73, + (byte) 0x24, (byte) 0x4C, (byte) 0x6F, (byte) 0x6F, (byte) 0x6B, (byte) 0x75, (byte) 0x70, + (byte) 0x01, (byte) 0x00, (byte) 0x1E, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, + (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x69, + (byte) 0x6E, (byte) 0x76, (byte) 0x6F, (byte) 0x6B, (byte) 0x65, (byte) 0x2F, (byte) 0x4D, + (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6F, (byte) 0x64, (byte) 0x48, (byte) 0x61, + (byte) 0x6E, (byte) 0x64, (byte) 0x6C, (byte) 0x65, (byte) 0x73, (byte) 0x00, (byte) 0x21, + (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x05, + (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x07, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x1D, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x2A, (byte) 0xB7, (byte) 0x00, + (byte) 0x01, (byte) 0xB1, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, + (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x00, + (byte) 0x09, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x07, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x1B, (byte) 0x00, (byte) 0x01, (byte) 0x00, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x12, (byte) 0x02, + (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x08, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x10, (byte) 0x0A, (byte) 0x00, (byte) 0x0B, + (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x07, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x19, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0xB1, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, + (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x02, (byte) 0x00, (byte) 0x0D, (byte) 0x00, (byte) 0x21, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x1F, (byte) 0x00, + (byte) 0x23, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x19, (byte) 0x00, (byte) 0x0F, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x01, (byte) 0x00, + (byte) 0x10, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x11, (byte) 0x00, (byte) 0x12, + (byte) 0x00, (byte) 0x11 + }; +} diff --git a/java/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java b/java/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java index 9993fbe..646e47e 100644 --- a/java/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java +++ b/java/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java @@ -48,6 +48,7 @@ public class ConstantPool { private static final byte TAG_NAMETYPE = 12; private static final byte TAG_METHODHANDLE = 15; private static final byte TAG_METHODTYPE = 16; + private static final byte TAG_CONSTANTDYNAMIC = 17; private static final byte TAG_INVOKEDYNAMIC = 18; private static final byte TAG_MODULE = 19; private static final byte TAG_PACKAGE = 20; @@ -145,6 +146,9 @@ public class ConstantPool { case TAG_METHODTYPE: entry = new EntryMethodType(in); break; + case TAG_CONSTANTDYNAMIC: + entry = new EntryConstantDynamic(in); + break; case TAG_INVOKEDYNAMIC: entry = new EntryInvokeDynamic(in); break; @@ -394,4 +398,11 @@ public class ConstantPool { } } + public static class EntryConstantDynamic extends BytesEntry { + + public EntryConstantDynamic(DataInputStream in) throws IOException { + super(TAG_CONSTANTDYNAMIC, in, 4); + } + } + } diff --git a/java/java.j2seproject/copylibstask/src/org/netbeans/modules/java/j2seproject/moduletask/classfile/ConstantPool.java b/java/java.j2seproject/copylibstask/src/org/netbeans/modules/java/j2seproject/moduletask/classfile/ConstantPool.java index f9e841a..61a5ab7 100644 --- a/java/java.j2seproject/copylibstask/src/org/netbeans/modules/java/j2seproject/moduletask/classfile/ConstantPool.java +++ b/java/java.j2seproject/copylibstask/src/org/netbeans/modules/java/j2seproject/moduletask/classfile/ConstantPool.java @@ -46,6 +46,7 @@ public final class ConstantPool { CONSTANT_Utf8(1), CONSTANT_MethodHandle(15), CONSTANT_MethodType(16), + CONSTANT_ConstantDynamic(17), CONSTANT_InvokeDynamic(18), CONSTANT_Module(19), CONSTANT_Package(20); @@ -166,6 +167,8 @@ public final class ConstantPool { return new CPMethodHandle(this, in); case CONSTANT_MethodType: return new CPMethodType(this, in); + case CONSTANT_ConstantDynamic: + return new CPConstantDynamic(this, in); case CONSTANT_InvokeDynamic: return new CPInvokeDynamic(this, in); case CONSTANT_Module: @@ -781,6 +784,46 @@ public final class ConstantPool { } } + public static class CPConstantDynamic extends CPInfo { + + private final int bootstrapMethodAttrIndex; + private final int nameAndTypeIndex; + + CPConstantDynamic( + final ConstantPool owner, + final Reader in) throws IOException { + super(owner, ConstantKind.CONSTANT_ConstantDynamic); + this.bootstrapMethodAttrIndex = in.readUnsignedShort(); + this.nameAndTypeIndex = in.readUnsignedShort(); + } + + @Override + void write(Writer out) throws IOException { + super.write(out); + out.writeUnsignedShort(bootstrapMethodAttrIndex); + out.writeUnsignedShort(nameAndTypeIndex); + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj) || !(obj instanceof CPConstantDynamic)) { + return false; + } + final CPConstantDynamic i = (CPConstantDynamic)obj; + return bootstrapMethodAttrIndex == i.bootstrapMethodAttrIndex + && nameAndTypeIndex == i.nameAndTypeIndex; + } + + @Override + public String toString() { + return String.format( + "%s bootstrapMethod: %d, nameAndType: %d", //NOI18N + super.toString(), + bootstrapMethodAttrIndex, + nameAndTypeIndex); + } + } + public static class CPModule extends CPUTF8Ref { CPModule( diff --git a/platform/o.n.bootstrap/src/org/netbeans/PatchByteCode.java b/platform/o.n.bootstrap/src/org/netbeans/PatchByteCode.java index e7bb653..2385936 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/PatchByteCode.java +++ b/platform/o.n.bootstrap/src/org/netbeans/PatchByteCode.java @@ -189,6 +189,7 @@ public final class PatchByteCode { case 10: // CONSTANT_Methodref case 11: // CONSTANT_InterfaceMethodref case 12: // CONSTANT_NameAndType + case 17: //CONSTANT_ConstantDynamic case 18: //CONSTANT_InvokeDynamic pos += 4; break; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists