meth, quid: hardwire negative tests as jtreg tests
authorjrose
Mon May 25 02:50:37 2009 -0700 (6 months ago)
changeset 263088e381b696
parent 256276f97c3873
child 274061ae313a0f
meth, quid: hardwire negative tests as jtreg tests
meth.patch
--- a/meth.patch Mon May 25 02:50:03 2009 -0700
+++ b/meth.patch Mon May 25 02:50:37 2009 -0700
@@ -1,2 +1,609 @@ changes entrained after 6829189 appear i
changes entrained after 6829189 appear in meth.patch proper
+diff --git a/test/tools/javac/meth/InvokeMH_BAD68.java b/test/tools/javac/meth/InvokeMH_BAD68.java
+new file mode 100644
+--- /dev/null
++++ b/test/tools/javac/meth/InvokeMH_BAD68.java
+@@ -0,0 +1,75 @@
++/*
++ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6754038
++ * @summary Generate call sites for method handle
++ * @author jrose
++ *
++ * @compile/fail -source 7 -target 7 InvokeMH_BAD68.java
++ */
++
++/*
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD68.java
++ * $ javap -c -classpath dist meth.InvokeMH_BAD68
++ * </code>
++ */
++
++package meth;
++
++import java.dyn.MethodHandle;
++
++public class InvokeMH_BAD68 {
++ void test(MethodHandle mh_SiO,
++ MethodHandle mh_vS,
++ MethodHandle mh_vi,
++ MethodHandle mh_vv) {
++ Object o; String s; int i; // for return type testing
++
++ // next five must have sig = (String,int)Object
++ mh_SiO.invoke("world", 123);
++ mh_SiO.invoke("mundus", 456);
++ Object k = "kosmos";
++ mh_SiO.invoke((String)k, 789);
++ o = mh_SiO.invoke((String)null, 000);
++ o = mh_SiO.<Object>invoke("arda", -123);
++
++ // sig = ()String
++ s = mh_vS.<String>invoke();
++
++ // sig = ()int
++ i = mh_vi.<int>invoke();
++ o = mh_vi.<int>invoke();
++ s = mh_vi.<int>invoke(); //BAD
++ mh_vi.<int>invoke();
++
++ // sig = ()void
++ //o = mh_vv.<void>invoke(); //BAD
++ mh_vv.<void>invoke();
++ }
++}
+diff --git a/test/tools/javac/meth/InvokeMH_BAD72.java b/test/tools/javac/meth/InvokeMH_BAD72.java
+new file mode 100644
+--- /dev/null
++++ b/test/tools/javac/meth/InvokeMH_BAD72.java
+@@ -0,0 +1,75 @@
++/*
++ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6754038
++ * @summary Generate call sites for method handle
++ * @author jrose
++ *
++ * @compile/fail -source 7 -target 7 InvokeMH_BAD72.java
++ */
++
++/*
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD72.java
++ * $ javap -c -classpath dist meth.InvokeMH_BAD72
++ * </code>
++ */
++
++package meth;
++
++import java.dyn.MethodHandle;
++
++public class InvokeMH_BAD72 {
++ void test(MethodHandle mh_SiO,
++ MethodHandle mh_vS,
++ MethodHandle mh_vi,
++ MethodHandle mh_vv) {
++ Object o; String s; int i; // for return type testing
++
++ // next five must have sig = (String,int)Object
++ mh_SiO.invoke("world", 123);
++ mh_SiO.invoke("mundus", 456);
++ Object k = "kosmos";
++ mh_SiO.invoke((String)k, 789);
++ o = mh_SiO.invoke((String)null, 000);
++ o = mh_SiO.<Object>invoke("arda", -123);
++
++ // sig = ()String
++ s = mh_vS.<String>invoke();
++
++ // sig = ()int
++ i = mh_vi.<int>invoke();
++ o = mh_vi.<int>invoke();
++ //s = mh_vi.<int>invoke(); //BAD
++ mh_vi.<int>invoke();
++
++ // sig = ()void
++ o = mh_vv.<void>invoke(); //BAD
++ mh_vv.<void>invoke();
++ }
++}
+diff --git a/test/tools/javac/meth/MakeNegTests.sh b/test/tools/javac/meth/MakeNegTests.sh
+--- a/test/tools/javac/meth/MakeNegTests.sh
++++ b/test/tools/javac/meth/MakeNegTests.sh
+@@ -23,10 +23,10 @@
+ # have any questions.
+ #
+
+-# @test
+-# @bug 6754038
+-# @summary Verify correct rejection of strongly typed return values
+-# @run shell MakeNegTests.sh
++# @#test
++# @#bug 6754038
++# @#summary Verify correct rejection of strongly typed return values
++# @#run shell MakeNegTests.sh
+
+ default_template=InvokeMH.java
+ javacflags='-source 7 -target 7'
+diff --git a/test/tools/javac/quid/MakeNegTests.sh b/test/tools/javac/quid/MakeNegTests.sh
+--- a/test/tools/javac/quid/MakeNegTests.sh
++++ b/test/tools/javac/quid/MakeNegTests.sh
+@@ -23,10 +23,10 @@
+ # have any questions.
+ #
+
+-# @test
+-# @bug 6746458
+-# @summary Verify correct rejection of illegal quoted identifiers.
+-# @run shell MakeNegTests.sh
++# @#test
++# @#bug 6746458
++# @#summary Verify correct rejection of illegal quoted identifiers.
++# @#run shell MakeNegTests.sh
+
+ default_template=QuotedIdent.java
+ # the rest of this file is a generic "//BAD"-line tester
+diff --git a/test/tools/javac/quid/QuotedIdent_BAD61.java b/test/tools/javac/quid/QuotedIdent_BAD61.java
+new file mode 100644
+--- /dev/null
++++ b/test/tools/javac/quid/QuotedIdent_BAD61.java
+@@ -0,0 +1,132 @@
++/*
++ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6746458
++ * @summary Verify correct lexing of quoted identifiers.
++ * @author jrose
++ *
++ * @library ..
++ * @run main quid.QuotedIdent_BAD61
++ */
++
++/*
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD61.java
++ * $ java -version # should print 1.6 or later
++ * $ java -cp dist quid.QuotedIdent_BAD61
++ * </code>
++ */
++
++package quid;
++
++public class QuotedIdent_BAD61 {
++ static void check(int testid, String have, String expect)
++ throws RuntimeException {
++ if ((have == null && have != expect) ||
++ (have != null && !have.equals(expect))) {
++ String msg =
++ "TEST " + testid + ": HAVE \"" +
++ have + "\" EXPECT \"" + expect + "\"";
++ System.out.println("StringConversion: " + msg);
++ throw new RuntimeException(msg);
++ }
++ }
++
++ // negative tests:
++ static class #"" { } //BAD empty ident name
++ //static class #"<foo>" { } //BAD bad char in ident name
++ /*static class /*(//BAD ident name interrupted by newline) #"jump:
++ " { } /* uncomment previous line to attempt class w/ bad name */
++
++ static class #"int" extends Number {
++ final int #"int";
++ #"int"(int #"int") {
++ this.#"int" = #"int";
++ }
++ static #"int" valueOf(int #"int") {
++ return new #"int"(#"int");
++ }
++ public int intValue() { return #"int"; }
++ public long longValue() { return #"int"; }
++ public float floatValue() { return #"int"; }
++ public double doubleValue() { return #"int"; }
++ public String toString() { return String.valueOf(#"int"); }
++ }
++
++ class #"*86" {
++ String #"555-1212"() { return "[*86.555-1212]"; }
++ }
++ static#"*86"#"MAKE-*86"() { // note close spacing
++ return new QuotedIdent_BAD61().new#"*86"();
++ }
++
++ static String bar() { return "[bar]"; }
++
++ public static void main(String[] args) throws Exception {
++ String s;
++
++ String #"sticky \' wicket" = "wicked ' stick";
++ s = #"sticky ' wicket";
++ check(11, s, "wicked \' stick");
++ check(12, #"s", s);
++ check(13, #"\163", s);
++
++ s = #"QuotedIdent_BAD61".bar();
++ check(21, s, "[bar]");
++
++ s = #"int".valueOf(123).toString();
++ check(22, s, "123");
++
++ s = #"MAKE-*86"().#"555-1212"();
++ check(23, s, "[*86.555-1212]");
++
++ class#"{{{inmost}}}" { }
++ s = new#"{{{inmost}}}"().getClass().getName();
++ if (!s.endsWith("{{{inmost}}}"))
++ check(24, s, "should end with \"{{{inmost}}}\"");
++
++ s = #"Yog-Shoggoth".#"(nameless ululation)";
++ check(25, s, "Tekeli-li!");
++
++ s = #"int".class.getName();
++ check(31, s, QuotedIdent_BAD61.class.getName()+"$int");
++
++ Class x86 = Class.forName(QuotedIdent_BAD61.class.getName()+"$*86");
++ if (x86 != #"*86".class)
++ check(32, "reflected "+x86, "static "+#"*86".class);
++
++ s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
++ check(31, s, "[*86.555-1212]");
++
++ System.out.println("OK");
++ }
++}
++
++interface #"Yog-Shoggoth" {
++ final String #"(nameless ululation)" = "Tekeli-li!";
++}
+diff --git a/test/tools/javac/quid/QuotedIdent_BAD62.java b/test/tools/javac/quid/QuotedIdent_BAD62.java
+new file mode 100644
+--- /dev/null
++++ b/test/tools/javac/quid/QuotedIdent_BAD62.java
+@@ -0,0 +1,132 @@
++/*
++ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6746458
++ * @summary Verify correct lexing of quoted identifiers.
++ * @author jrose
++ *
++ * @library ..
++ * @run main quid.QuotedIdent_BAD62
++ */
++
++/*
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD62.java
++ * $ java -version # should print 1.6 or later
++ * $ java -cp dist quid.QuotedIdent_BAD62
++ * </code>
++ */
++
++package quid;
++
++public class QuotedIdent_BAD62 {
++ static void check(int testid, String have, String expect)
++ throws RuntimeException {
++ if ((have == null && have != expect) ||
++ (have != null && !have.equals(expect))) {
++ String msg =
++ "TEST " + testid + ": HAVE \"" +
++ have + "\" EXPECT \"" + expect + "\"";
++ System.out.println("StringConversion: " + msg);
++ throw new RuntimeException(msg);
++ }
++ }
++
++ // negative tests:
++ //static class #"" { } //BAD empty ident name
++ static class #"<foo>" { } //BAD bad char in ident name
++ /*static class /*(//BAD ident name interrupted by newline) #"jump:
++ " { } /* uncomment previous line to attempt class w/ bad name */
++
++ static class #"int" extends Number {
++ final int #"int";
++ #"int"(int #"int") {
++ this.#"int" = #"int";
++ }
++ static #"int" valueOf(int #"int") {
++ return new #"int"(#"int");
++ }
++ public int intValue() { return #"int"; }
++ public long longValue() { return #"int"; }
++ public float floatValue() { return #"int"; }
++ public double doubleValue() { return #"int"; }
++ public String toString() { return String.valueOf(#"int"); }
++ }
++
++ class #"*86" {
++ String #"555-1212"() { return "[*86.555-1212]"; }
++ }
++ static#"*86"#"MAKE-*86"() { // note close spacing
++ return new QuotedIdent_BAD62().new#"*86"();
++ }
++
++ static String bar() { return "[bar]"; }
++
++ public static void main(String[] args) throws Exception {
++ String s;
++
++ String #"sticky \' wicket" = "wicked ' stick";
++ s = #"sticky ' wicket";
++ check(11, s, "wicked \' stick");
++ check(12, #"s", s);
++ check(13, #"\163", s);
++
++ s = #"QuotedIdent_BAD62".bar();
++ check(21, s, "[bar]");
++
++ s = #"int".valueOf(123).toString();
++ check(22, s, "123");
++
++ s = #"MAKE-*86"().#"555-1212"();
++ check(23, s, "[*86.555-1212]");
++
++ class#"{{{inmost}}}" { }
++ s = new#"{{{inmost}}}"().getClass().getName();
++ if (!s.endsWith("{{{inmost}}}"))
++ check(24, s, "should end with \"{{{inmost}}}\"");
++
++ s = #"Yog-Shoggoth".#"(nameless ululation)";
++ check(25, s, "Tekeli-li!");
++
++ s = #"int".class.getName();
++ check(31, s, QuotedIdent_BAD62.class.getName()+"$int");
++
++ Class x86 = Class.forName(QuotedIdent_BAD62.class.getName()+"$*86");
++ if (x86 != #"*86".class)
++ check(32, "reflected "+x86, "static "+#"*86".class);
++
++ s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
++ check(31, s, "[*86.555-1212]");
++
++ System.out.println("OK");
++ }
++}
++
++interface #"Yog-Shoggoth" {
++ final String #"(nameless ululation)" = "Tekeli-li!";
++}
+diff --git a/test/tools/javac/quid/QuotedIdent_BAD63.java b/test/tools/javac/quid/QuotedIdent_BAD63.java
+new file mode 100644
+--- /dev/null
++++ b/test/tools/javac/quid/QuotedIdent_BAD63.java
+@@ -0,0 +1,132 @@
++/*
++ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6746458
++ * @summary Verify correct lexing of quoted identifiers.
++ * @author jrose
++ *
++ * @library ..
++ * @run main quid.QuotedIdent_BAD63
++ */
++
++/*
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD63.java
++ * $ java -version # should print 1.6 or later
++ * $ java -cp dist quid.QuotedIdent_BAD63
++ * </code>
++ */
++
++package quid;
++
++public class QuotedIdent_BAD63 {
++ static void check(int testid, String have, String expect)
++ throws RuntimeException {
++ if ((have == null && have != expect) ||
++ (have != null && !have.equals(expect))) {
++ String msg =
++ "TEST " + testid + ": HAVE \"" +
++ have + "\" EXPECT \"" + expect + "\"";
++ System.out.println("StringConversion: " + msg);
++ throw new RuntimeException(msg);
++ }
++ }
++
++ // negative tests:
++ //static class #"" { } //BAD empty ident name
++ //static class #"<foo>" { } //BAD bad char in ident name
++ static class /*(//BAD ident name interrupted by newline) #"jump:
++ " { } /* uncomment previous line to attempt class w/ bad name */
++
++ static class #"int" extends Number {
++ final int #"int";
++ #"int"(int #"int") {
++ this.#"int" = #"int";
++ }
++ static #"int" valueOf(int #"int") {
++ return new #"int"(#"int");
++ }
++ public int intValue() { return #"int"; }
++ public long longValue() { return #"int"; }
++ public float floatValue() { return #"int"; }
++ public double doubleValue() { return #"int"; }
++ public String toString() { return String.valueOf(#"int"); }
++ }
++
++ class #"*86" {
++ String #"555-1212"() { return "[*86.555-1212]"; }
++ }
++ static#"*86"#"MAKE-*86"() { // note close spacing
++ return new QuotedIdent_BAD63().new#"*86"();
++ }
++
++ static String bar() { return "[bar]"; }
++
++ public static void main(String[] args) throws Exception {
++ String s;
++
++ String #"sticky \' wicket" = "wicked ' stick";
++ s = #"sticky ' wicket";
++ check(11, s, "wicked \' stick");
++ check(12, #"s", s);
++ check(13, #"\163", s);
++
++ s = #"QuotedIdent_BAD63".bar();
++ check(21, s, "[bar]");
++
++ s = #"int".valueOf(123).toString();
++ check(22, s, "123");
++
++ s = #"MAKE-*86"().#"555-1212"();
++ check(23, s, "[*86.555-1212]");
++
++ class#"{{{inmost}}}" { }
++ s = new#"{{{inmost}}}"().getClass().getName();
++ if (!s.endsWith("{{{inmost}}}"))
++ check(24, s, "should end with \"{{{inmost}}}\"");
++
++ s = #"Yog-Shoggoth".#"(nameless ululation)";
++ check(25, s, "Tekeli-li!");
++
++ s = #"int".class.getName();
++ check(31, s, QuotedIdent_BAD63.class.getName()+"$int");
++
++ Class x86 = Class.forName(QuotedIdent_BAD63.class.getName()+"$*86");
++ if (x86 != #"*86".class)
++ check(32, "reflected "+x86, "static "+#"*86".class);
++
++ s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
++ check(31, s, "[*86.555-1212]");
++
++ System.out.println("OK");
++ }
++}
++
++interface #"Yog-Shoggoth" {
++ final String #"(nameless ululation)" = "Tekeli-li!";
++}