提交 a9c98dbd 编写于 作者: K ksrini

8008262: pack200 should support MethodParameters - part 2

Reviewed-by: jrose
上级 a865220e
......@@ -177,7 +177,7 @@ class Attribute implements Comparable<Attribute> {
define(sd, ATTR_CONTEXT_METHOD, "Synthetic", "");
define(sd, ATTR_CONTEXT_METHOD, "Deprecated", "");
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_CODE, "StackMapTable",
......
......@@ -1505,7 +1505,7 @@ class BandStructure {
// band for predefine method parameters
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);
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);
IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi");
......@@ -1776,9 +1776,9 @@ class BandStructure {
new Band[]{
method_MethodParameters_NB,
method_MethodParameters_name_RUN,
method_MethodParameters_flag_I
method_MethodParameters_flag_FH
},
"MethodParameters", "NB[RUNHI]");
"MethodParameters", "NB[RUNHFH]");
assert(attrCodeEmpty == Package.attrCodeEmpty);
predefineAttribute(X_ATTR_Signature, ATTR_CONTEXT_METHOD,
new Band[] { method_Signature_RS },
......
......@@ -1521,7 +1521,7 @@ class PackageReader extends BandStructure {
// *method_Exceptions_RC :UNSIGNED5 (cp_Class)
// *method_MethodParameters_NB: BYTE1
// *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8)
// *method_MethodParameters_I: UNSIGNED5 (flag)
// *method_MethodParameters_FH: UNSIGNED5 (flag)
//
// code_attr_bands:
// *code_flags :UNSIGNED5
......
......@@ -354,7 +354,7 @@ const band_init all_band_inits[] = {
BAND_INIT(method_metadata_bands, -1, -1),
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_flag_I, UNSIGNED5_spec, 0),
BAND_INIT(method_MethodParameters_flag_FH, UNSIGNED5_spec, 0),
BAND_INIT(method_attr_bands, -1, -1),
BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0),
BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0),
......
......@@ -214,7 +214,7 @@ enum band_number {
e_method_metadata_bands,
e_method_MethodParameters_NB,
e_method_MethodParameters_name_RUN,
e_method_MethodParameters_flag_I,
e_method_MethodParameters_flag_FH,
e_method_attr_bands,
e_class_flags_hi,
......@@ -393,7 +393,7 @@ enum band_number {
#define method_Signature_RS all_bands[e_method_Signature_RS]
#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_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 class_flags_hi all_bands[e_class_flags_hi]
#define class_flags_lo all_bands[e_class_flags_lo]
......
......@@ -2488,7 +2488,7 @@ void unpacker::read_attrs(int attrc, int obj_count) {
method_MethodParameters_NB.readData(count);
count = method_MethodParameters_NB.getIntTotal();
method_MethodParameters_name_RUN.readData(count);
method_MethodParameters_flag_I.readData(count);
method_MethodParameters_flag_FH.readData(count);
CHECK;
break;
......@@ -4431,7 +4431,7 @@ int unpacker::write_attrs(int attrc, julong indexBits) {
putu1(count = method_MethodParameters_NB.getByte());
for (j = 0; j < count; j++) {
putref(method_MethodParameters_name_RUN.getRefN());
putu4(method_MethodParameters_flag_I.getInt());
putu2(method_MethodParameters_flag_FH.getInt());
}
break;
......
......@@ -29,7 +29,7 @@ import java.util.List;
import static java.nio.file.StandardOpenOption.*;
/*
* @test
* @bug 6746111 8005252
* @bug 6746111 8005252 8008262
* @summary tests various classfile format and attribute handling by pack200
* @compile -XDignore.symbol.file Utils.java AttributeTests.java
* @run main AttributeTests
......@@ -67,17 +67,17 @@ public class AttributeTests {
File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);
Utils.jar("cvf", testjarFile.getName(), javaClassName);
// pack using --repack
File outjarFile = new File(cwd, "out" + Utils.JAR_FILE_EXT);
scratch.clear();
scratch.add(Utils.getPack200Cmd());
scratch.add("--repack");
scratch.add("--unknown-attribute=error");
scratch.add(outjarFile.getName());
scratch.add(testjarFile.getName());
Utils.runExec(scratch);
// pack using native --repack
File nativejarFile = new File(cwd, "out-n" + Utils.JAR_FILE_EXT);
Utils.repack(testjarFile, nativejarFile, false,
"--unknown-attribute=error");
Utils.doCompareVerify(testjarFile, nativejarFile);
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
......
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -314,6 +314,27 @@ class Utils {
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
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.
先完成此消息的编辑!
想要评论请 注册