langtools/test/tools/javac/lambda/lambdaNaming/TestNonSerializableLambdaNameStability.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    26  * @bug 8067422
    26  * @bug 8067422
    27  * @summary Check that the lambda names are not unnecessarily unstable
    27  * @summary Check that the lambda names are not unnecessarily unstable
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules jdk.jdeps/com.sun.tools.classfile
    29  * @modules jdk.jdeps/com.sun.tools.classfile
    30  *          jdk.compiler/com.sun.tools.javac.api
    30  *          jdk.compiler/com.sun.tools.javac.api
    31  *          jdk.compiler/com.sun.tools.javac.file
       
    32  *          jdk.compiler/com.sun.tools.javac.main
    31  *          jdk.compiler/com.sun.tools.javac.main
    33  *          jdk.jdeps/com.sun.tools.javap
    32  *          jdk.jdeps/com.sun.tools.javap
    34  * @build ToolBox
    33  * @build toolbox.ToolBox toolbox.JavacTask
    35  * @run main TestNonSerializableLambdaNameStability
    34  * @run main TestNonSerializableLambdaNameStability
    36  */
    35  */
    37 
    36 
    38 import com.sun.tools.classfile.ClassFile;
       
    39 import com.sun.tools.classfile.Method;
       
    40 import java.io.ByteArrayInputStream;
    37 import java.io.ByteArrayInputStream;
    41 import java.io.InputStream;
    38 import java.io.InputStream;
    42 import java.util.ArrayList;
    39 import java.util.ArrayList;
    43 import java.util.List;
    40 import java.util.List;
    44 import javax.tools.StandardLocation;
    41 import javax.tools.StandardLocation;
       
    42 
       
    43 import com.sun.tools.classfile.ClassFile;
       
    44 import com.sun.tools.classfile.Method;
       
    45 
       
    46 import toolbox.JavacTask;
       
    47 import toolbox.ToolBox;
    45 
    48 
    46 public class TestNonSerializableLambdaNameStability {
    49 public class TestNonSerializableLambdaNameStability {
    47 
    50 
    48     public static void main(String... args) throws Exception {
    51     public static void main(String... args) throws Exception {
    49         new TestNonSerializableLambdaNameStability().run();
    52         new TestNonSerializableLambdaNameStability().run();
    69         }
    72         }
    70 
    73 
    71         ToolBox tb = new ToolBox();
    74         ToolBox tb = new ToolBox();
    72 
    75 
    73         try (ToolBox.MemoryFileManager fm = new ToolBox.MemoryFileManager()) {
    76         try (ToolBox.MemoryFileManager fm = new ToolBox.MemoryFileManager()) {
    74             tb.new JavacTask()
    77             new JavacTask(tb)
    75               .sources(sources.toArray(new String[sources.size()]))
    78               .sources(sources.toArray(new String[sources.size()]))
    76               .fileManager(fm)
    79               .fileManager(fm)
    77               .run();
    80               .run();
    78 
    81 
    79             for (String file : fm.files.get(StandardLocation.CLASS_OUTPUT).keySet()) {
    82             for (String file : fm.getFileNames(StandardLocation.CLASS_OUTPUT)) {
    80                 byte[] fileBytes = fm.getFileBytes(StandardLocation.CLASS_OUTPUT, file);
    83                 byte[] fileBytes = fm.getFileBytes(StandardLocation.CLASS_OUTPUT, file);
    81                 try (InputStream in = new ByteArrayInputStream(fileBytes)) {
    84                 try (InputStream in = new ByteArrayInputStream(fileBytes)) {
    82                     boolean foundLambdaMethod = false;
    85                     boolean foundLambdaMethod = false;
    83                     ClassFile cf = ClassFile.read(in);
    86                     ClassFile cf = ClassFile.read(in);
    84                     StringBuilder seenMethods = new StringBuilder();
    87                     StringBuilder seenMethods = new StringBuilder();