changeset 21:b39db18c6f6a

Update to support new attributes: NestHost, NestMembers, contributed by: leonid.kuskov@oracle.com
author afedorch
date Wed, 07 Mar 2018 12:15:23 -0800
parents 872f704a0d9a
children 1e6791f5e622
files .hgignore src/org/openjdk/asmtools/jasm/CFVersion.java src/org/openjdk/asmtools/jasm/Main.java src/org/openjdk/asmtools/jasm/Tables.java src/org/openjdk/asmtools/jdec/ClassData.java
diffstat 5 files changed, 32 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Jan 02 11:47:06 2018 -0800
+++ b/.hgignore	Wed Mar 07 12:15:23 2018 -0800
@@ -1,3 +1,4 @@
+re:data
 re:data/.*
 re:asmtools-6.0-build/.*
 re:.*~$
--- a/src/org/openjdk/asmtools/jasm/CFVersion.java	Tue Jan 02 11:47:06 2018 -0800
+++ b/src/org/openjdk/asmtools/jasm/CFVersion.java	Wed Mar 07 12:15:23 2018 -0800
@@ -44,8 +44,8 @@
         minor_version = UNDEFINED_VERSION;
     }
 
-    public CFVersion(short major_version, short minor_version) {
-        frozen = true;
+    public CFVersion(boolean frozenCFV, short major_version, short minor_version) {
+        frozen = frozenCFV;
         this.major_version = major_version;
         this.minor_version = minor_version;
     }
--- a/src/org/openjdk/asmtools/jasm/Main.java	Tue Jan 02 11:47:06 2018 -0800
+++ b/src/org/openjdk/asmtools/jasm/Main.java	Wed Mar 07 12:15:23 2018 -0800
@@ -107,6 +107,7 @@
      */
     private synchronized boolean parseArgs(String argv[]) {
         // Parse arguments
+        boolean frozenCFV = false;
         for (int i = 0; i < argv.length; i++) {
             String arg = argv[i];
             switch (arg) {
@@ -180,6 +181,10 @@
                         }
                     }
                     break;
+                case "-fixcv":
+                    // overrides cf version if it's defined in the source file.
+                    frozenCFV = true;
+                // public options
                 case "-cv":
                     if ((i + 1) >= argv.length) {
                         error(i18n.getString("jasm.error.cv_requires_arg"));
@@ -198,7 +203,7 @@
                         return false;
                     }
                     try {
-                        cfv = new CFVersion(Short.parseShort(versions[0]), Short.parseShort(versions[1]) );
+                        cfv = new CFVersion(frozenCFV, Short.parseShort(versions[0]), Short.parseShort(versions[1]) );
                     } catch (NumberFormatException e) {
                         error(i18n.getString("jasm.error.invalid_major_minor_param"));
                         usage();
--- a/src/org/openjdk/asmtools/jasm/Tables.java	Tue Jan 02 11:47:06 2018 -0800
+++ b/src/org/openjdk/asmtools/jasm/Tables.java	Wed Mar 07 12:15:23 2018 -0800
@@ -188,7 +188,7 @@
         // Constant for ME Spec (StackMap does not appear in SE VM Spec)
         ATT_Unrecognized                            (0, "ATT_Unrecognized", ""),
         ATT_StackMap                                (1, "ATT_StackMap", "StackMap"),
-    // Numbers corespond to VM spec (chapter 4.7.X)
+        // Numbers corespond to VM spec (chapter 4.7.X)
         ATT_ConstantValue                           (2, "ATT_ConstantValue", "ConstantValue"),
         ATT_Code                                    (3, "ATT_Code", "Code"),
         ATT_StackMapTable                           (4, "ATT_StackMapTable", "StackMapTable"),
@@ -218,7 +218,10 @@
         ATT_MainClass                               (28, "ATT_MainClass", "MainClass"),
         ATT_ModulePackages                          (29, "ATT_ModulePackages", "ModulePackages"),
         ATT_ModuleMainClass                         (30, "ATT_ModuleMainClass", "ModuleMainClass"),
-        ATT_ModuleTarget                            (31, "ATT_ModuleTarget", "ModuleTarget");
+        ATT_ModuleTarget                            (31, "ATT_ModuleTarget", "ModuleTarget"),
+        // JEP 181: class file 55.0
+        ATT_NestHost                                (32, "ATT_NestHost", "NestHost"),
+        ATT_NestMembers                             (33, "ATT_NestMembers", "NestMembers");
 
         private final Integer value;
         private final String printval;
--- a/src/org/openjdk/asmtools/jdec/ClassData.java	Tue Jan 02 11:47:06 2018 -0800
+++ b/src/org/openjdk/asmtools/jdec/ClassData.java	Wed Mar 07 12:15:23 2018 -0800
@@ -355,7 +355,7 @@
                 if (printDetails) {
                     out_println(" at " + toHex(pos));
                 } else {
-                    out_println("");
+                    out.println();
                 }
             }
         } finally {
@@ -928,6 +928,21 @@
                         out_end("}");
                     }
                     break;
+                // JEP 181: class file 55.0
+                case ATT_NestHost:
+                    decodeCPXAttr(in, len, AttrName, out);
+                    break;
+                case ATT_NestMembers:
+                    int cls_num = in.readUnsignedShort();
+                    startArrayCmt(cls_num, AttrName);
+                    try {
+                        for (int i = 0; i < cls_num; i++) {
+                            out_println("#" + in.readUnsignedShort() + ";" + getCommentPosCond());
+                        }
+                    } finally {
+                        out_end("}");
+                    }
+                    break;
                 default:
                     if (AttrName == null) {
                         printBytes(out, in, len);
@@ -985,7 +1000,7 @@
         if (printDetails) {
             out_print(" : " + entityName);
         }
-        out_println("");
+        out.println();
 
         // u2 module_flags
         int moduleFlags = in.readUnsignedShort();
@@ -993,7 +1008,7 @@
         if (printDetails) {
             out_print(" " + Module.Modifier.getModuleFlags(moduleFlags));
         }
-        out_println("");
+        out.println();
 
         //u2 module_version
         int versionIndex = in.readUnsignedShort();