< prev index next >

test/langtools/tools/javac/classfiles/attributes/Synthetic/BridgeMethodsForLambdaTest.java

Print this page




  27  * @summary Checking ACC_SYNTHETIC flag is generated for bridge method
  28  *          generated for lambda expressions and method references.
  29  * @modules jdk.compiler/com.sun.tools.javac.api
  30  *          jdk.compiler/com.sun.tools.javac.main
  31  *          jdk.jdeps/com.sun.tools.classfile
  32  * @library /tools/lib /tools/javac/lib ../lib
  33  * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase
  34  * @build SyntheticTestDriver ExpectedClass ExpectedClasses
  35  * @compile -XDdeduplicateLambdas=false BridgeMethodsForLambdaTest.java
  36  * @run main SyntheticTestDriver BridgeMethodsForLambdaTest
  37  */
  38 
  39 import java.util.Comparator;
  40 import java.util.stream.IntStream;
  41 
  42 /**
  43  * Synthetic members:
  44  * 1. inner class for Inner1.
  45  * 2. method for () -> {} in Inner1
  46  * 3. method for () -> {} in Inner2
  47  * 4. method references to private methods.
  48  * 5. method for super::function()
  49  * 6. method references to private static methods.
  50  * 7. access method for private method function().
  51  * 8. access method for private static method staticFunction().
  52  * 9. method reference to vararg method.
  53  * 10. method reference to array's method.
  54  * 11. constructors for Inner1 and Inner2.
  55  */
  56 @ExpectedClass(className = "BridgeMethodsForLambdaTest",
  57         expectedMethods = {"<init>()", "<clinit>()", "function(java.lang.Integer[])"},
  58         expectedNumberOfSyntheticMethods = 6)
  59 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner1",
  60         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()", "run()"},
  61         expectedFields = "lambda1",
  62         expectedNumberOfSyntheticMethods = 1,
  63         expectedNumberOfSyntheticFields = 1)
  64 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner2",
  65         expectedMethods = {"<init>()", "staticFunction()"},
  66         expectedFields = "lambda1",
  67         expectedNumberOfSyntheticMethods = 1)
  68 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner3",
  69         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()"},
  70         expectedNumberOfSyntheticFields = 1)
  71 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner4",
  72         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()"},
  73         expectedNumberOfSyntheticMethods = 1,
  74         expectedNumberOfSyntheticFields = 1)
  75 public class BridgeMethodsForLambdaTest {
  76 
  77     private class Inner1 implements Runnable {
  78         private Inner1() {




  27  * @summary Checking ACC_SYNTHETIC flag is generated for bridge method
  28  *          generated for lambda expressions and method references.
  29  * @modules jdk.compiler/com.sun.tools.javac.api
  30  *          jdk.compiler/com.sun.tools.javac.main
  31  *          jdk.jdeps/com.sun.tools.classfile
  32  * @library /tools/lib /tools/javac/lib ../lib
  33  * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase
  34  * @build SyntheticTestDriver ExpectedClass ExpectedClasses
  35  * @compile -XDdeduplicateLambdas=false BridgeMethodsForLambdaTest.java
  36  * @run main SyntheticTestDriver BridgeMethodsForLambdaTest
  37  */
  38 
  39 import java.util.Comparator;
  40 import java.util.stream.IntStream;
  41 
  42 /**
  43  * Synthetic members:
  44  * 1. inner class for Inner1.
  45  * 2. method for () -> {} in Inner1
  46  * 3. method for () -> {} in Inner2
  47  * 4. method for super::function()
  48  * 5. method reference to vararg method.
  49  * 6. method reference to array's method.
  50  * 7. constructors for Inner1 and Inner2.




  51  */
  52 @ExpectedClass(className = "BridgeMethodsForLambdaTest",
  53         expectedMethods = {"<init>()", "<clinit>()", "function(java.lang.Integer[])"},
  54         expectedNumberOfSyntheticMethods = 3)
  55 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner1",
  56         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()", "run()"},
  57         expectedFields = "lambda1",
  58         expectedNumberOfSyntheticMethods = 1,
  59         expectedNumberOfSyntheticFields = 1)
  60 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner2",
  61         expectedMethods = {"<init>()", "staticFunction()"},
  62         expectedFields = "lambda1",
  63         expectedNumberOfSyntheticMethods = 1)
  64 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner3",
  65         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()"},
  66         expectedNumberOfSyntheticFields = 1)
  67 @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner4",
  68         expectedMethods = {"<init>(BridgeMethodsForLambdaTest)", "function()"},
  69         expectedNumberOfSyntheticMethods = 1,
  70         expectedNumberOfSyntheticFields = 1)
  71 public class BridgeMethodsForLambdaTest {
  72 
  73     private class Inner1 implements Runnable {
  74         private Inner1() {


< prev index next >