test/tools/javac/T8019486/WrongLVTForLambdaTest.java

changeset 2158
6cd16d8ed2b9
parent 1940
b8610a65fbf9
     1.1 --- a/test/tools/javac/T8019486/WrongLVTForLambdaTest.java	Tue Oct 22 13:54:49 2013 +0100
     1.2 +++ b/test/tools/javac/T8019486/WrongLVTForLambdaTest.java	Tue Oct 22 16:53:21 2013 -0700
     1.3 @@ -61,8 +61,6 @@
     1.4          {9,           0},       //number -> number / 1
     1.5      };
     1.6  
     1.7 -    static final String methodToLookFor = "lambda$0";
     1.8 -
     1.9      public static void main(String[] args) throws Exception {
    1.10          new WrongLVTForLambdaTest().run();
    1.11      }
    1.12 @@ -70,7 +68,7 @@
    1.13      void run() throws Exception {
    1.14          compileTestClass();
    1.15          checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
    1.16 -                "Foo.class").toUri()), methodToLookFor);
    1.17 +                "Foo.class").toUri()));
    1.18      }
    1.19  
    1.20      void compileTestClass() throws Exception {
    1.21 @@ -79,12 +77,12 @@
    1.22          ToolBox.javac(javacSuccessArgs);
    1.23      }
    1.24  
    1.25 -    void checkClassFile(final File cfile, String methodToFind) throws Exception {
    1.26 +    void checkClassFile(final File cfile) throws Exception {
    1.27          ClassFile classFile = ClassFile.read(cfile);
    1.28 -        boolean methodFound = false;
    1.29 +        int methodsFound = 0;
    1.30          for (Method method : classFile.methods) {
    1.31 -            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
    1.32 -                methodFound = true;
    1.33 +            if (method.getName(classFile.constant_pool).startsWith("lambda$")) {
    1.34 +                ++methodsFound;
    1.35                  Code_attribute code = (Code_attribute) method.attributes.get("Code");
    1.36                  LineNumberTable_attribute lnt =
    1.37                          (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
    1.38 @@ -101,7 +99,7 @@
    1.39                  }
    1.40              }
    1.41          }
    1.42 -        Assert.check(methodFound, "The seek method was not found");
    1.43 +        Assert.check(methodsFound == 1, "Expected to find one lambda method, found " + methodsFound);
    1.44      }
    1.45  
    1.46      void error(String msg) {

mercurial