Mercurial > hg > openjdk > jdk9 > langtools
changeset 2550:980b18627fd3 jdk9-b24
Merge
author | lana |
---|---|
date | Fri, 18 Jul 2014 08:25:38 -0700 |
parents | 01837f3ed565 (current diff) b40c130a0a95 (diff) |
children | 47afa462f626 731e97ed8d2b |
files | test/tools/javac/unicode/NonasciiDigit2.java test/tools/javac/unicode/NonasciiDigit2.out test/tools/sjavac/ExclPatternWrapper.java test/tools/sjavac/JavacOptionPrepWrapper.java test/tools/sjavac/OptionDecodingWrapper.java test/tools/sjavac/SJavacTestUtil.java test/tools/sjavac/SJavacWrapper.java test/tools/sjavac/SerializationWrapper.java |
diffstat | 38 files changed, 670 insertions(+), 371 deletions(-) [+] |
line wrap: on
line diff
--- a/make/build.xml Thu Jul 17 09:50:45 2014 -0700 +++ b/make/build.xml Fri Jul 18 08:25:38 2014 -0700 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2007, 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 @@ -457,6 +457,46 @@ </javac> </target> + <!-- Generate API docs for "important" test classes that are used by + multiple tests. + --> + <target name="test-framework-docs" depends="build-all-classes"> + <javadoc executable="${target.java.home}/bin/javadoc" + destdir="${build.dir}/testframeworkdocs"> + <!-- disable doclint for now; it might be good to enable -Xdoclint:missing --> + <arg value="-Xdoclint:none"/> + <!-- source files to be documented --> + <sourcefiles> + <fileset dir="${test.dir}"> + <include name="**/ToolBox.java"/> + <include name="**/*Tester.java"/> + <include name="**/*TestBase.java"/> + <include name="**/*Testing*.java"/> + </fileset> + </sourcefiles> + <!-- source path used for documentation --> + <sourcepath> + <pathelement path="${test.dir}/lib"/> + <pathelement path="${test.dir}/lib/combo"/> + <pathelement path="${test.dir}/tools/javac/lib"/> + <pathelement path="${test.dir}/tools/javac/classfiles/attributes/LocalVariableTable"/> + </sourcepath> + <!-- exclude the following "packages" found by <javadoc> + on the sourcepath --> + <excludepackage name="combo.tools.javac.combo"/> + <excludepackage name="tools.javac.combo"/> + <!-- library classes used for documentation --> + <classpath> + <pathelement path="${jtreg.home}/lib/testng.jar"/> + </classpath> + <!-- platform classes used for documentation --> + <bootclasspath> + <pathelement path="${build.dir}/classes"/> + <pathelement path="${target.java.home}/jre/lib/rt.jar"/> + </bootclasspath> + </javadoc> + </target> + <!-- **** Debugging/diagnostic targets. --> @@ -761,7 +801,7 @@ <copy todir=".idea" > <fileset dir="make/intellij" includes="**"/> </copy> - <replace file=".idea/ant.xml" token="@@@" value="${jtreg.home}"/> + <replace file=".idea/ant.xml" token="@@@" value="${jtreg.home}"/> </target> <!--
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Jul 18 08:25:38 2014 -0700 @@ -1072,7 +1072,7 @@ boolean testFirst) { Env<GenContext> loopEnv = env.dup(loop, new GenContext()); int startpc = code.entryPoint(); - if (testFirst) { + if (testFirst) { //while or for loop CondItem c; if (cond != null) { code.statBegin(cond.pos); @@ -1118,6 +1118,9 @@ code.resolve(c.falseJumps); } code.resolve(loopEnv.info.exit); + if (loopEnv.info.exit != null) { + loopEnv.info.exit.state.defined.excludeFrom(code.nextreg); + } } private enum LoopLocalVarRangeEndingPoint {
--- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Fri Jul 18 08:25:38 2014 -0700 @@ -213,7 +213,7 @@ reader.putChar(true); } skipIllegalUnderscores(); - if ('0' <= reader.ch && reader.ch <= '9') { + if (reader.digit(pos, 10) >= 0) { scanDigits(pos, 10); if (!hexFloatsWork) lexError(pos, "unsupported.cross.fp.lit"); @@ -239,7 +239,7 @@ */ private void scanFraction(int pos) { skipIllegalUnderscores(); - if ('0' <= reader.ch && reader.ch <= '9') { + if (reader.digit(pos, 10) >= 0) { scanDigits(pos, 10); } int sp1 = reader.sp; @@ -250,7 +250,7 @@ reader.putChar(true); } skipIllegalUnderscores(); - if ('0' <= reader.ch && reader.ch <= '9') { + if (reader.digit(pos, 10) >= 0) { scanDigits(pos, 10); return; } @@ -384,11 +384,11 @@ reader.scanChar(); continue; } else { - high = reader.scanSurrogates(); - if (high != 0) { - reader.putChar(high); - isJavaIdentifierPart = Character.isJavaIdentifierPart( - Character.toCodePoint(high, reader.ch)); + int codePoint = reader.peekSurrogates(); + if (codePoint >= 0) { + if (isJavaIdentifierPart = Character.isJavaIdentifierPart(codePoint)) { + reader.putChar(true); + } } else { isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch); } @@ -530,7 +530,7 @@ break loop; case '.': reader.scanChar(); - if ('0' <= reader.ch && reader.ch <= '9') { + if (reader.digit(pos, 10) >= 0) { reader.putChar('.'); scanFractionAndSuffix(pos); } else if (reader.ch == '.') { @@ -613,11 +613,11 @@ reader.scanChar(); if (reader.ch == '\'') { lexError(pos, "empty.char.lit"); + reader.scanChar(); } else { if (reader.ch == CR || reader.ch == LF) lexError(pos, "illegal.line.end.in.char.lit"); scanLitChar(pos); - char ch2 = reader.ch; if (reader.ch == '\'') { reader.scanChar(); tk = TokenKind.CHARLITERAL; @@ -642,29 +642,39 @@ scanOperator(); } else { boolean isJavaIdentifierStart; + int codePoint = -1; if (reader.ch < '\u0080') { // all ASCII range chars already handled, above isJavaIdentifierStart = false; } else { - char high = reader.scanSurrogates(); - if (high != 0) { - reader.putChar(high); - - isJavaIdentifierStart = Character.isJavaIdentifierStart( - Character.toCodePoint(high, reader.ch)); + codePoint = reader.peekSurrogates(); + if (codePoint >= 0) { + if (isJavaIdentifierStart = Character.isJavaIdentifierStart(codePoint)) { + reader.putChar(true); + } } else { isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch); } } if (isJavaIdentifierStart) { scanIdent(); + } else if (reader.digit(pos, 10) >= 0) { + scanNumber(pos, 10); } else if (reader.bp == reader.buflen || reader.ch == EOI && reader.bp + 1 == reader.buflen) { // JLS 3.5 tk = TokenKind.EOF; pos = reader.buflen; } else { - String arg = (32 < reader.ch && reader.ch < 127) ? - String.format("%s", reader.ch) : - String.format("\\u%04x", (int)reader.ch); + String arg; + + if (codePoint >= 0) { + char high = reader.ch; + reader.scanChar(); + arg = String.format("\\u%04x\\u%04x", (int) high, (int)reader.ch); + } else { + arg = (32 < reader.ch && reader.ch < 127) ? + String.format("%s", reader.ch) : + String.format("\\u%04x", (int)reader.ch); + } lexError(pos, "illegal.char", arg); reader.scanChar(); }
--- a/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Fri Jul 18 08:25:38 2014 -0700 @@ -197,24 +197,28 @@ } /** Scan surrogate pairs. If 'ch' is a high surrogate and - * the next character is a low surrogate, then put the low - * surrogate in 'ch', and return the high surrogate. - * otherwise, just return 0. + * the next character is a low surrogate, returns the code point + * constructed from these surrogates. Otherwise, returns -1. + * This method will not consume any of the characters. */ - protected char scanSurrogates() { + protected int peekSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; + int prevBP = bp; scanChar(); - if (Character.isLowSurrogate(ch)) { - return high; - } + char low = ch; ch = high; + bp = prevBP; + + if (Character.isLowSurrogate(low)) { + return Character.toCodePoint(high, low); + } } - return 0; + return -1; } /** Convert an ASCII digit from its base (8, 10, or 16) @@ -222,9 +226,14 @@ */ protected int digit(int pos, int base) { char c = ch; - int result = Character.digit(c, base); + if ('0' <= c && c <= '9') + return Character.digit(c, base); //a fast common case + int codePoint = peekSurrogates(); + int result = codePoint >= 0 ? Character.digit(codePoint, base) : Character.digit(c, base); if (result >= 0 && c > 0x7f) { log.error(pos + 1, "illegal.nonascii.digit"); + if (codePoint >= 0) + scanChar(); ch = "0123456789abcdef".charAt(result); } return result;
--- a/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,3 +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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + package com.sun.tools.sjavac.comp; import java.io.File;
--- a/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,3 +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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + package com.sun.tools.sjavac.server; import java.net.URI;
--- a/src/share/classes/com/sun/tools/sjavac/server/JavacService.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/sjavac/server/JavacService.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,3 +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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + package com.sun.tools.sjavac.server; import java.io.File;
--- a/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java Thu Jul 17 09:50:45 2014 -0700 +++ b/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,3 +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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + package com.sun.tools.sjavac.server; import java.io.BufferedReader;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8050386/WrongStackframeGenerationTest1.java Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,47 @@ +/* + * 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 8050386 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest1 { + public static void main(String[] args) {} + + static void foo(){ + while (true) { + int i = 0; + break; + } + switch (1) { + case 1: + int j = 0; + case 2: + bar(); + } + } + + static void bar() {} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8050386/WrongStackframeGenerationTest2.java Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,50 @@ +/* + * 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 8050386 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest2 { + public static void main(String[] args) {} + + static void foo() { + int len; + for (;;) { + try { + len = 1; + break; + } catch (Exception e) { + } + } + + try { + if (len == -1) { + len = 0; + } + } finally { + } + } +}
--- a/test/tools/javac/diags/examples/EmptyCharLiteral.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/diags/examples/EmptyCharLiteral.java Fri Jul 18 08:25:38 2014 -0700 @@ -22,7 +22,6 @@ */ // key: compiler.err.empty.char.lit -// key: compiler.err.unclosed.char.lit class X { char c = '';
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/expression/_super/NonDirectSuper/Base.java Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,45 @@ +/* + * 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 + * 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. + */ + +package base; + +public class Base extends PackagePrivate { } + +class PackagePrivate { + protected int refTobaseBase() { + return 0; + } + protected int refTotestOtherPackageTest() { + return 0; + } + protected int refTotestTarget11() { + return 0; + } + protected int refTotestCurPackagePrivateExt11() { + return 0; + } + protected int refTobaseBase; + protected int refTotestOtherPackageTest; + protected int refTotestTarget11; + protected int refTotestCurPackagePrivateExt11; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/expression/_super/NonDirectSuper/NonDirectSuper.java Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,178 @@ +/* + * 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 + * 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 8027789 + * @summary check that the direct superclass is used as the site when calling + * a superclass' method + * @compile Base.java NonDirectSuper.java + * @run main test.NonDirectSuper + */ + +package test; + +import java.io.File; + +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.ConstantPool.CPRefInfo; +import com.sun.tools.classfile.Instruction; +import com.sun.tools.classfile.Method; +import com.sun.tools.classfile.Opcode; + +public class NonDirectSuper { + public static void main(String... args) { + new NonDirectSuper().run(); + } + + void run() { + String workDir = System.getProperty("test.classes"); + File testPackage = new File(workDir, "test"); + + for (File clazz : testPackage.listFiles()) { + if ("NonDirectSuper.class".equals(clazz.getName())) continue; + verifyInvokeSpecialRefToObject(clazz); + } + } + + void verifyInvokeSpecialRefToObject(File clazz) { + try { + final ClassFile cf = ClassFile.read(clazz); + for (Method m : cf.methods) { + Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code); + for (Instruction instr : codeAttr.getInstructions()) { + if (instr.getOpcode() == Opcode.INVOKESPECIAL || + instr.getOpcode() == Opcode.INVOKEVIRTUAL) { + int pc_index = instr.getShort(1); + CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index); + String className = ref.getClassName(); + String methodName = ref.getNameAndTypeInfo().getName(); + if (methodName.equals("toString")) { + if (!className.equals("java/lang/Object")) + throw new IllegalStateException("Must directly refer to j.l.Object"); + } else if (methodName.startsWith("refTo")) { + String expectedClass = methodName.substring("refTo".length()); + if (!className.replace("/", "").equals(expectedClass)) { + throw new IllegalStateException("Unexpected reference to: " + + className + ", should be " + expectedClass); + } + } + } + if (instr.getOpcode() == Opcode.GETFIELD || + instr.getOpcode() == Opcode.PUTFIELD) { + int pc_index = instr.getShort(1); + CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index); + String className = ref.getClassName(); + String fieldName = ref.getNameAndTypeInfo().getName(); + if (fieldName.startsWith("refTo")) { + String expectedClass = fieldName.substring("refTo".length()); + if (!className.replace("/", "").equals(expectedClass)) { + throw new IllegalStateException("Unexpected reference to: " + + className + ", should be " + expectedClass); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + throw new Error("error reading " + clazz +": " + e); + } + } +} + +class OtherPackageTest extends base.Base { + void run() { + new Runnable() { + public void run() { + OtherPackageTest.super.refTobaseBase(); + OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1; + OtherPackageTest.super.toString(); + refTotestOtherPackageTest(); + refTotestOtherPackageTest = refTotestOtherPackageTest + 1; + OtherPackageTest.this.refTotestOtherPackageTest(); + OtherPackageTest.this.refTotestOtherPackageTest = + OtherPackageTest.this.refTotestOtherPackageTest + 1; + } + }.run(); + super.refTobaseBase(); + super.refTobaseBase = super.refTobaseBase + 1; + super.toString(); + OtherPackageTest.super.refTobaseBase(); + OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1; + OtherPackageTest.super.toString(); + refTotestOtherPackageTest(); + refTotestOtherPackageTest = refTotestOtherPackageTest + 1; + } + + static class InnerBase { + private void refTotestOtherPackageTest$InnerBase() { } + } + static class InnerTest extends InnerBase { + void run() { + new Runnable() { + public void run() { + InnerTest.super.refTotestOtherPackageTest$InnerBase(); + } + }.run(); + super.refTotestOtherPackageTest$InnerBase(); + InnerTest.super.refTotestOtherPackageTest$InnerBase(); + } + } +} + +class CurPackagePrivateBase { + void refTotestCurPackagePrivateExt() { } + void refTotestCurPackagePrivateTest() { } + int refTotestCurPackagePrivateExt; + int refTotestCurPackagePrivateTest; +} + +class CurPackagePrivateExt extends CurPackagePrivateBase { +} + +class CurPackagePrivateTest extends CurPackagePrivateExt { + void run() { + new Runnable() { + public void run() { + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt(); + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt = + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1; + CurPackagePrivateTest.this.refTotestCurPackagePrivateTest(); + CurPackagePrivateTest.this.refTotestCurPackagePrivateTest = + CurPackagePrivateTest.this.refTotestCurPackagePrivateTest + 1; + refTotestCurPackagePrivateTest(); + refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1; + } + }.run(); + super.refTotestCurPackagePrivateExt(); + super.refTotestCurPackagePrivateExt = super.refTotestCurPackagePrivateExt + 1; + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt(); + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt = + CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1; + refTotestCurPackagePrivateTest(); + refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1; + } +}
--- a/test/tools/javac/unicode/NonasciiDigit.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/NonasciiDigit.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 4707960 6183529 + * @bug 4707960 6183529 8046620 * @summary javac accepts unicode digits - sometimes crashing * @author gafter * @@ -8,7 +8,16 @@ */ public class NonasciiDigit { public static void main(String[] args) { + // error: only ASCII allowed in constants + int i1 = \uff11; + int i2 = 1\uff11; + int i3 = \ud835\udfff; // error: floating literals use ascii only - float f = 0.\uff11; + double d1 = \uff11.0; + double d2 = 0.\uff11; + double d3 = 0x0P\uff11; + double d4 = 0E\uff11; + double d5 = .\uff11; + double d6 = \ud835\udfff.0; } }
--- a/test/tools/javac/unicode/NonasciiDigit.out Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/NonasciiDigit.out Fri Jul 18 08:25:38 2014 -0700 @@ -1,2 +1,10 @@ -NonasciiDigit.java:12:26: compiler.err.illegal.char: \uff11 -1 error +NonasciiDigit.java:12:24: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:13:19: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:14:24: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:16:27: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:17:22: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:18:22: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:19:22: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:20:22: compiler.err.illegal.nonascii.digit +NonasciiDigit.java:21:27: compiler.err.illegal.nonascii.digit +9 errors
--- a/test/tools/javac/unicode/NonasciiDigit2.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 4707960 6183529 - * @summary javac accepts unicode digits - sometimes crashing - * @author gafter - * - * @compile/fail/ref=NonasciiDigit2.out -XDrawDiagnostics NonasciiDigit2.java - */ -public class NonasciiDigit2 { - public static void main(String[] args) { - // error: only ASCII allowed in constants - int i = 1\uff11; - } -}
--- a/test/tools/javac/unicode/NonasciiDigit2.out Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -NonasciiDigit2.java:12:18: compiler.err.illegal.nonascii.digit -1 error
--- a/test/tools/javac/unicode/SupplementaryJavaID2.out Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/SupplementaryJavaID2.out Fri Jul 18 08:25:38 2014 -0700 @@ -1,3 +1,4 @@ SupplementaryJavaID2.java:12:14: compiler.err.illegal.char: \ud801 +SupplementaryJavaID2.java:12:20: compiler.err.illegal.char: \ud801 SupplementaryJavaID2.java:12:24: compiler.err.expected: token.identifier -2 errors +3 errors
--- a/test/tools/javac/unicode/SupplementaryJavaID3.out Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/SupplementaryJavaID3.out Fri Jul 18 08:25:38 2014 -0700 @@ -1,2 +1,3 @@ +SupplementaryJavaID3.java:12:17: compiler.err.illegal.char: \ud801 SupplementaryJavaID3.java:12:23: compiler.err.illegal.char: \ud801 -1 error +2 errors
--- a/test/tools/javac/unicode/SupplementaryJavaID4.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/SupplementaryJavaID4.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,35 +1,12 @@ /* - * Copyright (c) 2003, 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 4914724 + * @test /nodynamiccopyright/ + * @bug 4914724 8048803 * @summary Ensure that a supplementary character that cannot be the start of a Java * identifier causes a compilation failure, if it is used as the start of an * identifier * @author Naoto Sato * - * @compile/fail SupplementaryJavaID4.java + * @compile/fail/ref=SupplementaryJavaID4.out -XDrawDiagnostics SupplementaryJavaID4.java */ public class SupplementaryJavaID4 {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/unicode/SupplementaryJavaID4.out Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,2 @@ +SupplementaryJavaID4.java:14:14: compiler.err.illegal.char: \ud834\udd7b +1 error
--- a/test/tools/javac/unicode/SupplementaryJavaID5.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/SupplementaryJavaID5.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,35 +1,12 @@ /* - * Copyright (c) 2003, 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 4914724 + * @test /nodynamiccopyright/ + * @bug 4914724 8048803 * @summary Ensure that a supplementary character that cannot be the part of a Java * identifier causes a compilation failure, if it is used as the part of an * identifier * @author Naoto Sato * - * @compile/fail SupplementaryJavaID5.java + * @compile/fail/ref=SupplementaryJavaID5.out -XDrawDiagnostics SupplementaryJavaID5.java */ public class SupplementaryJavaID5 {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/unicode/SupplementaryJavaID5.out Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,2 @@ +SupplementaryJavaID5.java:14:17: compiler.err.illegal.char: \ud834\udd00 +1 error
--- a/test/tools/javac/unicode/TripleQuote.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/TripleQuote.java Fri Jul 18 08:25:38 2014 -0700 @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 1265387 + * @bug 1265387 8048805 * @summary ''' and '\u0027' are not legal char literals. * @author turnidge *
--- a/test/tools/javac/unicode/TripleQuote.out Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/javac/unicode/TripleQuote.out Fri Jul 18 08:25:38 2014 -0700 @@ -1,7 +1,5 @@ TripleQuote.java:12:14: compiler.err.empty.char.lit -TripleQuote.java:12:20: compiler.err.empty.char.lit TripleQuote.java:12:21: compiler.err.unclosed.char.lit TripleQuote.java:13:14: compiler.err.empty.char.lit -TripleQuote.java:13:15: compiler.err.empty.char.lit TripleQuote.java:13:16: compiler.err.unclosed.char.lit -6 errors +4 errors
--- a/test/tools/sjavac/ExclPattern.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/ExclPattern.java Fri Jul 18 08:25:38 2014 -0700 @@ -23,6 +23,16 @@ * questions. */ + +/* + * @test + * @bug 8037085 + * @summary Ensures that sjavac can handle various exclusion patterns. + * + * @build Wrapper + * @run main Wrapper ExclPattern + */ + import java.io.IOException; import java.io.PrintWriter; import java.nio.charset.Charset;
--- a/test/tools/sjavac/ExclPatternWrapper.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * 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 8037085 - * @summary Ensures that sjavac can handle various exclusion patterns. - * @run main ExclPatternWrapper - */ -public class ExclPatternWrapper { - public static void main(String... args) throws Exception { - SJavacTestUtil.runSjavacTest("ExclPattern", args); - } -}
--- a/test/tools/sjavac/IgnoreSymbolFile.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/IgnoreSymbolFile.java Fri Jul 18 08:25:38 2014 -0700 @@ -27,6 +27,9 @@ * @test * @bug 8047183 * @summary JDK build fails with sjavac enabled + * + * @build Wrapper + * @run main Wrapper IgnoreSymbolFile */ import java.io.File; @@ -38,12 +41,8 @@ public class IgnoreSymbolFile { public static void main(String... args) throws Exception { - if (sjavacAvailable()) { - IgnoreSymbolFile test = new IgnoreSymbolFile(); - test.run(); - } else { - System.err.println("sjavac not available; test skipped"); - } + IgnoreSymbolFile test = new IgnoreSymbolFile(); + test.run(); } void run() throws Exception { @@ -96,13 +95,4 @@ } int errors; - - static boolean sjavacAvailable() { - try { - Class.forName("com.sun.tools.sjavac.Main"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } }
--- a/test/tools/sjavac/JavacOptionPrep.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/JavacOptionPrep.java Fri Jul 18 08:25:38 2014 -0700 @@ -23,6 +23,15 @@ * questions. */ +/* + * @test + * @bug 8035063 + * @summary Tests the preparation of javac-arguments. + * + * @build Wrapper + * @run main Wrapper JavacOptionPrep + */ + import java.io.File; import java.io.IOException; import java.nio.file.Files;
--- a/test/tools/sjavac/JavacOptionPrepWrapper.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * 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 8035063 - * @summary Tests the preparation of javac-arguments. - * @run main JavacOptionPrepWrapper - */ -public class JavacOptionPrepWrapper { - public static void main(String... args) throws Exception { - SJavacTestUtil.runSjavacTest("JavacOptionPrep", args); - } -}
--- a/test/tools/sjavac/OptionDecoding.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/OptionDecoding.java Fri Jul 18 08:25:38 2014 -0700 @@ -23,6 +23,15 @@ * questions. */ +/* + * @test + * @bug 8035063 + * @summary Tests decoding of String[] into Options. + * + * @build Wrapper + * @run main Wrapper OptionDecoding + */ + import static util.OptionTestUtil.assertEquals; import static util.OptionTestUtil.checkFilesFound;
--- a/test/tools/sjavac/OptionDecodingWrapper.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * 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 8035063 - * @summary Tests decoding of String[] into Options. - * @run main OptionDecodingWrapper - */ -public class OptionDecodingWrapper { - public static void main(String... args) throws Exception { - SJavacTestUtil.runSjavacTest("OptionDecoding", args); - } -}
--- a/test/tools/sjavac/SJavac.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/SJavac.java Fri Jul 18 08:25:38 2014 -0700 @@ -21,6 +21,16 @@ * questions. */ + +/* + * @test + * @summary Test all aspects of sjavac. + * @bug 8004658 8042441 8042699 + * + * @build Wrapper + * @run main Wrapper SJavac + */ + import java.util.*; import java.io.*; import java.nio.file.*; @@ -29,8 +39,7 @@ import com.sun.tools.sjavac.Main; -public -class SJavac { +public class SJavac { public static void main(String... args) throws Exception { try {
--- a/test/tools/sjavac/SJavacTestUtil.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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.io.File; -import java.lang.reflect.Method; - - -public class SJavacTestUtil { - - public static void runSjavacTest(String testClassName, String[] args) - throws Exception { - - if (!isSJavacOnClassPath()) { - System.out.println("sjavac not available: pass by default"); - return; - } - - File srcDir = new File(System.getProperty("test.src")); - File clsDir = new File(System.getProperty("test.classes")); - - File src = new File(srcDir, testClassName + ".java"); - File cls = new File(clsDir, testClassName + ".class"); - - if (cls.lastModified() < src.lastModified()) { - System.err.println("Recompiling test class..."); - String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() }; - int rc = com.sun.tools.javac.Main.compile(javacArgs); - if (rc != 0) - throw new Exception("compilation failed"); - } - - Class<?> sjavac = Class.forName(testClassName); - Method main = sjavac.getMethod("main", String[].class); - main.invoke(null, new Object[] { args }); - - } - - private static boolean isSJavacOnClassPath() { - String cls = "com/sun/tools/sjavac/Main.class"; - return SJavacTestUtil.class.getClassLoader().getResource(cls) != null; - } -}
--- a/test/tools/sjavac/SJavacWrapper.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * 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 - * 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 - * @summary Test all aspects of sjavac. - * - * @bug 8004658 - * @bug 8042441 - * @bug 8042699 - * @summary Add internal smart javac wrapper to solve JEP 139 - * - * @run main SJavacWrapper - */ - -public class SJavacWrapper { - public static void main(String... args) throws Exception { - SJavacTestUtil.runSjavacTest("SJavac", args); - } -}
--- a/test/tools/sjavac/Serialization.java Thu Jul 17 09:50:45 2014 -0700 +++ b/test/tools/sjavac/Serialization.java Fri Jul 18 08:25:38 2014 -0700 @@ -21,6 +21,18 @@ * questions. */ +/* + * @test + * @bug 8035063 + * + * @summary Tests serialization of options. The options needs to be serialized + * and saved in the state file since the files need to be recompiled + * if new options are provided. + * + * @build Wrapper + * @run main Wrapper Serialization + */ + import static util.OptionTestUtil.assertEquals; import java.io.IOException;
--- a/test/tools/sjavac/SerializationWrapper.java Thu Jul 17 09:50:45 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * 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 8035063 - * - * @summary Tests serialization of options. The options needs to be serialized - * and saved in the state file since the files need to be recompiled - * if new options are provided. - * - * @run main SerializationWrapper - */ -public class SerializationWrapper { - public static void main(String... args) throws Exception { - SJavacTestUtil.runSjavacTest("Serialization", args); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/sjavac/Wrapper.java Fri Jul 18 08:25:38 2014 -0700 @@ -0,0 +1,64 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.io.File; +import java.lang.reflect.Method; +import java.util.Arrays; + + +public class Wrapper { + public static void main(String... args) throws Exception { + if (!isSJavacOnClassPath()) { + System.out.println("sjavac not available: pass by default"); + return; + } + + String testClassName = args[0]; + String[] testArgs = Arrays.copyOfRange(args, 1, args.length); + + File srcDir = new File(System.getProperty("test.src")); + File clsDir = new File(System.getProperty("test.classes")); + + File src = new File(srcDir, testClassName + ".java"); + File cls = new File(clsDir, testClassName + ".class"); + + if (cls.lastModified() < src.lastModified()) { + System.err.println("Recompiling test class..."); + String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() }; + int rc = com.sun.tools.javac.Main.compile(javacArgs); + if (rc != 0) + throw new Exception("compilation failed"); + } + + Class<?> sjavac = Class.forName(testClassName); + Method main = sjavac.getMethod("main", String[].class); + main.invoke(null, new Object[] { testArgs }); + } + + private static boolean isSJavacOnClassPath() { + String cls = "com/sun/tools/sjavac/Main.class"; + return Wrapper.class.getClassLoader().getResource(cls) != null; + } +}