Mercurial > hg > icedtea8-forest > langtools
changeset 2389:dd7b57ab4ab1 icedtea-3.0.0pre01
Merge jdk8u20-b10
author | andrew |
---|---|
date | Tue, 22 Apr 2014 19:50:43 +0100 |
parents | f5793eb2ac89 (current diff) a0d9c18a1041 (diff) |
children | 655c9e5e37bc |
files | .hgtags |
diffstat | 26 files changed, 640 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Tue Apr 22 17:15:42 2014 +0100 +++ b/.hgtags Tue Apr 22 19:50:43 2014 +0100 @@ -256,6 +256,22 @@ bb69217ed81202b1a490dc7150dc7cd073689341 jdk8-b127 09cdd3b493c0d13dc32206e5f12bb1a2f7465687 jdk8-b128 8fe7202d3c38784f3f14368e3954fc4e0394afa4 jdk8-b129 +9d81ae1c417a4748f58921c1f8def7f3c401cecd jdk8-b130 +196ab3dcbd28fac1578590684a337f1c7cf505c9 jdk8-b131 +c8a87a58eb3efdd64055566b502c9d4a72ca0996 jdk8-b132 +519557cab6d4a7fd77b33226e71f92303090420b jdk8u5-b01 +9003a59a512e6b764d8a3f805aadc3996a58e5bd jdk8u5-b02 +30e3dad0ebbdf3129bacd04a7f4cdecd3df92bb2 jdk8u5-b03 +019dcdfffced0ca2026a0ad8c0e5fcb49d46116f jdk8u5-b04 +c9db8c800797258540e0411e58b8f7d59273de5f jdk8u5-b05 +b1920c0b701d5ff219c9f622db5cafc9bf00d5c8 jdk8u5-b06 +180df7f2c078f1efaa6fcd8ca9f55dc5f81b182c jdk8u5-b07 +9c3d7d1a70391bd772693dc5a838b53e1cad0761 jdk8u5-b08 +169c8c1a2e8d1e80a4474d91f7809aa2a6b2249a jdk8u5-b09 +026543c71810701de08cdfd906d1b8fdc69b89c0 jdk8u5-b10 +a12055904afd9f951131804868215e724c71b684 jdk8u5-b11 +2a7002626e7997e946b96530629e2787bc1864bb jdk8u5-b12 +9beafb58fb99e8b5f7577b2f26b12743ef4d07e7 jdk8u5-b13 26b33a6ea08810853af37e81c9b435465b289c98 jdk8u20-b02 a07271bca831cf1bab35a2ffbcebd8e060b2734b jdk8u20-b03 613c1d9930c9f650e3fc6926215931a85b679c66 jdk8u20-b04 @@ -265,3 +281,5 @@ c8a87a58eb3efdd64055566b502c9d4a72ca0996 jdk8-b132 c6d0108aca9f8f45b9cddeb6e483d464509e0127 jdk8u20-b06 1a57c569cb811a897691e42049eca33da8f8d761 jdk8u20-b07 +0f821eb7e92b242c878dca68ef63f9626643ee8f jdk8u20-b08 +aa0cb3af23d376e012a142b0531c4f42032fdacf jdk8u20-b09
--- a/THIRD_PARTY_README Tue Apr 22 17:15:42 2014 +0100 +++ b/THIRD_PARTY_README Tue Apr 22 19:50:43 2014 +0100 @@ -1399,13 +1399,13 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Little CMS 2.4, which may be +%% This notice is provided with respect to Little CMS 2.5, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- Little CMS -Copyright (c) 1998-2010 Marti Maria Saguer +Copyright (c) 1998-2011 Marti Maria Saguer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -247,7 +247,7 @@ } else if (opt.equals("-doctitle")) { doctitle = os[1]; } else if (opt.equals("-windowtitle")) { - windowtitle = os[1]; + windowtitle = os[1].replaceAll("\\<.*?>", ""); } else if (opt.equals("-top")) { top = os[1]; } else if (opt.equals("-bottom")) {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -467,11 +467,24 @@ private boolean hiddenIn(ClassSymbol clazz, Types types) { Symbol sym = hiddenInInternal(clazz, types); - return sym != null && sym != this; + Assert.check(sym != null, "the result of hiddenInInternal() can't be null"); + /* If we find the current symbol then there is no symbol hiding it + */ + return sym != this; } - private Symbol hiddenInInternal(ClassSymbol c, Types types) { - Scope.Entry e = c.members().lookup(name); + /** This method looks in the supertypes graph that has the current class as the + * initial node, till it finds the current symbol or another symbol that hides it. + * If the current class has more than one supertype (extends one class and + * implements one or more interfaces) then null can be returned, meaning that + * a wrong path in the supertypes graph was selected. Null can only be returned + * as a temporary value, as a result of the recursive call. + */ + private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) { + if (currentClass == owner) { + return this; + } + Scope.Entry e = currentClass.members().lookup(name); while (e.scope != null) { if (e.sym.kind == kind && (kind != MTH || @@ -481,18 +494,19 @@ } e = e.next(); } - List<Symbol> hiddenSyms = List.nil(); - for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) { + Symbol hiddenSym = null; + for (Type st : types.interfaces(currentClass.type) + .prepend(types.supertype(currentClass.type))) { if (st != null && (st.hasTag(CLASS))) { Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types); - if (sym != null) { - hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types)); + if (sym == this) { + return this; + } else if (sym != null) { + hiddenSym = sym; } } } - return hiddenSyms.contains(this) ? - this : - (hiddenSyms.isEmpty() ? null : hiddenSyms.head); + return hiddenSym; } /** Is this symbol inherited into a given class?
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -1481,8 +1481,21 @@ } public String toString() { - if (inst != null) return inst.toString(); - else return qtype + "?"; + return (inst == null) ? qtype + "?" : inst.toString(); + } + + public String debugString() { + String result = "inference var = " + qtype + "\n"; + if (inst != null) { + result += "inst = " + inst + '\n'; + } + for (InferenceBound bound: InferenceBound.values()) { + List<Type> aboundList = bounds.get(bound); + if (aboundList.size() > 0) { + result += bound + " = " + aboundList + '\n'; + } + } + return result; } @Override @@ -1492,8 +1505,7 @@ @Override public Type baseType() { - if (inst != null) return inst.baseType(); - else return this; + return (inst == null) ? this : inst.baseType(); } /** get all bounds of a given kind */
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -2119,6 +2119,12 @@ //back-door to infer return Infer.this; } + + @Override + public String toString() { + return "Inference vars: " + inferencevars + '\n' + + "Undet vars: " + undetvars; + } } final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Apr 22 19:50:43 2014 +0100 @@ -1038,7 +1038,7 @@ } databuf.appendChar(pool.get(inner)); databuf.appendChar( - inner.owner.kind == TYP ? pool.get(inner.owner) : 0); + inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0); databuf.appendChar( !inner.name.isEmpty() ? pool.get(inner.name) : 0); databuf.appendChar(flags);
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -2189,9 +2189,9 @@ // Keep local variables if // 1) we need them for debug information // 2) it is an exception type and it contains type annotations - if (!varDebugInfo && - (!var.sym.isExceptionParameter() || - var.sym.hasTypeAnnotations())) return; + boolean keepLocalVariables = varDebugInfo || + (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); + if (!keepLocalVariables) return; if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; if (varBuffer == null) varBuffer = new LocalVar[20];
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Apr 22 19:50:43 2014 +0100 @@ -762,14 +762,14 @@ public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) { // Type parameters are not considered to be enclosed by a type scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitType(e, p); } @Override public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) { // Type parameters are not considered to be enclosed by an executable scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitExecutable(e, p); } void addAnnotations(Element e, Set<TypeElement> p) {
--- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Tue Apr 22 19:50:43 2014 +0100 @@ -137,14 +137,14 @@ public Set<Element> visitType(TypeElement e, TypeElement p) { // Type parameters are not considered to be enclosed by a type scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitType(e, p); } @Override public Set<Element> visitExecutable(ExecutableElement e, TypeElement p) { // Type parameters are not considered to be enclosed by an executable scan(e.getTypeParameters(), p); - return scan(e.getEnclosedElements(), p); + return super.visitExecutable(e, p); } @Override
--- a/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties Tue Apr 22 19:50:43 2014 +0100 @@ -419,8 +419,6 @@ compiler.err.intf.expected.here=\u3053\u3053\u306B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304C\u5FC5\u8981\u3067\u3059 -compiler.err.intf.or.array.expected.here=\u3053\u3053\u306B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u307E\u305F\u306F\u914D\u5217\u578B\u304C\u5FC5\u8981\u3067\u3059 - compiler.err.intf.meth.cant.have.body=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 # 0: symbol
--- a/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties Tue Apr 22 19:50:43 2014 +0100 @@ -419,8 +419,6 @@ compiler.err.intf.expected.here=\u6B64\u5904\u9700\u8981\u63A5\u53E3 -compiler.err.intf.or.array.expected.here=\u6B64\u5904\u9884\u671F\u4E3A\u63A5\u53E3\u6216\u6570\u7EC4\u7C7B\u578B - compiler.err.intf.meth.cant.have.body=\u63A5\u53E3\u62BD\u8C61\u65B9\u6CD5\u4E0D\u80FD\u5E26\u6709\u4E3B\u4F53 # 0: symbol
--- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Apr 22 19:50:43 2014 +0100 @@ -202,7 +202,6 @@ if (options.verbose) { println(); indent(+1); - attrWriter.write(cf, cf.attributes, constant_pool); println("minor version: " + cf.minor_version); println("major version: " + cf.major_version); writeList("flags: ", flags.getClassFlags(), "\n"); @@ -218,6 +217,10 @@ writeMethods(); indent(-1); println("}"); + + if (options.verbose) { + attrWriter.write(cf, cf.attributes, constant_pool); + } } // where class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> {
--- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Tue Apr 22 19:50:43 2014 +0100 @@ -29,8 +29,11 @@ main.opt.dotoutput=\ -dotoutput <dir> DOT\u30D5\u30A1\u30A4\u30EB\u51FA\u529B\u306E\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA +main.opt.jdkinternals=\ -jdkinternals JDK\u5185\u90E8API\u306E\u30AF\u30E9\u30B9\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\u3002\n \u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001-include\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u306A\u3044\u3068\u3001\n -classpath\u306E\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3068\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u3092\u5206\u6790\u3057\u307E\u3059\u3002\n \u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F-p\u3001-e\u304A\u3088\u3073-s\u30AA\u30D7\u30B7\u30E7\u30F3\u3068\u4E00\u7DD2\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002\n \u8B66\u544A: JDK\u5185\u90E8API\u306F\u3001\u6B21\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u304F\u306A\u308B\u53EF\u80FD\u6027\u304C\n \u3042\u308A\u307E\u3059\u3002 + main.opt.depth=\ -depth=<depth> \u63A8\u79FB\u7684\u306A\u4F9D\u5B58\u6027\u5206\u6790\u306E\u6DF1\u3055\u3092\n \u6307\u5B9A\u3057\u307E\u3059 + err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0} err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2}
--- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties Tue Apr 22 17:15:42 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties Tue Apr 22 19:50:43 2014 +0100 @@ -29,8 +29,11 @@ main.opt.dotoutput=\ -dotoutput <dir> DOT \u6587\u4EF6\u8F93\u51FA\u7684\u76EE\u6807\u76EE\u5F55 +main.opt.jdkinternals=\ -jdkinternals \u5728 JDK \u5185\u90E8 API \u4E0A\u67E5\u627E\u7C7B\u7EA7\u522B\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\u3002\n \u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5B83\u5206\u6790 -classpath \u4E0A\u7684\u6240\u6709\u7C7B\n \u548C\u8F93\u5165\u6587\u4EF6, \u9664\u975E\u6307\u5B9A\u4E86 -include \u9009\u9879\u3002\n \u6B64\u9009\u9879\u4E0D\u80FD\u4E0E -p, -e \u548C -s \u9009\u9879\u4E00\u8D77\u4F7F\u7528\u3002\n \u8B66\u544A: \u5728\u4E0B\u4E00\u4E2A\u53D1\u884C\u7248\u4E2D\u53EF\u80FD\u65E0\u6CD5\u8BBF\u95EE\n JDK \u5185\u90E8 API\u3002 + main.opt.depth=\ -depth=<depth> \u6307\u5B9A\u8FC7\u6E21\u88AB\u4F9D\u8D56\u5BF9\u8C61\u5206\u6790\n \u7684\u6DF1\u5EA6 + err.unknown.option=\u672A\u77E5\u9009\u9879: {0} err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2}
--- a/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java Tue Apr 22 17:15:42 2014 +0100 +++ b/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8016675 + * @bug 8016675 8026736 * @summary Test for window title. * @author Bhavesh Patel * @library ../lib/ @@ -34,26 +34,153 @@ public class TestWindowTitle extends JavadocTester { private static final String BUG_ID = "8016675"; - private static final String WIN_TITLE = + //Window title with JavaScript special characters. + private static final String TITLE_JS_CHARS = "Testing \"Window 'Title'\" with a \\ backslash and a / " + "forward slash and a \u00e8 unicode char also a tab and also a " + "\t special character another \u0002 unicode)"; - private static final String[][] TEST = { - {BUG_ID + FS + "overview-summary.html", + private static final String[] ARGS_JS_CHARS = new String[]{ + "-d", BUG_ID + "-1", "-windowtitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_JS_CHARS = { + {BUG_ID + "-1" + FS + "overview-summary.html", "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + "also a tab and also a \\t special character another \\u0002 unicode))\";" }, }; - private static final String[][] NEG_TEST = { - {BUG_ID + FS + "overview-summary.html", + private static final String[][] NEG_TEST_JS_CHARS = { + {BUG_ID + "-1" + FS + "overview-summary.html", "parent.document.title=\"Overview (Testing \"Window \'Title\'\" " + "with a \\ backslash and a / forward slash and a \u00E8 unicode char " + "also a tab and also a \t special character another \u0002 unicode))\";" + } + }; + + //Window title with a script tag. + private static final String TITLE_SCRIPT_TAG = + "Testing script tag in title </title><script>alert(\"Should not pop up\")</script>."; + private static final String[] ARGS_SCRIPT_TAG = new String[]{ + "-d", BUG_ID + "-2", "-windowtitle", TITLE_SCRIPT_TAG, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_SCRIPT_TAG = { + {BUG_ID + "-2" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" }, + {BUG_ID + "-2" + FS + "p2" + FS + "C2.html", + "parent.document.title=\"C2 (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" + } + }; + private static final String[][] NEG_TEST_SCRIPT_TAG = { + {BUG_ID + "-2" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing script tag in title </title><script>" + + "alert(\\\"Should not pop up\\\")</script>.)\";" + }, + {BUG_ID + "-2" + FS + "p2" + FS + "C2.html", + "parent.document.title=\"C2 (Testing script tag in title </title><script>" + + "alert(\\\"Should not pop up\\\")</script>.)\";" + } + }; + + //Window title with other HTML tags. + private static final String TITLE_HTML_TAGS = + "Testing another <p>HTML</p> tag. Another <h1>tag</h1>. A " + + "<span id=\"testTag\">tag with attributes</span>. <script and </p are not tags."; + private static final String[] ARGS_HTML_TAGS = new String[]{ + "-d", BUG_ID + "-3", "-windowtitle", TITLE_HTML_TAGS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_HTML_TAGS = { + {BUG_ID + "-3" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing another HTML tag. Another tag. A " + + "tag with attributes. <script and </p are not tags.)\";" + } + }; + private static final String[][] NEG_TEST_HTML_TAGS = { + {BUG_ID + "-3" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing another <p>HTML</p> tag. Another " + + "<h1>tag</h1>. A <span id=\"testTag\">tag with attributes</span>. <script and " + + "</p are not tags.)\";" + } + }; + + //Window title using entities. + private static final String TITLE_HTML_ENTITIES = + "Testing entities <script>alert(\"Should not pop up\")</script>."; + private static final String[] ARGS_HTML_ENTITIES = new String[]{ + "-d", BUG_ID + "-4", "-windowtitle", TITLE_HTML_ENTITIES, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_HTML_ENTITIES = { + {BUG_ID + "-4" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing entities <script>alert(\\\"Should " + + "not pop up\\\")</script>.)\";" + } }; - private static final String[] ARGS = new String[]{ - "-d", BUG_ID, "-windowtitle", WIN_TITLE, "-sourcepath", SRC_DIR, "p1", "p2" + private static final String[][] NEG_TEST_HTML_ENTITIES = { + {BUG_ID + "-4" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing entities alert(\\\"Should not pop up\\\").)\";" + } + }; + + //Window title with just empty HTML tags. + private static final String TITLE_EMPTY_TAGS = + "</title><script></script>"; + private static final String[] ARGS_EMPTY_TAGS = new String[]{ + "-d", BUG_ID + "-5", "-windowtitle", TITLE_EMPTY_TAGS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_EMPTY_TAGS = { + {BUG_ID + "-5" + FS + "overview-summary.html", + "parent.document.title=\"Overview\";" + } + }; + private static final String[][] NEG_TEST_EMPTY_TAGS = { + {BUG_ID + "-5" + FS + "overview-summary.html", + "parent.document.title=\"Overview (</title><script></script>)\";" + } + }; + + //Window title with unicode characters. + private static final String TITLE_UNICODE_CHARS = + "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e."; + private static final String[] ARGS_UNICODE_CHARS = new String[]{ + "-d", BUG_ID + "-6", "-windowtitle", TITLE_UNICODE_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_UNICODE_CHARS = { + {BUG_ID + "-6" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing unicode alert(\\\"Should " + + "not pop up\\\").)\";" + } + }; + private static final String[][] NEG_TEST_UNICODE_CHARS = { + {BUG_ID + "-6" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing unicode <script>alert(\\\"Should not pop up\\\")" + + "</script>.)\";" + } + }; + + //An empty window title. + private static final String TITLE_EMPTY = + ""; + private static final String[] ARGS_EMPTY_TITLE = new String[]{ + "-d", BUG_ID + "-7", "-windowtitle", TITLE_EMPTY, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_EMPTY = { + {BUG_ID + "-7" + FS + "overview-summary.html", + "parent.document.title=\"Overview\";" + } + }; + + //Test doctitle. + private static final String[] ARGS_DOCTITLE = new String[]{ + "-d", BUG_ID + "-8", "-doctitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] NEG_TEST_DOCTITLE = { + {BUG_ID + "-8" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + + "also a tab and also a \\t special character another \\u0002 unicode)\";" + }, }; /** @@ -62,7 +189,14 @@ */ public static void main(String[] args) { TestWindowTitle tester = new TestWindowTitle(); - run(tester, ARGS, TEST, NEG_TEST); + run(tester, ARGS_JS_CHARS, TEST_JS_CHARS, NEG_TEST_JS_CHARS); + run(tester, ARGS_SCRIPT_TAG, TEST_SCRIPT_TAG, NEG_TEST_SCRIPT_TAG); + run(tester, ARGS_HTML_TAGS, TEST_HTML_TAGS, NEG_TEST_HTML_TAGS); + run(tester, ARGS_HTML_ENTITIES, TEST_HTML_ENTITIES, NEG_TEST_HTML_ENTITIES); + run(tester, ARGS_EMPTY_TAGS, TEST_EMPTY_TAGS, NEG_TEST_EMPTY_TAGS); + run(tester, ARGS_UNICODE_CHARS, TEST_UNICODE_CHARS, NEG_TEST_UNICODE_CHARS); + run(tester, ARGS_EMPTY_TITLE, TEST_EMPTY, NO_TEST); + run(tester, ARGS_DOCTITLE, NO_TEST, NEG_TEST_DOCTITLE); tester.printSummary(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034924 + * @summary Incorrect inheritance of inaccessible static method + * @library /tools/javac/lib + * @build ToolBox + * @run main IncorrectInheritanceTest + */ + +public class IncorrectInheritanceTest { + private static final String ASrc = + "package pkg;\n" + + "\n" + + "public class A {\n" + + " static void foo(Object o) {}\n" + + " private static void bar(Object o) {}\n" + + "}"; + + private static final String BSrc = + "import pkg.A;\n" + + "class B extends A {\n" + + " public void foo(Object o) {}\n" + + " public void bar(Object o) {}\n" + + "}"; + + private static final String CSrc = + "class C extends B {\n" + + " public void m(Object o) {\n" + + " foo(o);\n" + + " bar(o);\n" + + " }\n" + + "}"; + + public static void main(String[] args) throws Exception { + new IncorrectInheritanceTest().test(); + } + + public void test() throws Exception { + ToolBox.JavaToolArgs javacParams = + new ToolBox.JavaToolArgs() + .setSources(ASrc, BSrc, CSrc); + ToolBox.javac(javacParams); + } + +}
--- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Tue Apr 22 17:15:42 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -30,6 +30,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -51,6 +52,11 @@ new Driver().runDriver(clazz.newInstance()); } + String[][] extraParamsCombinations = new String[][] { + new String[] { }, + new String[] { "-g" }, + }; + protected void runDriver(Object object) throws Exception { int passed = 0, failed = 0; Class<?> clazz = object.getClass(); @@ -65,18 +71,20 @@ throw new IllegalArgumentException("Test method needs to return a string: " + method); String testClass = testClassOf(method); - try { - String compact = (String)method.invoke(object); - String fullFile = wrap(compact); - ClassFile cf = compileAndReturn(fullFile, testClass); - List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); - ReferenceInfoUtil.compare(expected, actual, cf); - out.println("PASSED: " + method.getName()); - ++passed; - } catch (Throwable e) { - out.println("FAILED: " + method.getName()); - out.println(" " + e.toString()); - ++failed; + for (String[] extraParams : extraParamsCombinations) { + try { + String compact = (String)method.invoke(object); + String fullFile = wrap(compact); + ClassFile cf = compileAndReturn(fullFile, testClass, extraParams); + List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); + ReferenceInfoUtil.compare(expected, actual, cf); + out.println("PASSED: " + method.getName()); + ++passed; + } catch (Throwable e) { + out.println("FAILED: " + method.getName()); + out.println(" " + e.toString()); + ++failed; + } } } @@ -156,7 +164,7 @@ } } - private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception { + private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception { File source = writeTestFile(fullFile); File clazzFile = compileTestFile(source, testClass); return ClassFile.read(clazzFile); @@ -170,8 +178,12 @@ return f; } - protected File compileTestFile(File f, String testClass) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() }); + protected File compileTestFile(File f, String testClass, String... extraParams) { + List<String> options = new ArrayList<>(); + options.addAll(Arrays.asList("-source", "1.8")); + options.addAll(Arrays.asList(extraParams)); + options.add(f.getPath()); + int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()])); if (rc != 0) throw new Error("compilation failed. rc=" + rc); String path;
--- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Tue Apr 22 17:15:42 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Tue Apr 22 19:50:43 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 @@ -25,6 +25,7 @@ /* * @test + * @bug 8028576 * @summary Test population of reference info for exception parameters * @author Werner Dietl * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** @test + * @bug 8034854 + * @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has + * inner_name_index zero (for synthetic classes) + * @compile SyntheticClasses.java + * @run main SyntheticClasses + */ + +import java.io.*; +import java.util.*; +import com.sun.tools.classfile.*; + +public class SyntheticClasses { + + public static void main(String[] args) throws IOException, ConstantPoolException { + new SyntheticClasses().run(); + } + + private void run() throws IOException, ConstantPoolException { + File testClasses = new File(System.getProperty("test.classes")); + for (File classFile : testClasses.listFiles()) { + ClassFile cf = ClassFile.read(classFile); + if (cf.getName().matches(".*\\$[0-9]+")) { + EnclosingMethod_attribute encl = + (EnclosingMethod_attribute) cf.getAttribute(Attribute.EnclosingMethod); + if (encl != null) { + if (encl.method_index != 0) + throw new IllegalStateException("Invalid EnclosingMethod.method_index: " + + encl.method_index + "."); + } + } + InnerClasses_attribute attr = + (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses); + if (attr != null) { + for (InnerClasses_attribute.Info info : attr.classes) { + if (cf.major_version < 51) + throw new IllegalStateException(); + if (info.inner_name_index == 0 && info.outer_class_info_index != 0) + throw new IllegalStateException("Invalid outer_class_info_index=" + + info.outer_class_info_index + + "; inner_name_index=" + + info.inner_name_index + "."); + } + } + } + } +} + +class SyntheticConstructorAccessTag { + + private static class A { + private A(){} + } + + public void test() { + new A(); + } +} + +class SyntheticEnumMapping { + private int convert(E e) { + switch (e) { + case A: return 0; + default: return -1; + } + } + enum E { A } +} + +interface SyntheticAssertionsDisabled { + public default void test() { + assert false; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8038080 + * @summary make sure that all declaration annotations are discovered + * by the processing environment + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery + * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java + */ + +import java.lang.annotation.*; +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.element.*; + +import com.sun.tools.javac.util.*; + +@ProcessingEnvAnnoDiscovery.Anno1 +public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T> + extends JavacTestingAbstractProcessor { + private int round = 0; + + public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) { + if (round++ == 0) { + System.out.println(annos); + Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4"))); + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5"))); + Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target + } + + return true; + } + + @Anno2 + public <@Anno5 K> K m(@Anno3 long foo) { + return null; + } + + @interface Anno1 {} + + @interface Anno2 {} + + @interface Anno3 {} + + @Target(ElementType.TYPE_PARAMETER) + @interface Anno4 {} + + @Target(ElementType.TYPE_PARAMETER) + @interface Anno5 {} + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/round/Anno.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.*; +import static java.lang.annotation.RetentionPolicy.*; + +@Retention(RUNTIME) +public @interface Anno {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/environment/round/ParameterAnnotations.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Class to hold annotations for ElementsAnnotatedWithTest. + */ + +@AnnotatedElementInfo(annotationName="Anno", + expectedSize=1, + names={"annotatedParameter"}) +public class ParameterAnnotations { + private void foo(@Anno Object annotatedParameter) {} +}
--- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Tue Apr 22 17:15:42 2014 +0100 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Tue Apr 22 19:50:43 2014 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080 * @summary Tests that getElementsAnnotatedWith works properly. * @author Joseph D. Darcy * @library /tools/javac/lib @@ -31,12 +31,14 @@ * @compile TestElementsAnnotatedWith.java * @compile InheritedAnnotation.java * @compile TpAnno.java + * @compile Anno.java * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java * @compile -processor TestElementsAnnotatedWith -proc:only C2.java * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java + * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java * @compile Foo.java * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
--- a/test/tools/javap/T4975569.java Tue Apr 22 17:15:42 2014 +0100 +++ b/test/tools/javap/T4975569.java Tue Apr 22 19:50:43 2014 +0100 @@ -40,10 +40,10 @@ verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"); verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"); verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC", - "InnerClasses:\n static"); + "InnerClasses:\n static"); verify("T4975569$V", "void m(java.lang.String...)", "flags: ACC_VARARGS"); - verify("T4975569$Prot", "InnerClasses:\n protected"); + verify("T4975569$Prot", "InnerClasses:\n protected"); //verify("T4975569$Priv", "InnerClasses"); if (errors > 0) throw new Error(errors + " found.");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javap/T8035104.java Tue Apr 22 19:50:43 2014 +0100 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035104 + * @summary reorder class file attributes in javap listing + */ + +import java.io.*; + +public class T8035104 { + public static void main(String[] args) throws Exception { + new T8035104().run(); + } + + public void run() throws Exception { + String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+"); + int minor = -1; + int SourceFile = -1; + for (int i = 0; i < lines.length; i++) { + String line = lines[i]; + if (line.matches(" *minor version: [0-9.]+")) + minor = i; + if (line.matches(" *SourceFile: .+")) + SourceFile = i; + } + if (minor == -1) + throw new Exception("minor version not found"); + if (SourceFile == -1) + throw new Exception("SourceFile not found"); + if (SourceFile < minor) + throw new Exception("unexpected order of output"); + + System.out.println("output OK"); + } + + String javap(String... args) { + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args, out); + out.close(); + System.out.println(sw.toString()); + System.out.println("javap exited, rc=" + rc); + return sw.toString(); + } +}