"
+ },
//Test for "overview-frame.html" showing the "All Profiles" link.
{PROFILE_BUG_ID + FS + "overview-frame.html",
""
+ "pkg2.Class1Pkg2"
- + NL +"Class1Pkg2. This class is deprecated
"
+ + NL +""
},
//Test deprecated package in profile
{PROFILE_BUG_ID + FS + "deprecated-list.html",""
+ "pkgDeprecated"
- + NL +"This package is Deprecated."
+ + NL +""
},
{PROFILE_BUG_ID + FS + "pkgDeprecated" + FS + "package-summary.html",
- "Deprecated."
- + NL + " This package is Deprecated."
+ "Deprecated."
+ + NL + " "
},
// need to add teststring when JDK-8015496 will be fixed
@@ -171,6 +191,21 @@ public class TestProfiles extends JavadocTester {
+ "target=\"classFrame\">Anno1Pkg4"
},
{PROFILE_BUG_ID + FS + "compact1-summary.html"," Use"
+ },
+ {PROFILE_BUG_ID + FS + "compact2-summary.html",
+ " " + NL + "- " + NL
+ + "" + NL + "
- " + NL
+ + "
"
+ },
+ {PROFILE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html",
+ "" + NL + "- " + NL
+ + "
- " + NL
+ + "
"
}
};
private static final String[][] PACKAGES_TEST = {
diff --git a/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java b/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java
index 287cca02952..f194bddff93 100644
--- a/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java
+++ b/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8006124 8009684 8015663 8015496
+ * @bug 8006124 8009684 8015663 8015496 8026567
* @summary Test javadoc options support for profiles.
* @author Evgeniya Stepanova
* @library ../lib/
@@ -87,7 +87,7 @@ public class TestProfilesConfiguration extends JavadocTester {
{PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html",
"" + NL + "" +
- "Deprecated. "
+ "Deprecated."
}
};
private static final String[][] PROFILES_CONFIGURATION_NEGATED_TEST = {
diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
index 06217b94a56..1f391d08184 100644
--- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
@@ -25,7 +25,7 @@
/*
* @test
- * @bug 6802694 8025633
+ * @bug 6802694 8025633 8026567
* @summary This test verifies deprecation info in serialized-form.html.
* @author Bhavesh Patel
* @library ../lib/
@@ -42,29 +42,29 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester {
// display the inline comments, tags and deprecation information if any.
private static final String[][] TEST_CMNT_DEPR = {
{BUG_ID + FS + "serialized-form.html", "" + NL +
- "- Throws:
" + NL + "" +
- "java.io.IOException "+ NL + "- See Also:" +
+ "
- Throws:
" + NL + " " +
+ "java.io.IOException "+ NL + "- See Also:" +
"
" + NL + "- " +
"
C1.setUndecorated(boolean) " + NL + " "},
- {BUG_ID + FS + "serialized-form.html", "Deprecated." +
- " As of JDK version 1.5, replaced by" + NL +
+ {BUG_ID + FS + "serialized-form.html", "Deprecated." +
+ " " + NL +
"This field indicates whether the C1 " +
"is undecorated. " + NL + " " + NL +
- "" + NL + "- Since:
" + NL +
- "- 1.4
" + NL + "- See Also:" +
+ "
" + NL + "- Since:
" + NL +
+ "- 1.4
" + NL + "- See Also:" +
"
" + NL + "- " +
"
C1.setUndecorated(boolean) " + NL + " "},
- {BUG_ID + FS + "serialized-form.html", "Deprecated." +
- " As of JDK version 1.5, replaced by" + NL +
+ {BUG_ID + FS + "serialized-form.html", "Deprecated." +
+ " " + NL +
"Reads the object stream. " + NL +
- "" + NL + "- Throws:
" + NL + "" +
+ "" + NL + "- Throws:
" + NL + "" +
"IOException
" + NL +
"java.io.IOException " + NL + " "},
- {BUG_ID + FS + "serialized-form.html", "Deprecated." +
+ {BUG_ID + FS + "serialized-form.html", "Deprecated." +
" " + NL + "" +
"The name for this class. "}};
@@ -73,12 +73,12 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester {
// information if any.
private static final String[][] TEST_NOCMNT = {
{BUG_ID + FS + "serialized-form.html", "boolean undecorated " + NL +
- "Deprecated. " +
+ "Deprecated. " + NL + ""},
- {BUG_ID + FS + "serialized-form.html", "" +
- "Deprecated. As of JDK version" +
+ {BUG_ID + FS + "serialized-form.html", "" +
+ "Deprecated. " + NL + ""}};
diff --git a/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java b/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
index 94b3eb134ef..e48e805ae6e 100644
--- a/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
+++ b/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4695326 4750173 4920381
+ * @bug 4695326 4750173 4920381 8026567
* @summary Test the declarartion of simple tags using -tag. Verify that
* "-tag name" is a shortcut for "-tag name:a:Name:". Also verity that
* you can escape the ":" character with a back slash so that it is not
@@ -42,13 +42,13 @@ public class TestSimpleTag extends JavadocTester {
private static final String[][] TEST =
new String[][] {
{"./" + BUG_ID + "/C.html",
- "Todo:"},
+ "Todo:"},
{"./" + BUG_ID + "/C.html",
- "EJB Beans:"},
+ "EJB Beans:"},
{"./" + BUG_ID + "/C.html",
- "Regular Tag:"},
+ "Regular Tag:"},
{"./" + BUG_ID + "/C.html",
- "Back-Slash-Tag:"},
+ "Back-Slash-Tag:"},
};
private static final String[] ARGS = new String[] {
diff --git a/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java b/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java
index 4b5ac2310b9..83617bd93bb 100644
--- a/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java
+++ b/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8008768
+ * @bug 8008768 8026567
* @summary Using {@inheritDoc} in simple tag defined via -tag fails
* @library ../lib/
* @build JavadocTester TestSimpleTagInherit
@@ -46,10 +46,10 @@ public class TestSimpleTagInherit extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
{ BUG_ID + FS + "p" + FS + "TestClass.html",
- "- Custom:
" + NL +
+ "- Custom:
" + NL +
"- doc for BaseClass class
" },
{ BUG_ID + FS + "p" + FS + "TestClass.html",
- "- Custom:
" + NL +
+ "- Custom:
" + NL +
"- doc for BaseClass method
" }
};
private static final String[][] NEGATED_TEST = NO_TEST;
diff --git a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
index 531047cc065..b3538994c81 100644
--- a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
+++ b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 7180906
+ * @bug 7180906 8026567
* @summary Test to make sure that the since tag works correctly
* @author Bhavesh Patel
* @library ../lib/
@@ -48,11 +48,11 @@ public class TestSinceTag extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg1" + FS + "C1.html",
- "" + NL + "- Since:
" + NL +
+ "" + NL + "- Since:
" + NL +
"- JDK1.0
"
},
{BUG_ID + FS + "serialized-form.html",
- "" + NL + "- Since:
" + NL +
+ "" + NL + "- Since:
" + NL +
"- 1.4
"
}
};
diff --git a/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java b/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java
index c7d5f7a186e..aecf75154e8 100644
--- a/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java
+++ b/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java
@@ -25,7 +25,7 @@
/*
* @test
- * @bug 8026370
+ * @bug 8026370 8026567
* @summary This test checks the generated tag output.
* @author Bhavesh Patel
* @library ../lib/
@@ -38,15 +38,15 @@ public class TestTagOutput extends JavadocTester {
private static final String BUG_ID = "8026370";
private static final String[][] TEST = {
{BUG_ID + FS + "pkg1" + FS + "DeprecatedTag.html",
- "Deprecated. "},
+ "Deprecated. "},
{BUG_ID + FS + "pkg1" + FS + "DeprecatedTag.html",
- "Deprecated. " +
- "Do not use this. "}};
+ "Deprecated. " +
+ " "}};
private static final String[][] NEGATED_TEST = {
{BUG_ID + FS + "pkg1" + FS + "DeprecatedTag.html",
- "Deprecated." +
- " "}};
+ "Deprecated." +
+ " "}};
private static final String[] ARGS =
new String[] {
diff --git a/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java b/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java
index e49e857e6fe..563b84a2e6b 100644
--- a/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java
+++ b/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java
@@ -55,7 +55,7 @@ public class TestTaglets extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST_4654308 = new String[][] {
- {"4654308" + FS + "C.html", "Foo:" +
+ {"4654308" + FS + "C.html", "Foo:" +
"- my only method is
here" +
" "}
};
diff --git a/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java b/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
index b0b7e475681..d3183718ec8 100644
--- a/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
+++ b/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
@@ -50,7 +50,7 @@ public class Foo extends BaseTaglet {
*/
public Content getTagletOutput(Tag tag, TagletWriter writer) {
ArrayList inlineTags = new ArrayList();
- inlineTags.add(new TextTag(tag.holder(), "- Foo:
- "));
+ inlineTags.add(new TextTag(tag.holder(), "
- Foo:
- "));
inlineTags.addAll(Arrays.asList(tag.inlineTags()));
inlineTags.add(new TextTag(tag.holder(), "
"));
return writer.commentTagsToOutput(tag,
diff --git a/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java b/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
index 49408e4ed01..67a55e226af 100644
--- a/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
+++ b/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4530727
+ * @bug 4530727 8026567
* @summary When an exception is declared in the method signature but
* not documented with a throws tag, we generate a link to it in the
* throws section. Make sure that the link is below a Throws heading.
@@ -38,7 +38,7 @@ public class TestThrowsHead extends JavadocTester {
private static final String BUG_ID = "4530727";
private static final String[][] TEST = {
- {BUG_ID + FS + "C.html", "- Throws:"}
+ {BUG_ID + FS + "C.html", "
- Throws:"}
};
private static final String[][] NEGATED_TEST = NO_TEST;
private static final String[] ARGS = new String[] {
diff --git a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
index 0627c07fccd..ad94e1d50b4 100644
--- a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
+++ b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8005091 8009686 8025633
+ * @bug 8005091 8009686 8025633 8026567
* @summary Make sure that type annotations are displayed correctly
* @author Bhavesh Patel
* @library ../lib/
@@ -74,12 +74,12 @@ public class TestTypeAnnotations extends JavadocTester {
// Test for type annotations on Class Parameters (ClassParameters.java).
{BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html",
- "class ExtendsBound<K extends ExtendsBound<K extends @ClassParamA java.lang.String>"
},
{BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html",
- "
class ExtendsGeneric<K extends " +
+ "class ExtendsGeneric<K extends " +
"@ClassParamA Unannotated< java.lang.String>>"
},
{BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
- "class TwoBounds<K extends class TwoBounds<K extends " +
"@ClassParamA java.lang.String,V extends @ClassParamB" +
" java.lang.String>"
},
{BUG_ID + FS + "typeannos" + FS + "Complex1.html",
- "class Complex1<K extends Complex1<K extends " +
"@ClassParamA java.lang.String & java.lang.Runnable>"
},
{BUG_ID + FS + "typeannos" + FS + "Complex2.html",
- "class Complex2<K extends java.lang." +
+ "class Complex2<K extends java.lang." +
"String & @ClassParamB java.lang.Runnable>"
},
{BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
- "class ComplexBoth<K extends ComplexBoth<K extends @ClassParamA java.lang.String & @ClassParamA" +
diff --git a/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java b/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
index 1d24a52798a..f035444b510 100644
--- a/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
+++ b/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4764045 8004825
+ * @bug 4764045 8004825 8026567
* @summary This test ensures that the value tag works in all
* use cases. The explainations for each test case are written below.
* @author jamieh
@@ -94,7 +94,7 @@ public class TestValueTag extends JavadocTester {
"Result: \"Test 17 passes\""},
//Test @value tag used with custom tag.
{BUG_ID + FS + "pkg1" + FS + "CustomTagUsage.html",
- "- Todo:
" + NL +
+ "- Todo:
" + NL +
"- the value of this constant is 55.
"},
//Test @value errors printed dues to invalid use or when used with
//non-constant or with bad references.
diff --git a/langtools/test/tools/doclint/CustomTagTest.java b/langtools/test/tools/doclint/CustomTagTest.java
new file mode 100644
index 00000000000..3340dfb878c
--- /dev/null
+++ b/langtools/test/tools/doclint/CustomTagTest.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006248
+ * @summary DocLint should report unknown tags
+ * @build DocLintTester
+ * @run main DocLintTester CustomTagTest.java
+ * @run main DocLintTester -XcustomTags: -ref CustomTagTest.out CustomTagTest.java
+ * @run main DocLintTester -XcustomTags:customTag -ref CustomTagTestWithOption.out CustomTagTest.java
+ * @run main DocLintTester -XcustomTags:customTag,anotherCustomTag -ref CustomTagTestWithOption.out CustomTagTest.java
+ * @author bpatel
+ */
+
+/**
+ * @customTag Text for a custom tag.
+ * @unknownTag Text for an unknown tag.
+ */
+public class CustomTagTest {
+}
+
diff --git a/langtools/test/tools/doclint/CustomTagTest.out b/langtools/test/tools/doclint/CustomTagTest.out
new file mode 100644
index 00000000000..063e313071e
--- /dev/null
+++ b/langtools/test/tools/doclint/CustomTagTest.out
@@ -0,0 +1,8 @@
+CustomTagTest.java:14: error: unknown tag: customTag
+ * @customTag Text for a custom tag.
+ ^
+CustomTagTest.java:15: error: unknown tag: unknownTag
+ * @unknownTag Text for an unknown tag.
+ ^
+2 errors
+
diff --git a/langtools/test/tools/doclint/CustomTagTestWithOption.out b/langtools/test/tools/doclint/CustomTagTestWithOption.out
new file mode 100644
index 00000000000..09150146e0c
--- /dev/null
+++ b/langtools/test/tools/doclint/CustomTagTestWithOption.out
@@ -0,0 +1,5 @@
+CustomTagTest.java:15: error: unknown tag: unknownTag
+ * @unknownTag Text for an unknown tag.
+ ^
+1 error
+
diff --git a/langtools/test/tools/doclint/DocLintTester.java b/langtools/test/tools/doclint/DocLintTester.java
index 78c052a695c..2691731c8e2 100644
--- a/langtools/test/tools/doclint/DocLintTester.java
+++ b/langtools/test/tools/doclint/DocLintTester.java
@@ -58,6 +58,8 @@ public class DocLintTester {
badArgs = true;
} else if (arg.startsWith("-Xmsgs")) {
opts.add(arg);
+ } else if (arg.startsWith("-XcustomTags")) {
+ opts.add(arg);
} else if (arg.startsWith("-")) {
opts.add(arg);
if (i < args.length - 1 && !args[i+1].startsWith("-"))
diff --git a/langtools/test/tools/javac/ExtDirs/ExtDirTest.java b/langtools/test/tools/javac/ExtDirs/ExtDirTest.java
index 22af79a9f8f..d33592f819c 100644
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest.java
+++ b/langtools/test/tools/javac/ExtDirs/ExtDirTest.java
@@ -112,11 +112,6 @@ public class ExtDirTest {
}
void createJars() throws Exception {
-
-// for i in 1 2 3; do
-// if test ! -d ext${i}; then mkdir ext${i}; fi
-// cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
-// done
sun.tools.jar.Main jarGenerator =
new sun.tools.jar.Main(System.out, System.err, "jar");
@@ -155,19 +150,19 @@ public class ExtDirTest {
void compileWithExtDirs() throws Exception {
-//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
+//javac -extdirs ext1 ExtDirTest_1.java
ToolBox.JavaToolArgs params =
new ToolBox.JavaToolArgs()
.setOptions("-d", ".", "-extdirs", "ext1")
.setSources(ExtDirTest_1Src);
ToolBox.javac(params);
-//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
+//javac -extdirs ext1:ext2 ExtDirTest_2.java
params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2")
.setSources(ExtDirTest_2Src);
ToolBox.javac(params);
-//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
+//javac -extdirs ext3 ExtDirTest_3.java
params.setOptions("-d", ".", "-extdirs", "ext3")
.setSources(ExtDirTest_3Src);
ToolBox.javac(params);
diff --git a/langtools/test/tools/javac/ExtDirs/ext1/pkg1.jar b/langtools/test/tools/javac/ExtDirs/ext1/pkg1.jar
deleted file mode 100644
index 3429f8e2b9f..00000000000
Binary files a/langtools/test/tools/javac/ExtDirs/ext1/pkg1.jar and /dev/null differ
diff --git a/langtools/test/tools/javac/ExtDirs/ext2/pkg2.jar b/langtools/test/tools/javac/ExtDirs/ext2/pkg2.jar
deleted file mode 100644
index 9c4705fc728..00000000000
Binary files a/langtools/test/tools/javac/ExtDirs/ext2/pkg2.jar and /dev/null differ
diff --git a/langtools/test/tools/javac/ExtDirs/ext3/pkg1.jar b/langtools/test/tools/javac/ExtDirs/ext3/pkg1.jar
deleted file mode 100644
index 3429f8e2b9f..00000000000
Binary files a/langtools/test/tools/javac/ExtDirs/ext3/pkg1.jar and /dev/null differ
diff --git a/langtools/test/tools/javac/ExtDirs/ext3/pkg2.jar b/langtools/test/tools/javac/ExtDirs/ext3/pkg2.jar
deleted file mode 100644
index 9c4705fc728..00000000000
Binary files a/langtools/test/tools/javac/ExtDirs/ext3/pkg2.jar and /dev/null differ
diff --git a/langtools/test/tools/javac/MethodParameters/LambdaTest.out b/langtools/test/tools/javac/MethodParameters/LambdaTest.out
index 7cfdfe9058a..da662e11958 100644
--- a/langtools/test/tools/javac/MethodParameters/LambdaTest.out
+++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.out
@@ -1,7 +1,7 @@
class LambdaTest --
LambdaTest.()
LambdaTest.foo(i)
-LambdaTest.lambda$1(arg0, arg1)/*synthetic*/
-LambdaTest.lambda$0(arg0)/*synthetic*/
+LambdaTest.lambda$static$1(arg0)/*synthetic*/
+LambdaTest.lambda$null$0(arg0, arg1)/*synthetic*/
static interface LambdaTest$I -- inner
-LambdaTest$I.m(x)
\ No newline at end of file
+LambdaTest$I.m(x)
diff --git a/langtools/test/tools/javac/MethodParameters/Tester.java b/langtools/test/tools/javac/MethodParameters/Tester.java
index 4b3bb04580f..1833985412c 100644
--- a/langtools/test/tools/javac/MethodParameters/Tester.java
+++ b/langtools/test/tools/javac/MethodParameters/Tester.java
@@ -27,7 +27,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
/**
@@ -152,14 +151,14 @@ public class Tester {
throws FileNotFoundException, IOException {
List refFileList = Files.readAllLines(refFile.toPath(), StandardCharsets.UTF_8);
- List sbList = Arrays.asList(sb.split(System.getProperty("line.separator")));
+ List sbList = Arrays.asList(sb.split("[\r\n]+"));
// Check if test output contains unexpected lines or is missing expected lines.
- List sbOnly = new ArrayList(sbList);
+ List sbOnly = new ArrayList<>(sbList);
sbOnly.removeAll(refFileList);
for (String line: sbOnly)
error("unexpected line found: " + line);
- List refOnly = new ArrayList(refFileList);
+ List refOnly = new ArrayList<>(refFileList);
refOnly.removeAll(sbList);
for (String line: refOnly)
error("expected line not found: " + line);
diff --git a/langtools/test/tools/javac/T8019486/WrongLVTForLambdaTest.java b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java
similarity index 58%
rename from langtools/test/tools/javac/T8019486/WrongLVTForLambdaTest.java
rename to langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java
index 9d7d32abb3b..525e20e074b 100644
--- a/langtools/test/tools/javac/T8019486/WrongLVTForLambdaTest.java
+++ b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java
@@ -25,11 +25,11 @@
/*
* @test
- * @bug 8019486
+ * @bug 8019486 8026861
* @summary javac, generates erroneous LVT for a test case with lambda code
* @library /tools/javac/lib
* @build ToolBox
- * @run main WrongLVTForLambdaTest
+ * @run main WrongLNTForLambdaTest
*/
import java.io.File;
@@ -41,7 +41,7 @@ import com.sun.tools.classfile.LineNumberTable_attribute;
import com.sun.tools.classfile.Method;
import com.sun.tools.javac.util.Assert;
-public class WrongLVTForLambdaTest {
+public class WrongLNTForLambdaTest {
static final String testSource =
/* 01 */ "import java.util.List;\n" +
@@ -54,23 +54,72 @@ public class WrongLVTForLambdaTest {
/* 08 */ " final List numbersPlusOne = \n" +
/* 09 */ " numbers.stream().map(number -> number / 1).collect(Collectors.toList());\n" +
/* 10 */ " }\n" +
- /* 11 */ "}";
+ /* 11 */ " void variablesInLambdas(int value) {\n" +
+ /* 12 */ " Runnable r1 = () -> {\n" +
+ /* 13 */ " int i = value;\n" +
+ /* 14 */ " class FooBar {\n" +
+ /* 15 */ " public void run() {\n" +
+ /* 16 */ " T t = null;\n" +
+ /* 17 */ " }\n" +
+ /* 18 */ " }\n" +
+ /* 19 */ " };\n" +
+ /* 20 */ " Runnable r2 = () -> System.err.println(1);\n" +
+ /* 21 */ " Runnable r3 = (Runnable & java.io.Serializable) this::foo;\n" +
+ /* 22 */ " Runnable r4 = super :: notify;\n" +
+ /* 23 */ " }\n" +
+ /* 24 */ " private void foo() {}\n" +
+ /* 25 */ "}";
- static final int[][] expectedLNT = {
+ static final int[][] simpleLambdaExpectedLNT = {
// {line-number, start-pc},
{9, 0}, //number -> number / 1
};
- static final String methodToLookFor = "lambda$0";
+ static final int[][] lambdaWithVarsExpectedLNT = {
+ // {line-number, start-pc},
+ {13, 0}, //number -> number / 1
+ {19, 2}, //number -> number / 1
+ };
+
+ static final int[][] insideLambdaWithVarsExpectedLNT = {
+ // {line-number, start-pc},
+ {16, 0}, //number -> number / 1
+ {17, 2}, //number -> number / 1
+ };
+
+ static final int[][] lambdaVoid2VoidExpectedLNT = {
+ // {line-number, start-pc},
+ {20, 0}, //number -> number / 1
+ };
+
+ static final int[][] deserializeExpectedLNT = {
+ // {line-number, start-pc},
+ {05, 0}, //number -> number / 1
+ };
+
+ static final int[][] lambdaBridgeExpectedLNT = {
+ // {line-number, start-pc},
+ {22, 0}, //number -> number / 1
+ };
public static void main(String[] args) throws Exception {
- new WrongLVTForLambdaTest().run();
+ new WrongLNTForLambdaTest().run();
}
void run() throws Exception {
compileTestClass();
checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
- "Foo.class").toUri()), methodToLookFor);
+ "Foo.class").toUri()), "lambda$bar$0", simpleLambdaExpectedLNT);
+ checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+ "Foo.class").toUri()), "lambda$variablesInLambdas$1", lambdaWithVarsExpectedLNT);
+ checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+ "Foo$1FooBar.class").toUri()), "run", insideLambdaWithVarsExpectedLNT);
+ checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+ "Foo.class").toUri()), "lambda$variablesInLambdas$2", lambdaVoid2VoidExpectedLNT);
+ checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+ "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT);
+ checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+ "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT);
}
void compileTestClass() throws Exception {
@@ -79,7 +128,7 @@ public class WrongLVTForLambdaTest {
ToolBox.javac(javacSuccessArgs);
}
- void checkClassFile(final File cfile, String methodToFind) throws Exception {
+ void checkClassFile(final File cfile, String methodToFind, int[][] expectedLNT) throws Exception {
ClassFile classFile = ClassFile.read(cfile);
boolean methodFound = false;
for (Method method : classFile.methods) {
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java
index f53340f6366..e01fa1f72d4 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java
@@ -3,7 +3,6 @@
* @bug 8006733 8006775
* @summary Ensure behavior for nested types is correct.
* @author Werner Dietl
- * @ignore
* @compile/fail/ref=CantAnnotateStaticClass2.out -XDrawDiagnostics CantAnnotateStaticClass2.java
*/
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out
index 977dd690624..869059ce7f0 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out
@@ -24,10 +24,6 @@ CantAnnotateStaticClass2.java:57:12: compiler.err.cant.type.annotate.scoping.1:
CantAnnotateStaticClass2.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
-CantAnnotateStaticClass2.java:105:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
-CantAnnotateStaticClass2.java:107:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
-CantAnnotateStaticClass2.java:112:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
-CantAnnotateStaticClass2.java:114:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:120:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:121:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:128:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
@@ -50,6 +46,10 @@ CantAnnotateStaticClass2.java:165:22: compiler.err.cant.type.annotate.scoping.1:
CantAnnotateStaticClass2.java:167:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:169:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:171:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
+CantAnnotateStaticClass2.java:105:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
+CantAnnotateStaticClass2.java:107:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
+CantAnnotateStaticClass2.java:112:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
+CantAnnotateStaticClass2.java:114:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:184:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:186:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:187:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
@@ -62,4 +62,4 @@ CantAnnotateStaticClass2.java:201:41: compiler.err.cant.type.annotate.scoping.1:
CantAnnotateStaticClass2.java:202:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
CantAnnotateStaticClass2.java:204:49: compiler.err.cant.type.annotate.scoping: @Top.TA,@Top.TB,@Top.TC
-64 errors
\ No newline at end of file
+64 errors
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.java
new file mode 100644
index 00000000000..1c5f6ee1fcc
--- /dev/null
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8023682
+ * @summary Cannot annotate an anonymous class with a target type of TYPE
+ * @compile/fail/ref=TypeOnAnonClass.out -XDrawDiagnostics TypeOnAnonClass.java
+ */
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@interface X {}
+interface Foo {}
+class TypeOnAnonClass { void m() { new @X Foo() {}; } }
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.out b/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.out
new file mode 100644
index 00000000000..f5a986dd956
--- /dev/null
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/TypeOnAnonClass.out
@@ -0,0 +1,2 @@
+TypeOnAnonClass.java:13:40: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
index 91c76a572e9..490f378c755 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
@@ -1,4 +1,5 @@
DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
-3 errors
\ No newline at end of file
+DeclarationAnnotation.java:16:21: compiler.err.annotation.type.not.applicable
+4 errors
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
index e4136c29b7a..d43141e245e 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
@@ -32,12 +32,9 @@ import java.lang.annotation.*;
*/
class AnonymousClass {
Object o1 = new @TA Object() { };
- // Declaration annotations are also allowed.
- Object o2 = new @TA @DA Object() { };
+ Object o2 = new @TA Object() { };
}
-@interface DA { }
-
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface TA { }
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
index 59b02d7b105..8a1545d2f34 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
@@ -25,7 +25,6 @@ import java.lang.annotation.*;
/*
* @test
- * @ignore 8008762 Type annotations failures
* @bug 8006775
* @summary new type annotation location: multicatch
* @author Werner Dietl
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
index a8d1311eb47..3106341ddc5 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
@@ -21,14 +21,16 @@
* questions.
*/
-import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
-
/*
* @test
+ * @bug 8026791
* @summary Test population of reference info for constructor results
* @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
* @run main Driver Constructors
*/
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
public class Constructors {
@TADescriptions({
@@ -42,8 +44,8 @@ public class Constructors {
}
@TADescriptions({
- @TADescription(annotation = "TA", type = METHOD_RETURN),
- @TADescription(annotation = "TB", type = METHOD_RETURN),
+ @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}),
+ @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Test$Inner")
@@ -56,9 +58,9 @@ public class Constructors {
@TADescriptions({
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
- @TADescription(annotation = "TB", type = METHOD_RETURN),
+ @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TC", type = METHOD_RECEIVER),
- @TADescription(annotation = "TD", type = METHOD_RETURN),
+ @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Test$Inner")
@@ -72,9 +74,9 @@ public class Constructors {
@TADescriptions({
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
@TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
- @TADescription(annotation = "TC", type = METHOD_RETURN),
+ @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
@TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
- @TADescription(annotation = "TE", type = METHOD_RETURN),
+ @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Outer$Middle$Inner")
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
index aaa2faac469..7c16a0d7b66 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
@@ -25,7 +25,6 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
/*
* @test
- * @ignore 8008762 Type annotation failures
* @bug 8006732 8006775
* @summary Test population of reference info for multicatch exception parameters
* @author Werner Dietl
diff --git a/langtools/test/tools/javac/lambda/8016081/T8016081.java b/langtools/test/tools/javac/lambda/8016081/T8016081.java
index 648955f83cc..055712747a7 100644
--- a/langtools/test/tools/javac/lambda/8016081/T8016081.java
+++ b/langtools/test/tools/javac/lambda/8016081/T8016081.java
@@ -32,7 +32,7 @@ class T8016081 {
interface fint { int get(); }
@interface atype {
- fint fld = ()->( fld == null ?0 : 1);
+ fint fld = ()->1;
}
@atype class T {}
diff --git a/langtools/test/tools/javac/lambda/LambdaExpr13.java b/langtools/test/tools/javac/lambda/LambdaExpr13.java
index 7a5181e54fe..2b2d75e6e32 100644
--- a/langtools/test/tools/javac/lambda/LambdaExpr13.java
+++ b/langtools/test/tools/javac/lambda/LambdaExpr13.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -26,13 +26,14 @@
* @bug 8003280
* @summary Add lambda tests
* check that recursive lambda (through field ref) is accepted in all contexts
+ * but field initialization
* @compile LambdaExpr13.java
*/
class LambdaExpr13 {
- Runnable ir = () -> { ir.run(); };;
- static Runnable sr = () -> { sr.run(); };
+ Runnable ir;
+ static Runnable sr;
{ ir = () -> { ir.run(); }; }
static { sr = () -> { sr.run(); }; }
diff --git a/langtools/test/tools/javac/lambda/LocalVariableTable.java b/langtools/test/tools/javac/lambda/LocalVariableTable.java
new file mode 100644
index 00000000000..8a4d04a061b
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/LocalVariableTable.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2013, 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 8025998 8026749
+ * @summary Missing LV table in lambda bodies
+ * @compile -g LocalVariableTable.java
+ * @run main LocalVariableTable
+ */
+
+import java.io.*;
+import java.lang.annotation.*;
+import java.util.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * The test checks that a LocalVariableTable attribute is generated for the
+ * method bodies representing lambda expressions, and checks that the expected
+ * set of entries is found in the attribute.
+ *
+ * Since the bug was about missing entries in the LVT, not malformed entries,
+ * the test is not intended to be a detailed test of the contents of each
+ * LocalVariableTable entry: it is assumed that if a entry is present, it
+ * will have the correct contents.
+ *
+ * The test looks for test cases represented by nested classes whose
+ * name begins with "Lambda". Each such class contains a lambda expression
+ * that will mapped into a lambda method, and because the test is compiled
+ * with -g, these methods should have a LocalVariableTable. The set of
+ * expected names in the LVT is provided in an annotation on the class for
+ * the test case.
+ */
+public class LocalVariableTable {
+ public static void main(String... args) throws Exception {
+ new LocalVariableTable().run();
+ }
+
+ void run() throws Exception {
+ // the declared classes are returned in an unspecified order,
+ // so for neatness, sort them by name before processing them
+ Class>[] classes = getClass().getDeclaredClasses();
+ Arrays.sort(classes, (c1, c2) -> c1.getName().compareTo(c2.getName()));
+
+ for (Class> c : classes) {
+ if (c.getSimpleName().startsWith("Lambda"))
+ check(c);
+ }
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ }
+
+ /** Check an individual test case. */
+ void check(Class> c) throws Exception {
+ System.err.println("Checking " + c.getSimpleName());
+
+ Expect expect = c.getAnnotation(Expect.class);
+ if (expect == null) {
+ error("@Expect not found for class " + c.getSimpleName());
+ return;
+ }
+
+ ClassFile cf = ClassFile.read(getClass().getResource(c.getName() + ".class").openStream());
+ Method m = getLambdaMethod(cf);
+ if (m == null) {
+ error("lambda method not found");
+ return;
+ }
+
+ Code_attribute code = (Code_attribute) m.attributes.get(Attribute.Code);
+ if (code == null) {
+ error("Code attribute not found");
+ return;
+ }
+
+ LocalVariableTable_attribute lvt =
+ (LocalVariableTable_attribute) code.attributes.get(Attribute.LocalVariableTable);
+ if (lvt == null) {
+ error("LocalVariableTable attribute not found");
+ return;
+ }
+
+ Set foundNames = new LinkedHashSet<>();
+ for (LocalVariableTable_attribute.Entry e: lvt.local_variable_table) {
+ foundNames.add(cf.constant_pool.getUTF8Value(e.name_index));
+ }
+
+ Set expectNames = new LinkedHashSet<>(Arrays.asList(expect.value()));
+ if (!foundNames.equals(expectNames)) {
+ Set foundOnly = new LinkedHashSet<>(foundNames);
+ foundOnly.removeAll(expectNames);
+ for (String s: foundOnly)
+ error("Unexpected name found: " + s);
+ Set expectOnly = new LinkedHashSet<>(expectNames);
+ expectOnly.removeAll(foundNames);
+ for (String s: expectOnly)
+ error("Expected name not found: " + s);
+ }
+ }
+
+ /** Get a method whose name begins "lambda$...". */
+ Method getLambdaMethod(ClassFile cf) throws ConstantPoolException {
+ for (Method m: cf.methods) {
+ if (m.getName(cf.constant_pool).startsWith("lambda$"))
+ return m;
+ }
+ return null;
+ }
+
+ /** Report an error. */
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+
+ /**
+ * Annotation used to provide the set of names expected in the LVT attribute.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Expect {
+ String[] value();
+ }
+
+ /** Functional interface with nullary method. */
+ interface Run0 {
+ public void run();
+ }
+
+ /** Functional interface with 1-ary method. */
+ interface Run1 {
+ public void run(int a0);
+ }
+
+ /** Functional interface with 2-ary method. */
+ interface Run2 {
+ public void run(int a0, int a1);
+ }
+
+ /*
+ * ---------- Test cases ---------------------------------------------------
+ */
+
+ @Expect({ "x" })
+ static class Lambda_Args0_Local1 {
+ Run0 r = () -> { int x = 0; };
+ }
+
+ @Expect({ "x", "this" })
+ static class Lambda_Args0_Local1_this {
+ int v;
+ Run0 r = () -> { int x = v; };
+ }
+
+ @Expect({ "a" })
+ static class Lambda_Args1_Local0 {
+ Run1 r = (a) -> { };
+ }
+
+ @Expect({ "a", "x" })
+ static class Lambda_Args1_Local1 {
+ Run1 r = (a) -> { int x = a; };
+ }
+
+ @Expect({ "a", "x" })
+ static class Lambda_Args1_Local1_Captured1 {
+ void m() {
+ int v = 0;
+ Run1 r = (a) -> { int x = a + v; };
+ }
+ }
+
+ @Expect({ "a1", "a2", "x1", "x2", "this" })
+ static class Lambda_Args2_Local2_Captured2_this {
+ int v;
+ void m() {
+ int v1 = 0;
+ int v2 = 0;
+ Run2 r = (a1, a2) -> {
+ int x1 = a1 + v1 + v;
+ int x2 = a2 + v2 + v;
+ };
+ }
+ }
+
+ @Expect({ "e" })
+ static class Lambda_Try_Catch {
+ private static Runnable asUncheckedRunnable(Closeable c) {
+ return () -> {
+ try {
+ c.close();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ };
+ }
+ }
+}
+
diff --git a/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.java b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.java
new file mode 100644
index 00000000000..408f7b8f228
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013, 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 8024809
+ * @summary javac, some lambda programs are rejected by flow analysis
+ * @compile/fail/ref=SelfInitializerInLambdaTesta.out -XDrawDiagnostics SelfInitializerInLambdaTesta.java
+ */
+
+public class SelfInitializerInLambdaTesta {
+
+ final Runnable r1 = ()->System.out.println(r1);
+
+ final Object lock = new Object();
+
+ final Runnable r2 = ()->{
+ System.out.println(r2);
+ synchronized (lock){}
+ };
+
+ final Runnable r3 = ()->{
+ synchronized (lock){
+ System.out.println(r3);
+ }
+ };
+
+ final Runnable r4 = ()->{
+ System.out.println(r4);
+ };
+
+ interface SAM {
+ int m(String s);
+ }
+
+ final SAM s1 = (String s)->{
+ System.out.println(s + s1.toString());
+ return 0;
+ };
+
+ final SAM s2 = (s)->{
+ System.out.println(s + s2.toString());
+ return 0;
+ };
+}
diff --git a/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.out b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.out
new file mode 100644
index 00000000000..fcf50e891a9
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTesta.out
@@ -0,0 +1,7 @@
+SelfInitializerInLambdaTesta.java:33:48: compiler.err.illegal.self.ref
+SelfInitializerInLambdaTesta.java:38:28: compiler.err.illegal.self.ref
+SelfInitializerInLambdaTesta.java:44:32: compiler.err.illegal.self.ref
+SelfInitializerInLambdaTesta.java:49:28: compiler.err.illegal.self.ref
+SelfInitializerInLambdaTesta.java:57:32: compiler.err.illegal.self.ref
+SelfInitializerInLambdaTesta.java:62:32: compiler.err.illegal.self.ref
+6 errors
diff --git a/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.java b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.java
new file mode 100644
index 00000000000..87c254f7387
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, 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 8024809
+ * @summary javac, some lambda programs are rejected by flow analysis
+ * @compile/fail/ref=SelfInitializerInLambdaTestb.out -XDrawDiagnostics SelfInitializerInLambdaTestb.java
+ */
+
+public class SelfInitializerInLambdaTestb {
+
+ final Runnable r1;
+
+ final Runnable r2 = ()-> System.out.println(r1);
+
+ SelfInitializerInLambdaTestb() {
+ r1 = ()->System.out.println(r1);
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.out b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.out
new file mode 100644
index 00000000000..ebbdcab396c
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/T8024809/SelfInitializerInLambdaTestb.out
@@ -0,0 +1,3 @@
+SelfInitializerInLambdaTestb.java:35:49: compiler.err.var.might.not.have.been.initialized: r1
+SelfInitializerInLambdaTestb.java:38:37: compiler.err.var.might.not.have.been.initialized: r1
+2 errors
diff --git a/langtools/test/tools/javac/lambda/T8025290/ExplicitVSImplicitLambdaTest.java b/langtools/test/tools/javac/lambda/T8025290/ExplicitVSImplicitLambdaTest.java
new file mode 100644
index 00000000000..0bb8edbc589
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/T8025290/ExplicitVSImplicitLambdaTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, 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 8025290
+ * @summary javac implicit versus explicit lambda compilation error
+ * @compile ExplicitVSImplicitLambdaTest.java
+ */
+
+import java.util.function.*;
+
+public class ExplicitVSImplicitLambdaTest {
+ private void test()
+ {
+ /* in the explicit case "e" is inferred to String so we can use a String
+ * only method.
+ */
+ MyComparator.mycomparing1((String e) -> e.concat(""));
+ MyComparator.mycomparing2((String e) -> e.concat(""));
+ MyComparator.mycomparing3((String e) -> e.concat(""));
+ MyComparator.mycomparing4((String e) -> e.concat(""));
+
+ /* in the implicit case "e" is inferred to Object so toString() is OK.
+ */
+ MyComparator.mycomparing1((e) -> e.toString());
+ MyComparator.mycomparing2((e) -> e.toString());
+ MyComparator.mycomparing3((e) -> e.toString());
+ MyComparator.mycomparing4((e) -> e.toString());
+ }
+}
+
+interface MyComparator {
+ public static > MyComparator mycomparing1(
+ Function super T, ? extends U> keyExtractor) {
+ return null;
+ }
+
+ public static > MyComparator mycomparing2(
+ Function super T, ? super U> keyExtractor) {
+ return null;
+ }
+
+ public static > MyComparator mycomparing3(
+ Function extends T, ? extends U> keyExtractor) {
+ return null;
+ }
+
+ public static > MyComparator mycomparing4(
+ Function extends T, ? super U> keyExtractor) {
+ return null;
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/TargetType58.java b/langtools/test/tools/javac/lambda/TargetType58.java
index cb3ca9027e4..d3829ac3f96 100644
--- a/langtools/test/tools/javac/lambda/TargetType58.java
+++ b/langtools/test/tools/javac/lambda/TargetType58.java
@@ -35,7 +35,7 @@ import java.util.stream.*;
class TargetType58 {
void test(List li) {
- g(li, s -> s.substream(200), Collections.emptyList());
+ g(li, s -> s.skip(200), Collections.emptyList());
}
,
diff --git a/langtools/test/tools/javac/lambda/TestSelfRef.java b/langtools/test/tools/javac/lambda/TestSelfRef.java
index 967673e9fc2..58ab1426103 100644
--- a/langtools/test/tools/javac/lambda/TestSelfRef.java
+++ b/langtools/test/tools/javac/lambda/TestSelfRef.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -29,7 +29,6 @@
* consistently w.r.t. local inner classes
*/
-import com.sun.source.util.JavacTask;
import java.net.URI;
import java.util.Arrays;
import javax.tools.Diagnostic;
@@ -38,6 +37,7 @@ import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
public class TestSelfRef {
@@ -176,10 +176,16 @@ public class TestSelfRef {
check();
}
- void check() {
+ boolean isErrorExpected() {
//illegal forward ref
- boolean errorExpected = ik.inMethodContext(sk) &&
- (rk.selfRef || rk.forwardRef);
+ boolean result = ik.inMethodContext(sk) && (rk.selfRef || rk.forwardRef);
+ result |= (rk == RefKind.SELF_LAMBDA || rk == RefKind.FORWARD_LAMBDA);
+ return result;
+ }
+
+ void check() {
+ checkCount++;
+ boolean errorExpected = isErrorExpected();
if (diagChecker.errorFound != errorExpected) {
throw new Error("invalid diagnostics for source:\n" +
source.getCharContent(true) +
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/TestSerializedLambdaNameStability.java b/langtools/test/tools/javac/lambda/lambdaNaming/TestSerializedLambdaNameStability.java
new file mode 100644
index 00000000000..55302b028d2
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/TestSerializedLambdaNameStability.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013, 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 8023668
+ * @summary Desugar serializable lambda bodies using more robust naming scheme
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main TestSerializedLambdaNameStability
+ */
+
+import java.io.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.*;
+
+public class TestSerializedLambdaNameStability {
+
+ final ClassLoader writingClassLoader;
+ final ClassLoader clonedClassLoader;
+ final ClassLoader checkingClassLoader;
+
+ TestSerializedLambdaNameStability() {
+ writingClassLoader = new TestClassLoader("before");
+ clonedClassLoader = new TestClassLoader("before");
+ checkingClassLoader = new TestClassLoader("after");
+ }
+
+ public static void main(String... args) throws Exception {
+ new TestSerializedLambdaNameStability().doit("NameOfCapturedArgs", true);
+ new TestSerializedLambdaNameStability().doit("TypesOfCapturedArgs", true);
+ new TestSerializedLambdaNameStability().doit("OrderOfCapturedArgs", true);
+ new TestSerializedLambdaNameStability().doit("VariableAssignmentTarget", false);
+ new TestSerializedLambdaNameStability().doit("TargetName", true);
+ new TestSerializedLambdaNameStability().doit("TargetType", true);
+ }
+
+ public void doit(String name, boolean expectFail) throws Exception {
+ String iName = "I" + name;
+ String testName = "TEST" + name;
+ Class> kw = writingClassLoader.loadClass(testName);
+ Object instw = getInstance(kw);
+ Method mw = getMethod(kw, "write", ObjectOutput.class);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ObjectOutput out = new ObjectOutputStream(baos)) {
+ mw.invoke(instw, out);
+ }
+ byte[] ser = baos.toByteArray();
+
+ // Read and check clone
+ readCheck(iName, testName, clonedClassLoader, ser);
+ System.err.printf("cloned test readCheck %s\n", testName);
+
+ // Read and check other
+ if (expectFail) {
+ try {
+ readCheck(iName, testName, checkingClassLoader, ser);
+ } catch (InvocationTargetException ite) {
+ Throwable underlying = ite;
+ while (underlying != null && !(underlying instanceof IllegalArgumentException)) {
+ underlying = underlying.getCause();
+ }
+ if (underlying != null) {
+ if (underlying.getMessage().contains("deserialization")) {
+ System.err.printf("PASS: other test %s got expected exception %s\n", testName, underlying);
+ return;
+ }
+ }
+ System.err.printf("FAIL: other test %s got unexpected exception %s\n", testName, ite);
+ throw new Exception("unexpected exception ", ite);
+ }
+ System.err.printf("FAIL: other test %s expected an exception", testName);
+ throw new Exception("expected an exception" + testName);
+ } else {
+ readCheck(iName, testName, checkingClassLoader, ser);
+ System.err.printf("PASS: other test %s readCheck\n", testName);
+ }
+ }
+
+ void readCheck(String iName, String testName, ClassLoader loader, byte[] ser) throws Exception {
+ Class> k = loader.loadClass(testName);
+ Object inst = getInstance(k);
+ Method mrc = getMethod(k, "readCheck", ObjectInput.class);
+ ByteArrayInputStream bais = new ByteArrayInputStream(ser);
+ try (ObjectInput in = new ObjectInputStream(bais)) {
+ mrc.invoke(inst, in);
+ }
+ }
+
+ Method getMethod(Class> k, String name, Class> argTypes) throws Exception {
+ Method meth = k.getDeclaredMethod(name, argTypes);
+ meth.setAccessible(true);
+ return meth;
+ }
+
+ Object getInstance(Class> k) throws Exception {
+ Constructor> cons = k.getConstructors()[0];
+ cons.setAccessible(true);
+ return cons.newInstance();
+ }
+
+ static class TestClassLoader extends ClassLoader {
+ static final String compiledDir = System.getProperty("user.dir");
+ static final String sourceBaseDir = System.getProperty("test.src");
+
+ final String context;
+
+ public TestClassLoader(String context) {
+ super();
+ this.context = context;
+ }
+
+ @Override
+ public Class findClass(String name) throws ClassNotFoundException {
+ byte[] b;
+
+ try {
+ b = loadClassData(name);
+ } catch (Throwable th) {
+ // th.printStackTrace();
+ throw new ClassNotFoundException("Loading error", th);
+ }
+ return defineClass(name, b, 0, b.length);
+ }
+
+ private byte[] loadClassData(String name) throws Exception {
+ String srcName;
+ if (name.startsWith("TEST"))
+ srcName = name;
+ else if (name.startsWith("I"))
+ srcName = "TEST" + name.substring(1);
+ else
+ throw new Exception("Did not expect to load " + name);
+ Path srcFile = Paths.get(sourceBaseDir, context, srcName + ".java");
+ String testSource = new String(Files.readAllBytes(srcFile));
+ ToolBox.JavaToolArgs javacSuccessArgs =
+ new ToolBox.JavaToolArgs().setSources(testSource);
+ ToolBox.javac(javacSuccessArgs);
+ Path cfFile = Paths.get(compiledDir, name + ".class");
+ byte[] bytes = Files.readAllBytes(cfFile);
+ return bytes;
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTNameOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTNameOfCapturedArgs.java
new file mode 100644
index 00000000000..b66e6c24ccc
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTNameOfCapturedArgs.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface INameOfCapturedArgs extends Serializable {
+ int get();
+}
+
+class TESTNameOfCapturedArgs {
+
+ public TESTNameOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ int y = 44;
+ INameOfCapturedArgs res = () -> y;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ INameOfCapturedArgs lam = (INameOfCapturedArgs) in.readObject();
+ int val = lam.get();
+ if (val != 44) {
+ throw new IllegalArgumentException("Expected 44");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTOrderOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTOrderOfCapturedArgs.java
new file mode 100644
index 00000000000..68c915211fc
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTOrderOfCapturedArgs.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface IOrderOfCapturedArgs extends Serializable {
+ String get();
+}
+
+class TESTOrderOfCapturedArgs {
+
+ public TESTOrderOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ String a = "fu";
+ String b = "bar";
+ IOrderOfCapturedArgs res = () -> b + a;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ IOrderOfCapturedArgs lam = (IOrderOfCapturedArgs) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fubar")) {
+ throw new IllegalArgumentException("Expected 'fubar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetName.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetName.java
new file mode 100644
index 00000000000..183a03f6373
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetName.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface ITargetName extends Serializable {
+ String get();
+}
+
+class TESTTargetName {
+
+ public TESTTargetName() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ ITargetName resist = () -> "fubar";
+ out.writeObject(resist);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ ITargetName lam = (ITargetName) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fubar")) {
+ throw new IllegalArgumentException("Expected 'fubar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetType.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetType.java
new file mode 100644
index 00000000000..c7b3d9f699a
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTargetType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.function.*;
+
+class TESTTargetType {
+
+ public TESTTargetType() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ Object res = (Predicate & Serializable) ((str) -> str.length() > 3);
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ in.readObject();
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTypesOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTypesOfCapturedArgs.java
new file mode 100644
index 00000000000..7805575d7cc
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTTypesOfCapturedArgs.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface ITypesOfCapturedArgs extends Serializable {
+ Object get();
+}
+
+class TESTTypesOfCapturedArgs {
+
+ public TESTTypesOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ Object x = "hi";
+ ITypesOfCapturedArgs res = () -> x;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ ITypesOfCapturedArgs lam = (ITypesOfCapturedArgs) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("hi")) {
+ throw new IllegalArgumentException("Expected 'hi'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTVariableAssignmentTarget.java b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTVariableAssignmentTarget.java
new file mode 100644
index 00000000000..18c0dcc2a26
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/after/TESTVariableAssignmentTarget.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface IVariableAssignmentTarget extends Serializable {
+ String get();
+}
+
+class TESTVariableAssignmentTarget {
+
+ public TESTVariableAssignmentTarget() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ IVariableAssignmentTarget res2 = () -> "bar";
+ IVariableAssignmentTarget res1 = () -> "fu";
+ out.writeObject(res1);
+ out.writeObject(res2);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ IVariableAssignmentTarget lam = (IVariableAssignmentTarget) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fu")) {
+ throw new IllegalArgumentException("Expected 'fu'");
+ }
+ lam = (IVariableAssignmentTarget) in.readObject();
+ val = lam.get();
+ if (!val.equals("bar")) {
+ throw new IllegalArgumentException("Expected 'bar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTNameOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTNameOfCapturedArgs.java
new file mode 100644
index 00000000000..67b9a678222
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTNameOfCapturedArgs.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface INameOfCapturedArgs extends Serializable {
+ int get();
+}
+
+class TESTNameOfCapturedArgs {
+
+ public TESTNameOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ int x = 44;
+ INameOfCapturedArgs res = () -> x;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ INameOfCapturedArgs lam = (INameOfCapturedArgs) in.readObject();
+ int val = lam.get();
+ if (val != 44) {
+ throw new IllegalArgumentException("Expected 44");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTOrderOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTOrderOfCapturedArgs.java
new file mode 100644
index 00000000000..1c8461f4f49
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTOrderOfCapturedArgs.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface IOrderOfCapturedArgs extends Serializable {
+ String get();
+}
+
+class TESTOrderOfCapturedArgs {
+
+ public TESTOrderOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ String a = "fu";
+ String b = "bar";
+ IOrderOfCapturedArgs res = () -> a + b;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ IOrderOfCapturedArgs lam = (IOrderOfCapturedArgs) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fubar")) {
+ throw new IllegalArgumentException("Expected 'fubar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetName.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetName.java
new file mode 100644
index 00000000000..7c6d0fd5879
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetName.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface ITargetName extends Serializable {
+ String get();
+}
+
+class TESTTargetName {
+
+ public TESTTargetName() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ ITargetName res = () -> "fubar";
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ ITargetName lam = (ITargetName) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fubar")) {
+ throw new IllegalArgumentException("Expected 'fubar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetType.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetType.java
new file mode 100644
index 00000000000..c459a8760f0
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTargetType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.function.*;
+
+class TESTTargetType {
+
+ public TESTTargetType() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ Object res = (Function & Serializable) ((str) -> str.length() > 3);
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ in.readObject();
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTypesOfCapturedArgs.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTypesOfCapturedArgs.java
new file mode 100644
index 00000000000..4116f2e7d0a
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTTypesOfCapturedArgs.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface ITypesOfCapturedArgs extends Serializable {
+ Object get();
+}
+
+class TESTTypesOfCapturedArgs {
+
+ public TESTTypesOfCapturedArgs() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ String x = "hi";
+ ITypesOfCapturedArgs res = () -> x;
+ out.writeObject(res);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ ITypesOfCapturedArgs lam = (ITypesOfCapturedArgs) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("hi")) {
+ throw new IllegalArgumentException("Expected 'hi'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTVariableAssignmentTarget.java b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTVariableAssignmentTarget.java
new file mode 100644
index 00000000000..76b8f2c0135
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/lambdaNaming/before/TESTVariableAssignmentTarget.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+interface IVariableAssignmentTarget extends Serializable {
+ String get();
+}
+
+class TESTVariableAssignmentTarget {
+
+ public TESTVariableAssignmentTarget() {
+ }
+
+ public void write(ObjectOutput out) throws IOException {
+ IVariableAssignmentTarget res1 = () -> "fu";
+ IVariableAssignmentTarget res2 = () -> "bar";
+ out.writeObject(res1);
+ out.writeObject(res2);
+ }
+
+ public void readCheck(ObjectInput in) throws Exception {
+ IVariableAssignmentTarget lam = (IVariableAssignmentTarget) in.readObject();
+ Object val = lam.get();
+ if (!val.equals("fu")) {
+ throw new IllegalArgumentException("Expected 'fu'");
+ }
+ lam = (IVariableAssignmentTarget) in.readObject();
+ val = lam.get();
+ if (!val.equals("bar")) {
+ throw new IllegalArgumentException("Expected 'bar'");
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/privateMethodReferences/MethodInvoker.java b/langtools/test/tools/javac/lambda/privateMethodReferences/MethodInvoker.java
new file mode 100644
index 00000000000..0ebcd4cff18
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/privateMethodReferences/MethodInvoker.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 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 8022720
+ * @summary private method should be accessible (nested classes)
+ * @run main MethodInvoker
+ */
+
+interface MyFunctionalInterface1 {
+ int invokeMethodReference();
+}
+
+public class MethodInvoker {
+ public static void main(String[] args) throws Exception {
+ MethodInvoker.invoke();
+ System.out.println("Passed!");
+ }
+ public static void invoke() throws Exception {
+ MethodSupplier ms = new MethodSupplier();
+ MyFunctionalInterface1 fi = ms::m;
+ if (fi.invokeMethodReference() != 123) {
+ throw new Exception();
+ }
+ }
+ static class MethodSupplier {
+ private int m() {
+ return 123;
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/privateMethodReferences/MethodSupplier.java b/langtools/test/tools/javac/lambda/privateMethodReferences/MethodSupplier.java
new file mode 100644
index 00000000000..191b40118ac
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/privateMethodReferences/MethodSupplier.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 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 8022720
+ * @summary private method should be accessible (nested classes)
+ * @run main MethodSupplier
+ */
+
+interface MyFunctionalInterface2 {
+ int invokeMethodReference();
+}
+
+public class MethodSupplier {
+ public static void main(String[] args) throws Exception {
+ MethodInvoker.invoke();
+ System.out.println("Passed!");
+ }
+ private int m() {
+ return 4321;
+ }
+ static class MethodInvoker {
+ public static void invoke() throws Exception {
+ MethodSupplier ms = new MethodSupplier();
+ MyFunctionalInterface2 fi = ms::m;
+ if (fi.invokeMethodReference() != 4321) {
+ throw new Exception();
+ }
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambda/privateMethodReferences/ThirdClass.java b/langtools/test/tools/javac/lambda/privateMethodReferences/ThirdClass.java
new file mode 100644
index 00000000000..a5e4d71171d
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/privateMethodReferences/ThirdClass.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013, 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 8022720
+ * @summary private method should be accessible (nested classes)
+ * @run main ThirdClass
+ */
+
+interface MyFunctionalInterface3 {
+ int invokeMethodReference();
+}
+
+public class ThirdClass {
+ public static void main(String[] args) throws Exception {
+ MethodInvoker.invoke();
+ System.out.println("Passed!");
+ }
+ static class MethodSupplier {
+ private int m() {
+ return 999;
+ }
+ }
+
+ static class MethodInvoker {
+ public static void invoke() throws Exception {
+ MethodSupplier ms = new MethodSupplier();
+ MyFunctionalInterface3 fi = ms::m;
+ if (fi.invokeMethodReference() != 999) {
+ throw new Exception();
+ }
+ }
+ }
+}
diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java
index 4aace3da1fe..bb4cf6f9b5d 100644
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java
@@ -46,7 +46,7 @@ public class Compiler {
USECACHE // Keeps results around for reuse. Only use this is
// you're sure that each compilation name maps to the
// same source code
- };
+ }
private static final AtomicInteger counter = new AtomicInteger();
private static final String targetDir = "gen-separate";
@@ -85,7 +85,7 @@ public class Compiler {
}
public void setFlags(Flags ... flags) {
- this.flags = new HashSet(Arrays.asList(flags));
+ this.flags = new HashSet<>(Arrays.asList(flags));
}
public void addPostprocessor(ClassFilePreprocessor cfp) {
@@ -131,17 +131,10 @@ public class Compiler {
outputDirs.put(type.getName(), outDir);
Class superClass = type.getSuperclass();
- if (superClass != null) {
- for( Map.Entry each : compileHierarchy(superClass).entrySet()) {
- outputDirs.put(each.getKey(), each.getValue());
- }
- }
- for (Extends ext : type.getSupertypes()) {
- Type iface = ext.getType();
- for( Map.Entry each : compileHierarchy(iface).entrySet()) {
- outputDirs.put(each.getKey(), each.getValue());
- }
- }
+ if (superClass != null)
+ outputDirs.putAll(compileHierarchy(superClass));
+ for (Extends ext : type.getSupertypes())
+ outputDirs.putAll(compileHierarchy(ext.getType()));
return outputDirs;
}
@@ -157,8 +150,12 @@ public class Compiler {
SourceProcessor accum =
(name, src) -> { files.add(new SourceFile(name, src)); };
- for (Type dep : type.typeDependencies()) {
- dep.generateAsDependency(accum, type.methodDependencies());
+ Collection deps = type.typeDependencies(type.isFullCompilation());
+ for (Type dep : deps) {
+ if (type.isFullCompilation())
+ dep.generate(accum);
+ else
+ dep.generateAsDependency(accum, type.methodDependencies());
}
type.generate(accum);
@@ -185,7 +182,7 @@ public class Compiler {
StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
} catch (IOException e) {
throw new RuntimeException(
- "IOException encountered during compilation");
+ "IOException encountered during compilation", e);
}
Boolean result = ct.call();
if (result == Boolean.FALSE) {
diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java
index 22fbff7e5c4..ec7560191f0 100644
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java
@@ -48,7 +48,7 @@ public class SourceModel {
generate(pw);
return sw.toString();
}
- };
+ }
public static class AccessFlag extends Element {
private String flag;
@@ -125,6 +125,7 @@ public class SourceModel {
// (and thus will be present in stubs)
private Set methodDependencies;
private List typeDependencies;
+ private boolean fullCompilation;
protected Type(String name,
List flags, List params,
@@ -214,6 +215,14 @@ public class SourceModel {
methodDependencies.add(m);
}
+ public boolean isFullCompilation() {
+ return fullCompilation;
+ }
+
+ public void setFullCompilation(boolean fullCompilation) {
+ this.fullCompilation = fullCompilation;
+ }
+
// Convenience method for creating an Extends object using this
// class and specified type arguments.
public Extends with(String ... args) {
@@ -255,14 +264,23 @@ public class SourceModel {
pw.println("}");
}
- public Collection typeDependencies() {
+ public Collection typeDependencies(boolean recursive) {
HashMap dependencies = new HashMap<>();
Type superclass = getSuperclass();
if (superclass != null) {
dependencies.put(superclass.getName(), superclass);
+ if (recursive) {
+ for (Type t : superclass.typeDependencies(true))
+ dependencies.put(t.getName(), t);
+ }
}
- for (Extends e : getSupertypes())
+ for (Extends e : getSupertypes()) {
dependencies.put(e.getType().getName(), e.getType());
+ if (recursive) {
+ for (Type t : e.getType().typeDependencies(true))
+ dependencies.put(t.getName(), t);
+ }
+ }
// Do these last so that they override
for (Type t : this.typeDependencies)
dependencies.put(t.getName(), t);
diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java
index 18ea7cd9f62..3f34e73eb0e 100644
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java
@@ -198,7 +198,7 @@ public class TestHarness {
assertEquals(res, value);
}
} catch (InvocationTargetException | IllegalAccessException e) {
- fail("Unexpected exception thrown: " + e.getCause());
+ fail("Unexpected exception thrown: " + e.getCause(), e.getCause());
}
}
@@ -227,8 +227,7 @@ public class TestHarness {
* a return type of 'int', and no arguments.
*/
public void assertInvokeVirtualEquals(int value, Class target) {
- assertInvokeVirtualEquals(
- new Integer(value), target, stdCM, "-1");
+ assertInvokeVirtualEquals(value, target, stdCM, "-1");
}
/**
@@ -260,12 +259,31 @@ public class TestHarness {
Compiler compiler = compilerLocal.get();
compiler.setFlags(compilerFlags());
- assertInvokeInterfaceEquals(
- new Integer(value), target, new Extends(iface), stdAM);
+ assertInvokeInterfaceEquals(value, target, new Extends(iface), stdAM);
compiler.cleanup();
}
+ protected void assertInvokeInterfaceThrows(java.lang.Class extends Throwable> errorClass,
+ Class target, Extends iface, AbstractMethod method,
+ String... args) {
+ try {
+ assertInvokeInterfaceEquals(0, target, iface, method, args);
+ fail("Expected exception: " + errorClass);
+ }
+ catch (AssertionError e) {
+ Throwable cause = e.getCause();
+ if (cause == null)
+ throw e;
+ else if ((errorClass.isAssignableFrom(cause.getClass()))) {
+ // this is success
+ return;
+ }
+ else
+ throw e;
+ }
+ }
+
/**
* Creates a class which calls target::method(args) via invokevirtual,
* compiles and loads both the new class and 'target', and then invokes
@@ -300,7 +318,7 @@ public class TestHarness {
if (verboseLocal.get() == Boolean.TRUE) {
System.out.println(e.getCause());
}
- assertEquals(e.getCause().getClass(), exceptionType);
+ assertTrue(exceptionType.isAssignableFrom(e.getCause().getClass()));
}
compiler.cleanup();
}
diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java
index 77500f255e9..c7c46194ab2 100644
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,22 @@
package org.openjdk.tests.vm;
-import java.lang.reflect.*;
-import java.util.*;
-import java.io.File;
-import java.io.IOException;
-
-import org.testng.annotations.Test;
-import org.openjdk.tests.separate.*;
import org.openjdk.tests.separate.Compiler;
+import org.openjdk.tests.separate.TestHarness;
+import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-import static org.openjdk.tests.separate.SourceModel.*;
+import static org.openjdk.tests.separate.SourceModel.AbstractMethod;
+import static org.openjdk.tests.separate.SourceModel.AccessFlag;
import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.ConcreteMethod;
+import static org.openjdk.tests.separate.SourceModel.DefaultMethod;
+import static org.openjdk.tests.separate.SourceModel.Extends;
+import static org.openjdk.tests.separate.SourceModel.Interface;
+import static org.openjdk.tests.separate.SourceModel.MethodParameter;
+import static org.openjdk.tests.separate.SourceModel.TypeParameter;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
@Test(groups = "vm")
public class DefaultMethodsTest extends TestHarness {
@@ -186,7 +190,7 @@ public class DefaultMethodsTest extends TestHarness {
* TEST: D d = new D(); d.m() == 22;
* TEST: I i = new D(); i.m() == 22;
*/
- void testExistingInheritedOverride() {
+ public void testExistingInheritedOverride() {
Interface I = new Interface("I", DefaultMethod.std("99"));
Class C = new Class("C", I, ConcreteMethod.std("11"));
Class D = new Class("D", C, ConcreteMethod.std("22"));
@@ -255,15 +259,14 @@ public class DefaultMethodsTest extends TestHarness {
* interface J { default int m() { return 88; } }
* class C implements I, J {}
*
- * TEST: C c = new C(); c.m() throws AME
+ * TEST: C c = new C(); c.m() throws ICCE
*/
public void testConflict() {
- // debugTest();
Interface I = new Interface("I", DefaultMethod.std("99"));
Interface J = new Interface("J", DefaultMethod.std("88"));
Class C = new Class("C", I, J);
- assertThrows(AbstractMethodError.class, C);
+ assertThrows(IncompatibleClassChangeError.class, C);
}
/**
@@ -271,14 +274,14 @@ public class DefaultMethodsTest extends TestHarness {
* interface J { default int m() { return 88; } }
* class C implements I, J {}
*
- * TEST: C c = new C(); c.m() throws AME
+ * TEST: C c = new C(); c.m() == 88
*/
public void testAmbiguousReabstract() {
Interface I = new Interface("I", AbstractMethod.std());
Interface J = new Interface("J", DefaultMethod.std("88"));
Class C = new Class("C", I, J);
- assertThrows(AbstractMethodError.class, C);
+ assertInvokeVirtualEquals(88, C);
}
/**
@@ -390,19 +393,16 @@ public class DefaultMethodsTest extends TestHarness {
/**
* interface I { default int m(T t) { return 99; } }
- * Class C implements I { public int m() { return 88; } }
+ * Class C implements I
|