提交 a9c98dbd 编写于 作者: K ksrini

8008262: pack200 should support MethodParameters - part 2

Reviewed-by: jrose
上级 a865220e
...@@ -177,7 +177,7 @@ class Attribute implements Comparable<Attribute> { ...@@ -177,7 +177,7 @@ class Attribute implements Comparable<Attribute> {
define(sd, ATTR_CONTEXT_METHOD, "Synthetic", ""); define(sd, ATTR_CONTEXT_METHOD, "Synthetic", "");
define(sd, ATTR_CONTEXT_METHOD, "Deprecated", ""); define(sd, ATTR_CONTEXT_METHOD, "Deprecated", "");
define(sd, ATTR_CONTEXT_METHOD, "Exceptions", "NH[RCH]"); define(sd, ATTR_CONTEXT_METHOD, "Exceptions", "NH[RCH]");
define(sd, ATTR_CONTEXT_METHOD, "MethodParameters", "NB[RUNHI]"); define(sd, ATTR_CONTEXT_METHOD, "MethodParameters", "NB[RUNHFH]");
//define(sd, ATTR_CONTEXT_METHOD, "Code", "HHNI[B]NH[PHPOHPOHRCNH]NH[RUHNI[B]]"); //define(sd, ATTR_CONTEXT_METHOD, "Code", "HHNI[B]NH[PHPOHPOHRCNH]NH[RUHNI[B]]");
define(sd, ATTR_CONTEXT_CODE, "StackMapTable", define(sd, ATTR_CONTEXT_CODE, "StackMapTable",
......
...@@ -1505,7 +1505,7 @@ class BandStructure { ...@@ -1505,7 +1505,7 @@ class BandStructure {
// band for predefine method parameters // band for predefine method parameters
IntBand method_MethodParameters_NB = method_attr_bands.newIntBand("method_MethodParameters_NB", BYTE1); IntBand method_MethodParameters_NB = method_attr_bands.newIntBand("method_MethodParameters_NB", BYTE1);
CPRefBand method_MethodParameters_name_RUN = method_attr_bands.newCPRefBand("method_MethodParameters_name_RUN", UNSIGNED5, CONSTANT_Utf8, NULL_IS_OK); CPRefBand method_MethodParameters_name_RUN = method_attr_bands.newCPRefBand("method_MethodParameters_name_RUN", UNSIGNED5, CONSTANT_Utf8, NULL_IS_OK);
IntBand method_MethodParameters_flag_I = method_attr_bands.newIntBand("method_MethodParameters_flag_I"); IntBand method_MethodParameters_flag_FH = method_attr_bands.newIntBand("method_MethodParameters_flag_FH");
MultiBand class_attr_bands = class_bands.newMultiBand("(class_attr_bands)", UNSIGNED5); MultiBand class_attr_bands = class_bands.newMultiBand("(class_attr_bands)", UNSIGNED5);
IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi"); IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi");
...@@ -1776,9 +1776,9 @@ class BandStructure { ...@@ -1776,9 +1776,9 @@ class BandStructure {
new Band[]{ new Band[]{
method_MethodParameters_NB, method_MethodParameters_NB,
method_MethodParameters_name_RUN, method_MethodParameters_name_RUN,
method_MethodParameters_flag_I method_MethodParameters_flag_FH
}, },
"MethodParameters", "NB[RUNHI]"); "MethodParameters", "NB[RUNHFH]");
assert(attrCodeEmpty == Package.attrCodeEmpty); assert(attrCodeEmpty == Package.attrCodeEmpty);
predefineAttribute(X_ATTR_Signature, ATTR_CONTEXT_METHOD, predefineAttribute(X_ATTR_Signature, ATTR_CONTEXT_METHOD,
new Band[] { method_Signature_RS }, new Band[] { method_Signature_RS },
......
...@@ -1521,7 +1521,7 @@ class PackageReader extends BandStructure { ...@@ -1521,7 +1521,7 @@ class PackageReader extends BandStructure {
// *method_Exceptions_RC :UNSIGNED5 (cp_Class) // *method_Exceptions_RC :UNSIGNED5 (cp_Class)
// *method_MethodParameters_NB: BYTE1 // *method_MethodParameters_NB: BYTE1
// *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8) // *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8)
// *method_MethodParameters_I: UNSIGNED5 (flag) // *method_MethodParameters_FH: UNSIGNED5 (flag)
// //
// code_attr_bands: // code_attr_bands:
// *code_flags :UNSIGNED5 // *code_flags :UNSIGNED5
......
...@@ -354,7 +354,7 @@ const band_init all_band_inits[] = { ...@@ -354,7 +354,7 @@ const band_init all_band_inits[] = {
BAND_INIT(method_metadata_bands, -1, -1), BAND_INIT(method_metadata_bands, -1, -1),
BAND_INIT(method_MethodParameters_NB, BYTE1_spec, 0), BAND_INIT(method_MethodParameters_NB, BYTE1_spec, 0),
BAND_INIT(method_MethodParameters_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)), BAND_INIT(method_MethodParameters_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
BAND_INIT(method_MethodParameters_flag_I, UNSIGNED5_spec, 0), BAND_INIT(method_MethodParameters_flag_FH, UNSIGNED5_spec, 0),
BAND_INIT(method_attr_bands, -1, -1), BAND_INIT(method_attr_bands, -1, -1),
BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0), BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0),
BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0), BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0),
......
...@@ -214,7 +214,7 @@ enum band_number { ...@@ -214,7 +214,7 @@ enum band_number {
e_method_metadata_bands, e_method_metadata_bands,
e_method_MethodParameters_NB, e_method_MethodParameters_NB,
e_method_MethodParameters_name_RUN, e_method_MethodParameters_name_RUN,
e_method_MethodParameters_flag_I, e_method_MethodParameters_flag_FH,
e_method_attr_bands, e_method_attr_bands,
e_class_flags_hi, e_class_flags_hi,
...@@ -393,7 +393,7 @@ enum band_number { ...@@ -393,7 +393,7 @@ enum band_number {
#define method_Signature_RS all_bands[e_method_Signature_RS] #define method_Signature_RS all_bands[e_method_Signature_RS]
#define method_MethodParameters_NB all_bands[e_method_MethodParameters_NB] #define method_MethodParameters_NB all_bands[e_method_MethodParameters_NB]
#define method_MethodParameters_name_RUN all_bands[e_method_MethodParameters_name_RUN] #define method_MethodParameters_name_RUN all_bands[e_method_MethodParameters_name_RUN]
#define method_MethodParameters_flag_I all_bands[e_method_MethodParameters_flag_I] #define method_MethodParameters_flag_FH all_bands[e_method_MethodParameters_flag_FH]
#define method_attr_bands all_bands[e_method_attr_bands] #define method_attr_bands all_bands[e_method_attr_bands]
#define class_flags_hi all_bands[e_class_flags_hi] #define class_flags_hi all_bands[e_class_flags_hi]
#define class_flags_lo all_bands[e_class_flags_lo] #define class_flags_lo all_bands[e_class_flags_lo]
......
...@@ -2488,7 +2488,7 @@ void unpacker::read_attrs(int attrc, int obj_count) { ...@@ -2488,7 +2488,7 @@ void unpacker::read_attrs(int attrc, int obj_count) {
method_MethodParameters_NB.readData(count); method_MethodParameters_NB.readData(count);
count = method_MethodParameters_NB.getIntTotal(); count = method_MethodParameters_NB.getIntTotal();
method_MethodParameters_name_RUN.readData(count); method_MethodParameters_name_RUN.readData(count);
method_MethodParameters_flag_I.readData(count); method_MethodParameters_flag_FH.readData(count);
CHECK; CHECK;
break; break;
...@@ -4431,7 +4431,7 @@ int unpacker::write_attrs(int attrc, julong indexBits) { ...@@ -4431,7 +4431,7 @@ int unpacker::write_attrs(int attrc, julong indexBits) {
putu1(count = method_MethodParameters_NB.getByte()); putu1(count = method_MethodParameters_NB.getByte());
for (j = 0; j < count; j++) { for (j = 0; j < count; j++) {
putref(method_MethodParameters_name_RUN.getRefN()); putref(method_MethodParameters_name_RUN.getRefN());
putu4(method_MethodParameters_flag_I.getInt()); putu2(method_MethodParameters_flag_FH.getInt());
} }
break; break;
......
...@@ -29,7 +29,7 @@ import java.util.List; ...@@ -29,7 +29,7 @@ import java.util.List;
import static java.nio.file.StandardOpenOption.*; import static java.nio.file.StandardOpenOption.*;
/* /*
* @test * @test
* @bug 6746111 8005252 * @bug 6746111 8005252 8008262
* @summary tests various classfile format and attribute handling by pack200 * @summary tests various classfile format and attribute handling by pack200
* @compile -XDignore.symbol.file Utils.java AttributeTests.java * @compile -XDignore.symbol.file Utils.java AttributeTests.java
* @run main AttributeTests * @run main AttributeTests
...@@ -67,17 +67,17 @@ public class AttributeTests { ...@@ -67,17 +67,17 @@ public class AttributeTests {
File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT); File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);
Utils.jar("cvf", testjarFile.getName(), javaClassName); Utils.jar("cvf", testjarFile.getName(), javaClassName);
// pack using --repack // pack using native --repack
File outjarFile = new File(cwd, "out" + Utils.JAR_FILE_EXT); File nativejarFile = new File(cwd, "out-n" + Utils.JAR_FILE_EXT);
scratch.clear(); Utils.repack(testjarFile, nativejarFile, false,
scratch.add(Utils.getPack200Cmd()); "--unknown-attribute=error");
scratch.add("--repack"); Utils.doCompareVerify(testjarFile, nativejarFile);
scratch.add("--unknown-attribute=error");
scratch.add(outjarFile.getName());
scratch.add(testjarFile.getName());
Utils.runExec(scratch);
Utils.doCompareVerify(testjarFile, outjarFile); // pack using java --repack
File javajarFile = new File(cwd, "out-j" + Utils.JAR_FILE_EXT);
Utils.repack(testjarFile, javajarFile, true,
"--unknown-attribute=error");
Utils.doCompareBitWise(nativejarFile, javajarFile);
} }
/* /*
* this test checks to see if we get the expected strings for output * this test checks to see if we get the expected strings for output
......
/* /*
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -314,6 +314,27 @@ class Utils { ...@@ -314,6 +314,27 @@ class Utils {
throw new RuntimeException("jar command failed"); throw new RuntimeException("jar command failed");
} }
} }
static List<String> repack(File inFile, File outFile,
boolean disableNative, String... extraOpts) {
List<String> cmdList = new ArrayList<>();
cmdList.clear();
cmdList.add(Utils.getJavaCmd());
cmdList.add("-ea");
cmdList.add("-esa");
if (disableNative) {
cmdList.add("-Dcom.sun.java.util.jar.pack.disable.native=true");
}
cmdList.add("com.sun.java.util.jar.pack.Driver");
cmdList.add("--repack");
if (extraOpts != null) {
for (String opt: extraOpts) {
cmdList.add(opt);
}
}
cmdList.add(outFile.getName());
cmdList.add(inFile.getName());
return Utils.runExec(cmdList);
}
// given a jar file foo.jar will write to foo.pack // given a jar file foo.jar will write to foo.pack
static void pack(JarFile jarFile, File packFile) throws IOException { static void pack(JarFile jarFile, File packFile) throws IOException {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册