8080675: Enhance the classfile library to support construction of classfiles from scratch
authorjlahoda
Wed, 01 Jul 2015 09:51:47 +0200
changeset 31505 98c52b994430
parent 31302 f66c18528472
child 31506 4e07f827a794
8080675: Enhance the classfile library to support construction of classfiles from scratch Reviewed-by: jjg
langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Annotation.java
langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attributes.java
langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Annotation.java	Wed Jul 05 20:39:43 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Annotation.java	Wed Jul 01 09:51:47 2015 +0200
@@ -131,6 +131,11 @@
             const_value_index = cr.readUnsignedShort();
         }
 
+        public Primitive_element_value(int const_value_index, int tag) {
+            super(tag);
+            this.const_value_index = const_value_index;
+        }
+
         @Override
         public int length() {
             return 2;
@@ -151,6 +156,12 @@
             const_name_index = cr.readUnsignedShort();
         }
 
+        public Enum_element_value(int type_name_index, int const_name_index, int tag) {
+            super(tag);
+            this.type_name_index = type_name_index;
+            this.const_name_index = const_name_index;
+        }
+
         @Override
         public int length() {
             return 4;
@@ -170,6 +181,11 @@
             class_info_index = cr.readUnsignedShort();
         }
 
+        public Class_element_value(int class_info_index, int tag) {
+            super(tag);
+            this.class_info_index = class_info_index;
+        }
+
         @Override
         public int length() {
             return 2;
@@ -189,6 +205,11 @@
             annotation_value = new Annotation(cr);
         }
 
+        public Annotation_element_value(Annotation annotation_value, int tag) {
+            super(tag);
+            this.annotation_value = annotation_value;
+        }
+
         @Override
         public int length() {
             return annotation_value.length();
@@ -211,6 +232,12 @@
                 values[i] = element_value.read(cr);
         }
 
+        public Array_element_value(element_value[] values, int tag) {
+            super(tag);
+            this.num_values = values.length;
+            this.values = values;
+        }
+
         @Override
         public int length() {
             int n = 2;
@@ -234,6 +261,11 @@
             value = element_value.read(cr);
         }
 
+        public element_value_pair(int element_name_index, element_value value) {
+            this.element_name_index = element_name_index;
+            this.value = value;
+        }
+
         public int length() {
             return 2 + value.length();
         }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attributes.java	Wed Jul 05 20:39:43 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attributes.java	Wed Jul 01 09:51:47 2015 +0200
@@ -69,6 +69,11 @@
         }
     }
 
+    public Attributes(Map<String, Attribute> attributes) {
+        this.attrs = attributes.values().toArray(new Attribute[attributes.size()]);
+        map = attributes;
+    }
+
     public Iterator<Attribute> iterator() {
         return Arrays.asList(attrs).iterator();
     }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java	Wed Jul 05 20:39:43 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java	Wed Jul 01 09:51:47 2015 +0200
@@ -72,6 +72,13 @@
             inner_class_access_flags = new AccessFlags(cr.readUnsignedShort());
         }
 
+        public Info(int inner_class_info_index, int outer_class_info_index, int inner_name_index, AccessFlags inner_class_access_flags) {
+            this.inner_class_info_index = inner_class_info_index;
+            this.outer_class_info_index = outer_class_info_index;
+            this.inner_name_index = inner_name_index;
+            this.inner_class_access_flags = inner_class_access_flags;
+        }
+
         public CONSTANT_Class_info getInnerClassInfo(ConstantPool constant_pool) throws ConstantPoolException {
             if (inner_class_info_index == 0)
                 return null;