--- old/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Wed Jan 9 18:49:24 2013 +++ new/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Wed Jan 9 18:49:23 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -177,6 +177,7 @@ 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, "Code", "HHNI[B]NH[PHPOHPOHRCNH]NH[RUHNI[B]]"); define(sd, ATTR_CONTEXT_CODE, "StackMapTable", --- old/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java Wed Jan 9 18:49:26 2013 +++ new/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java Wed Jan 9 18:49:25 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -1502,6 +1502,10 @@ CPRefBand method_Exceptions_RC = method_attr_bands.newCPRefBand("method_Exceptions_RC", CONSTANT_Class); CPRefBand method_Signature_RS = method_attr_bands.newCPRefBand("method_Signature_RS", CONSTANT_Signature); MultiBand method_metadata_bands = method_attr_bands.newMultiBand("(method_metadata_bands)", UNSIGNED5); + // 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"); MultiBand class_attr_bands = class_bands.newMultiBand("(class_attr_bands)", UNSIGNED5); IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi"); @@ -1768,6 +1772,13 @@ method_Exceptions_RC }, "Exceptions", "NH[RCH]"); + predefineAttribute(METHOD_ATTR_MethodParameters, ATTR_CONTEXT_METHOD, + new Band[]{ + method_MethodParameters_NB, + method_MethodParameters_name_RUN, + method_MethodParameters_flag_I + }, + "MethodParameters", "NB[RUNHI]"); assert(attrCodeEmpty == Package.attrCodeEmpty); predefineAttribute(X_ATTR_Signature, ATTR_CONTEXT_METHOD, new Band[] { method_Signature_RS }, --- old/src/share/classes/com/sun/java/util/jar/pack/Constants.java Wed Jan 9 18:49:28 2013 +++ new/src/share/classes/com/sun/java/util/jar/pack/Constants.java Wed Jan 9 18:49:28 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,6 +73,9 @@ public final static Package.Version JAVA7_PACKAGE_VERSION = Package.Version.of(170, 1); + public final static Package.Version JAVA8_PACKAGE_VERSION = + Package.Version.of(171, 0); + // upper limit, should point to the latest class version public final static Package.Version JAVA_MAX_CLASS_VERSION = JAVA8_MAX_CLASS_VERSION; @@ -158,6 +161,7 @@ METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24, CLASS_ATTR_ClassFile_version = 24, METHOD_ATTR_AnnotationDefault = 25, + METHOD_ATTR_MethodParameters = 26, CODE_ATTR_StackMapTable = 0, // new in Java 6 CODE_ATTR_LineNumberTable = 1, CODE_ATTR_LocalVariableTable = 2, --- old/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java Wed Jan 9 18:49:31 2013 +++ new/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java Wed Jan 9 18:49:30 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -242,6 +242,7 @@ void checkArchiveVersion() throws IOException { Package.Version versionFound = null; for (Package.Version v : new Package.Version[] { + JAVA8_PACKAGE_VERSION, JAVA7_PACKAGE_VERSION, JAVA6_PACKAGE_VERSION, JAVA5_PACKAGE_VERSION @@ -252,7 +253,9 @@ } } if (versionFound == null) { - String expVer = JAVA7_PACKAGE_VERSION.toString() + String expVer = JAVA8_PACKAGE_VERSION.toString() + + "OR" + + JAVA7_PACKAGE_VERSION.toString() + " OR " + JAVA6_PACKAGE_VERSION.toString() + " OR " @@ -1516,6 +1519,9 @@ // method_metadata_bands // *method_Exceptions_N :UNSIGNED5 // *method_Exceptions_RC :UNSIGNED5 (cp_Class) + // *method_MethodParameters_NB: BYTE1 + // *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8) + // *method_MethodParameters_I: UNSIGNED5 (flag) // // code_attr_bands: // *code_flags :UNSIGNED5 --- old/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Wed Jan 9 18:49:33 2013 +++ new/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Wed Jan 9 18:49:32 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -142,12 +142,14 @@ } else if (highV.equals(JAVA6_MAX_CLASS_VERSION) || (highV.equals(JAVA7_MAX_CLASS_VERSION) && !pkg.cp.haveExtraTags())) { // force down the package version if we have jdk7 classes without - // any Indy references, this is because jdk7 class file (52.0) without - // Indy is identical to jdk6 class file (51.0). + // any Indy references, this is because jdk7 class file (51.0) without + // Indy is identical to jdk6 class file (50.0). packageVersion = JAVA6_PACKAGE_VERSION; + } else if (highV.equals(JAVA7_MAX_CLASS_VERSION)) { + packageVersion = JAVA7_PACKAGE_VERSION; } else { // Normal case. Use the newest archive format, when available - packageVersion = JAVA7_PACKAGE_VERSION; + packageVersion = JAVA8_PACKAGE_VERSION; } if (verbose > 0) { --- old/src/share/native/com/sun/java/util/jar/pack/bands.cpp Wed Jan 9 18:49:35 2013 +++ new/src/share/native/com/sun/java/util/jar/pack/bands.cpp Wed Jan 9 18:49:35 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -352,6 +352,9 @@ BAND_INIT(method_Exceptions_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)), BAND_INIT(method_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)), 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_attr_bands, -1, -1), BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0), BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0), --- old/src/share/native/com/sun/java/util/jar/pack/bands.h Wed Jan 9 18:49:38 2013 +++ new/src/share/native/com/sun/java/util/jar/pack/bands.h Wed Jan 9 18:49:37 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -212,6 +212,9 @@ e_method_Exceptions_RC, e_method_Signature_RS, e_method_metadata_bands, + e_method_MethodParameters_NB, + e_method_MethodParameters_name_RUN, + e_method_MethodParameters_flag_I, e_method_attr_bands, e_class_flags_hi, @@ -388,6 +391,9 @@ #define method_Exceptions_N all_bands[e_method_Exceptions_N] #define method_Exceptions_RC all_bands[e_method_Exceptions_RC] #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_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] --- old/src/share/native/com/sun/java/util/jar/pack/constants.h Wed Jan 9 18:49:40 2013 +++ new/src/share/native/com/sun/java/util/jar/pack/constants.h Wed Jan 9 18:49:39 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -59,6 +59,9 @@ #define JAVA7_PACKAGE_MAJOR_VERSION 170 #define JAVA7_PACKAGE_MINOR_VERSION 1 +#define JAVA8_PACKAGE_MAJOR_VERSION 171 +#define JAVA8_PACKAGE_MINOR_VERSION 0 + // magic number for gzip streams (for processing pack200-gzip data) #define GZIP_MAGIC 0x1F8B0800 #define GZIP_MAGIC_MASK 0xFFFFFF00 // last byte is variable "flg" field @@ -120,6 +123,7 @@ METHOD_ATTR_RuntimeVisibleParameterAnnotations = 23, METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24, METHOD_ATTR_AnnotationDefault = 25, + METHOD_ATTR_MethodParameters = 26, CODE_ATTR_StackMapTable = 0, CODE_ATTR_LineNumberTable = 1, CODE_ATTR_LocalVariableTable = 2, @@ -160,6 +164,7 @@ F(METHOD_ATTR_RuntimeVisibleParameterAnnotations,RuntimeVisibleParameterAnnotations) \ F(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations) \ F(METHOD_ATTR_AnnotationDefault,AnnotationDefault) \ + F(METHOD_ATTR_MethodParameters,MethodParameters) \ /*(end)*/ #define CODE_ATTR_DO(F) \ F(CODE_ATTR_StackMapTable,StackMapTable) \ --- old/src/share/native/com/sun/java/util/jar/pack/main.cpp Wed Jan 9 18:49:42 2013 +++ new/src/share/native/com/sun/java/util/jar/pack/main.cpp Wed Jan 9 18:49:41 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -71,7 +71,7 @@ unpacker* unpacker::non_mt_current = null; unpacker* unpacker::current() { - assert(uThread == THREAD_SELF); + //assert(uThread == THREAD_SELF); return non_mt_current; } static void set_current_unpacker(unpacker* u) { --- old/src/share/native/com/sun/java/util/jar/pack/unpack.cpp Wed Jan 9 18:49:44 2013 +++ new/src/share/native/com/sun/java/util/jar/pack/unpack.cpp Wed Jan 9 18:49:44 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -648,13 +648,14 @@ majver = hdr.getInt(); hdrVals += 2; - int majmin[3][2] = { + int majmin[4][2] = { {JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION}, {JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION}, - {JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION} + {JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION}, + {JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION} }; int majminfound = false; - for (int i = 0 ; i < 3 ; i++) { + for (int i = 0 ; i < 4 ; i++) { if (majver == majmin[i][0] && minver == majmin[i][1]) { majminfound = true; break; @@ -663,11 +664,12 @@ if (majminfound == null) { char message[200]; sprintf(message, "@" ERROR_FORMAT ": magic/ver = " - "%08X/%d.%d should be %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d\n", + "%08X/%d.%d should be %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d\n", magic, majver, minver, JAVA_PACKAGE_MAGIC, JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION, JAVA_PACKAGE_MAGIC, JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION, - JAVA_PACKAGE_MAGIC, JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION); + JAVA_PACKAGE_MAGIC, JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION, + JAVA_PACKAGE_MAGIC, JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION); abort(message); } CHECK; @@ -2481,6 +2483,13 @@ ad.readBandData(METHOD_ATTR_RuntimeInvisibleParameterAnnotations); ad.readBandData(METHOD_ATTR_AnnotationDefault); CHECK; + + count = ad.predefCount(METHOD_ATTR_MethodParameters); + method_MethodParameters_NB.readData(count); + count = method_MethodParameters_NB.getIntTotal(); + method_MethodParameters_name_RUN.readData(count); + method_MethodParameters_flag_I.readData(count); + CHECK; break; case ATTR_CONTEXT_CODE: @@ -4416,6 +4425,15 @@ putref(method_Exceptions_RC.getRefN()); } break; + + case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_MethodParameters): + aname = cp.sym[cpool::s_MethodParameters]; + putu1(count = method_MethodParameters_NB.getByte()); + for (j = 0; j < count; j++) { + putref(method_MethodParameters_name_RUN.getRefN()); + putu4(method_MethodParameters_flag_I.getInt()); + } + break; case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_StackMapTable): aname = cp.sym[cpool::s_StackMapTable]; --- old/test/ProblemList.txt Wed Jan 9 18:49:47 2013 +++ new/test/ProblemList.txt Wed Jan 9 18:49:46 2013 @@ -324,9 +324,6 @@ # 7150569 tools/launcher/UnicodeTest.java macosx-all -# 8005252 -tools/pack200/AttributeTests.java generic-all - ############################################################################ # jdk_jdi --- old/test/tools/pack200/AttributeTests.java Wed Jan 9 18:49:49 2013 +++ new/test/tools/pack200/AttributeTests.java Wed Jan 9 18:49:48 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,13 +21,15 @@ * questions. */ import java.io.File; -import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static java.nio.file.StandardOpenOption.*; /* * @test - * @bug 6746111 + * @bug 6746111 8005252 * @summary tests various classfile format and attribute handling by pack200 * @compile -XDignore.symbol.file Utils.java AttributeTests.java * @run main AttributeTests @@ -37,9 +39,47 @@ public static void main(String... args) throws Exception { test6746111(); + testMethodParameters(); } /* + * this tests ensure that MethodParameters produces by javac is packed + * correctly. Usually this is not the case as new attributes are available + * in the sdk jars, since MethodParameters happens to be an optional + * attribute, thus this test. + */ + static void testMethodParameters() throws Exception { + List scratch = new ArrayList<>(); + final String fname = "MP"; + String javaFileName = fname + Utils.JAVA_FILE_EXT; + String javaClassName = fname + Utils.CLASS_FILE_EXT; + scratch.add("class " + fname + " {"); + scratch.add("void foo2(int j, final int k){}"); + scratch.add("}"); + File cwd = new File("."); + File javaFile = new File(cwd, javaFileName); + Files.write(javaFile.toPath(), scratch, Charset.defaultCharset(), + CREATE, TRUNCATE_EXISTING); + + Utils.compiler(javaFile.getName(), "-parameters"); + + // jar the file up + 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); + + Utils.doCompareVerify(testjarFile, outjarFile); + } + /* * this test checks to see if we get the expected strings for output */ static void test6746111() throws Exception { --- old/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java Wed Jan 9 18:49:54 2013 +++ new/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java Wed Jan 9 18:49:53 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -53,6 +53,7 @@ import com.sun.tools.classfile.LocalVariableTable_attribute; import com.sun.tools.classfile.LocalVariableTypeTable_attribute; import com.sun.tools.classfile.Method; +import com.sun.tools.classfile.MethodParameters_attribute; import com.sun.tools.classfile.Opcode; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; @@ -1069,6 +1070,19 @@ l.setAttr("slot", "" + e.index); l.trimToSize(); p.add(l); + } + return null; // already added to parent + } + + @Override + public Element visitMethodParameters(MethodParameters_attribute mp, Element p) { + String name = x.getCpString(mp.attribute_name_index); + for (MethodParameters_attribute.Entry e : mp.method_parameter_table) { + Element l = new Element(name); + l.setAttr("name", x.getCpString(e.name_index)); + l.setAttr("flag", "" + e.flags); + l.trimToSize(); + p.add(l); } return null; // already added to parent }