Merge
This commit is contained in:
commit
49902de279
langtools
make
src/share/classes/com/sun/tools
javac
sjavac
test/tools
javac
T8050386
diags/examples
expression/_super/NonDirectSuper
unicode
sjavac
@ -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>
|
||||
|
||||
<!--
|
||||
|
@ -1072,7 +1072,7 @@ public class Gen extends JCTree.Visitor {
|
||||
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 @@ public class Gen extends JCTree.Visitor {
|
||||
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 {
|
||||
|
@ -213,7 +213,7 @@ public class JavaTokenizer {
|
||||
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 @@ public class JavaTokenizer {
|
||||
*/
|
||||
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 @@ public class JavaTokenizer {
|
||||
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 @@ public class JavaTokenizer {
|
||||
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 @@ public class JavaTokenizer {
|
||||
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 @@ public class JavaTokenizer {
|
||||
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 @@ public class JavaTokenizer {
|
||||
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();
|
||||
}
|
||||
|
@ -197,24 +197,28 @@ public class UnicodeReader {
|
||||
}
|
||||
|
||||
/** 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 @@ public class UnicodeReader {
|
||||
*/
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -23,12 +23,25 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8035063
|
||||
* @summary Tests decoding of String[] into Options.
|
||||
* @run main OptionDecodingWrapper
|
||||
* @bug 8050386
|
||||
* @summary Verification error due to a bad stackmap frame generated by javac
|
||||
*/
|
||||
public class OptionDecodingWrapper {
|
||||
public static void main(String... args) throws Exception {
|
||||
SJavacTestUtil.runSjavacTest("OptionDecoding", args);
|
||||
|
||||
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() {}
|
||||
}
|
@ -23,16 +23,28 @@
|
||||
|
||||
/*
|
||||
* @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
|
||||
* @bug 8050386
|
||||
* @summary Verification error due to a bad stackmap frame generated by javac
|
||||
*/
|
||||
public class SerializationWrapper {
|
||||
public static void main(String... args) throws Exception {
|
||||
SJavacTestUtil.runSjavacTest("Serialization", args);
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.empty.char.lit
|
||||
// key: compiler.err.unclosed.char.lit
|
||||
|
||||
class X {
|
||||
char c = '';
|
||||
|
@ -21,20 +21,25 @@
|
||||
* 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
|
||||
*/
|
||||
package base;
|
||||
|
||||
public class SJavacWrapper {
|
||||
public static void main(String... args) throws Exception {
|
||||
SJavacTestUtil.runSjavacTest("SJavac", args);
|
||||
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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
NonasciiDigit2.java:12:18: compiler.err.illegal.nonascii.digit
|
||||
1 error
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -0,0 +1,2 @@
|
||||
SupplementaryJavaID4.java:14:14: compiler.err.illegal.char: \ud834\udd7b
|
||||
1 error
|
@ -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 {
|
||||
|
@ -0,0 +1,2 @@
|
||||
SupplementaryJavaID5.java:14:17: compiler.err.illegal.char: \ud834\udd00
|
||||
1 error
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 1265387
|
||||
* @bug 1265387 8048805
|
||||
* @summary ''' and '\u0027' are not legal char literals.
|
||||
* @author turnidge
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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 @@ import java.util.Arrays;
|
||||
|
||||
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 @@ public class IgnoreSymbolFile {
|
||||
}
|
||||
|
||||
int errors;
|
||||
|
||||
static boolean sjavacAvailable() {
|
||||
try {
|
||||
Class.forName("com.sun.tools.sjavac.Main");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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 java.nio.charset.*;
|
||||
|
||||
import com.sun.tools.sjavac.Main;
|
||||
|
||||
public
|
||||
class SJavac {
|
||||
public class SJavac {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
try {
|
||||
|
@ -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;
|
||||
|
@ -25,18 +25,19 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class SJavacTestUtil {
|
||||
|
||||
public static void runSjavacTest(String testClassName, String[] args)
|
||||
throws Exception {
|
||||
|
||||
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"));
|
||||
|
||||
@ -53,12 +54,11 @@ public class SJavacTestUtil {
|
||||
|
||||
Class<?> sjavac = Class.forName(testClassName);
|
||||
Method main = sjavac.getMethod("main", String[].class);
|
||||
main.invoke(null, new Object[] { args });
|
||||
|
||||
main.invoke(null, new Object[] { testArgs });
|
||||
}
|
||||
|
||||
private static boolean isSJavacOnClassPath() {
|
||||
String cls = "com/sun/tools/sjavac/Main.class";
|
||||
return SJavacTestUtil.class.getClassLoader().getResource(cls) != null;
|
||||
return Wrapper.class.getClassLoader().getResource(cls) != null;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user