Update to support new attributes: NestHost, NestMembers, contributed by: leonid.kuskov@oracle.com

This commit is contained in:
afedorch 2018-03-07 12:15:23 -08:00
parent ec2319539d
commit c78c7b312c
5 changed files with 32 additions and 8 deletions

View File

@ -1,3 +1,4 @@
re:data
re:data/.*
re:asmtools-6.0-build/.*
re:.*~$

View File

@ -44,8 +44,8 @@ public class CFVersion implements Cloneable{
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;
}

View File

@ -107,6 +107,7 @@ public class Main {
*/
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 @@ public class Main {
}
}
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 @@ public class Main {
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();

View File

@ -188,7 +188,7 @@ public class Tables {
// 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 @@ public class Tables {
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;

View File

@ -355,7 +355,7 @@ class ClassData {
if (printDetails) {
out_println(" at " + toHex(pos));
} else {
out_println("");
out.println();
}
}
} finally {
@ -928,6 +928,21 @@ class ClassData {
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 @@ class ClassData {
if (printDetails) {
out_print(" : " + entityName);
}
out_println("");
out.println();
// u2 module_flags
int moduleFlags = in.readUnsignedShort();
@ -993,7 +1008,7 @@ class ClassData {
if (printDetails) {
out_print(" " + Module.Modifier.getModuleFlags(moduleFlags));
}
out_println("");
out.println();
//u2 module_version
int versionIndex = in.readUnsignedShort();