< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConstantPool.java

Print this page

        

@@ -115,10 +115,12 @@
     public static final int CONSTANT_InterfaceMethodref = 11;
     public static final int CONSTANT_NameAndType = 12;
     public static final int CONSTANT_MethodHandle = 15;
     public static final int CONSTANT_MethodType = 16;
     public static final int CONSTANT_InvokeDynamic = 18;
+    public static final int CONSTANT_Module = 19;
+    public static final int CONSTANT_Package = 20;
 
     public static enum RefKind {
         REF_getField(1),
         REF_getStatic(2),
         REF_putField(3),

@@ -211,14 +213,22 @@
 
             case CONSTANT_Methodref:
                 pool[i] = new CONSTANT_Methodref_info(this, cr);
                 break;
 
+            case CONSTANT_Module:
+                pool[i] = new CONSTANT_Module_info(this, cr);
+                break;
+
             case CONSTANT_NameAndType:
                 pool[i] = new CONSTANT_NameAndType_info(this, cr);
                 break;
 
+            case CONSTANT_Package:
+                pool[i] = new CONSTANT_Package_info(this, cr);
+                break;
+
             case CONSTANT_String:
                 pool[i] = new CONSTANT_String_info(this, cr);
                 break;
 
             case CONSTANT_Utf8:

@@ -274,14 +284,22 @@
 
     public CONSTANT_Class_info getClassInfo(int index) throws InvalidIndex, UnexpectedEntry {
         return ((CONSTANT_Class_info) get(index, CONSTANT_Class));
     }
 
+    public CONSTANT_Module_info getModuleInfo(int index) throws InvalidIndex, UnexpectedEntry {
+        return ((CONSTANT_Module_info) get(index, CONSTANT_Module));
+    }
+
     public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry {
         return ((CONSTANT_NameAndType_info) get(index, CONSTANT_NameAndType));
     }
 
+    public CONSTANT_Package_info getPackageInfo(int index) throws InvalidIndex, UnexpectedEntry {
+        return ((CONSTANT_Package_info) get(index, CONSTANT_Package));
+    }
+
     public String getUTF8Value(int index) throws InvalidIndex, UnexpectedEntry {
         return getUTF8Info(index).value;
     }
 
     public int getUTF8Index(String value) throws EntryNotFound {

@@ -337,14 +355,16 @@
         R visitFloat(CONSTANT_Float_info info, P p);
         R visitInteger(CONSTANT_Integer_info info, P p);
         R visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, P p);
         R visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, P p);
         R visitLong(CONSTANT_Long_info info, P p);
-        R visitNameAndType(CONSTANT_NameAndType_info info, P p);
         R visitMethodref(CONSTANT_Methodref_info info, P p);
         R visitMethodHandle(CONSTANT_MethodHandle_info info, P p);
         R visitMethodType(CONSTANT_MethodType_info info, P p);
+        R visitModule(CONSTANT_Module_info info, P p);
+        R visitNameAndType(CONSTANT_NameAndType_info info, P p);
+        R visitPackage(CONSTANT_Package_info info, P p);
         R visitString(CONSTANT_String_info info, P p);
         R visitUtf8(CONSTANT_Utf8_info info, P p);
     }
 
     public static abstract class CPInfo {

@@ -779,10 +799,50 @@
         public <R, D> R accept(Visitor<R, D> visitor, D data) {
             return visitor.visitMethodref(this, data);
         }
     }
 
+    public static class CONSTANT_Module_info extends CPInfo {
+        CONSTANT_Module_info(ConstantPool cp, ClassReader cr) throws IOException {
+            super(cp);
+            name_index = cr.readUnsignedShort();
+        }
+
+        public CONSTANT_Module_info(ConstantPool cp, int name_index) {
+            super(cp);
+            this.name_index = name_index;
+        }
+
+        public int getTag() {
+            return CONSTANT_Module;
+        }
+
+        public int  byteLength() {
+            return 3;
+        }
+
+        /**
+         * Get the raw value of the module name referenced by this constant pool entry.
+         * This will be the name of the module.
+         * @return the raw value of the module name
+         */
+        public String getName() throws ConstantPoolException {
+            return cp.getUTF8Value(name_index);
+        }
+
+        @Override
+        public String toString() {
+            return "CONSTANT_Module_info[name_index: " + name_index + "]";
+        }
+
+        public <R, D> R accept(Visitor<R, D> visitor, D data) {
+            return visitor.visitModule(this, data);
+        }
+
+        public final int name_index;
+    }
+
     public static class CONSTANT_NameAndType_info extends CPInfo {
         CONSTANT_NameAndType_info(ConstantPool cp, ClassReader cr) throws IOException {
             super(cp);
             name_index = cr.readUnsignedShort();
             type_index = cr.readUnsignedShort();

@@ -821,10 +881,50 @@
 
         public final int name_index;
         public final int type_index;
     }
 
+    public static class CONSTANT_Package_info extends CPInfo {
+        CONSTANT_Package_info(ConstantPool cp, ClassReader cr) throws IOException {
+            super(cp);
+            name_index = cr.readUnsignedShort();
+        }
+
+        public CONSTANT_Package_info(ConstantPool cp, int name_index) {
+            super(cp);
+            this.name_index = name_index;
+        }
+
+        public int getTag() {
+            return CONSTANT_Package;
+        }
+
+        public int  byteLength() {
+            return 3;
+        }
+
+        /**
+         * Get the raw value of the package name referenced by this constant pool entry.
+         * This will be the name of the package, in internal form.
+         * @return the raw value of the module name
+         */
+        public String getName() throws ConstantPoolException {
+            return cp.getUTF8Value(name_index);
+        }
+
+        @Override
+        public String toString() {
+            return "CONSTANT_Package_info[name_index: " + name_index + "]";
+        }
+
+        public <R, D> R accept(Visitor<R, D> visitor, D data) {
+            return visitor.visitPackage(this, data);
+        }
+
+        public final int name_index;
+    }
+
     public static class CONSTANT_String_info extends CPInfo {
         CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException {
             super(cp);
             string_index = cr.readUnsignedShort();
         }
< prev index next >