Thu, 27 Mar 2014 10:29:51 -0700
8035104: reorder class file attributes in javap listing
Reviewed-by: ksrini
1.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Mar 26 12:18:11 2014 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Mar 27 10:29:51 2014 -0700 1.3 @@ -202,7 +202,6 @@ 1.4 if (options.verbose) { 1.5 println(); 1.6 indent(+1); 1.7 - attrWriter.write(cf, cf.attributes, constant_pool); 1.8 println("minor version: " + cf.minor_version); 1.9 println("major version: " + cf.major_version); 1.10 writeList("flags: ", flags.getClassFlags(), "\n"); 1.11 @@ -218,6 +217,10 @@ 1.12 writeMethods(); 1.13 indent(-1); 1.14 println("}"); 1.15 + 1.16 + if (options.verbose) { 1.17 + attrWriter.write(cf, cf.attributes, constant_pool); 1.18 + } 1.19 } 1.20 // where 1.21 class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> {
2.1 --- a/test/tools/javap/T4975569.java Wed Mar 26 12:18:11 2014 +0100 2.2 +++ b/test/tools/javap/T4975569.java Thu Mar 27 10:29:51 2014 -0700 2.3 @@ -40,10 +40,10 @@ 2.4 verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"); 2.5 verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"); 2.6 verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC", 2.7 - "InnerClasses:\n static"); 2.8 + "InnerClasses:\n static"); 2.9 verify("T4975569$V", "void m(java.lang.String...)", 2.10 "flags: ACC_VARARGS"); 2.11 - verify("T4975569$Prot", "InnerClasses:\n protected"); 2.12 + verify("T4975569$Prot", "InnerClasses:\n protected"); 2.13 //verify("T4975569$Priv", "InnerClasses"); 2.14 if (errors > 0) 2.15 throw new Error(errors + " found.");
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javap/T8035104.java Thu Mar 27 10:29:51 2014 -0700 3.3 @@ -0,0 +1,67 @@ 3.4 +/* 3.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 8035104 3.30 + * @summary reorder class file attributes in javap listing 3.31 + */ 3.32 + 3.33 +import java.io.*; 3.34 + 3.35 +public class T8035104 { 3.36 + public static void main(String[] args) throws Exception { 3.37 + new T8035104().run(); 3.38 + } 3.39 + 3.40 + public void run() throws Exception { 3.41 + String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+"); 3.42 + int minor = -1; 3.43 + int SourceFile = -1; 3.44 + for (int i = 0; i < lines.length; i++) { 3.45 + String line = lines[i]; 3.46 + if (line.matches(" *minor version: [0-9.]+")) 3.47 + minor = i; 3.48 + if (line.matches(" *SourceFile: .+")) 3.49 + SourceFile = i; 3.50 + } 3.51 + if (minor == -1) 3.52 + throw new Exception("minor version not found"); 3.53 + if (SourceFile == -1) 3.54 + throw new Exception("SourceFile not found"); 3.55 + if (SourceFile < minor) 3.56 + throw new Exception("unexpected order of output"); 3.57 + 3.58 + System.out.println("output OK"); 3.59 + } 3.60 + 3.61 + String javap(String... args) { 3.62 + StringWriter sw = new StringWriter(); 3.63 + PrintWriter out = new PrintWriter(sw); 3.64 + int rc = com.sun.tools.javap.Main.run(args, out); 3.65 + out.close(); 3.66 + System.out.println(sw.toString()); 3.67 + System.out.println("javap exited, rc=" + rc); 3.68 + return sw.toString(); 3.69 + } 3.70 +}