Mon, 08 Apr 2013 15:53:08 +0100
8010404: Lambda debugging: redundant LineNumberTable entry for lambda capture
Summary: Ignore indy entries in LineNumberTable
Reviewed-by: jjg
jjg@376 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
jjg@376 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@376 | 4 | * |
jjg@376 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@376 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@376 | 7 | * published by the Free Software Foundation. |
jjg@376 | 8 | * |
jjg@376 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@376 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@376 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@376 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@376 | 13 | * accompanied this code). |
jjg@376 | 14 | * |
jjg@376 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@376 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@376 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@376 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jjg@376 | 22 | */ |
jjg@376 | 23 | |
jjg@376 | 24 | import java.io.File; |
jjg@376 | 25 | import java.io.PrintWriter; |
jjg@376 | 26 | import java.io.StringWriter; |
jjg@376 | 27 | import java.util.ArrayList; |
jjg@376 | 28 | import java.util.List; |
jjg@376 | 29 | |
jjg@376 | 30 | /* |
jjg@376 | 31 | * @test |
jjg@376 | 32 | * @bug 6873849 |
jjg@376 | 33 | * @summary suppress notes generated by javac |
jjg@376 | 34 | */ |
jjg@376 | 35 | |
jjg@376 | 36 | public class T6873849 { |
jjg@376 | 37 | public static void main(String... args) throws Exception { |
jjg@376 | 38 | new T6873849().run(); |
jjg@376 | 39 | } |
jjg@376 | 40 | |
jjg@376 | 41 | public void run() throws Exception { |
jjg@376 | 42 | test(null, "- compiler.note.unchecked.filename: T6873849.java" + newline + |
jjg@376 | 43 | "- compiler.note.unchecked.recompile" + newline); |
jjg@376 | 44 | test("-XDsuppressNotes", ""); |
jjg@376 | 45 | } |
jjg@376 | 46 | |
jjg@376 | 47 | void test(String opt, String expect) throws Exception { |
jjg@376 | 48 | List<String> args = new ArrayList<String>(); |
jjg@376 | 49 | if (opt != null) |
jjg@376 | 50 | args.add(opt); |
jjg@376 | 51 | args.add("-d"); |
jjg@376 | 52 | args.add(testClasses.getPath()); |
jjg@376 | 53 | args.add("-XDrawDiagnostics"); |
jjg@376 | 54 | args.add(new File(testSrc, "T6873849.java").getPath()); |
jjg@376 | 55 | StringWriter sw = new StringWriter(); |
jjg@376 | 56 | PrintWriter pw = new PrintWriter(sw); |
jjg@376 | 57 | System.err.println("compile: " + args); |
jjg@376 | 58 | int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); |
jjg@376 | 59 | pw.close(); |
jjg@376 | 60 | String out = sw.toString(); |
jjg@376 | 61 | System.out.println(out); |
jjg@376 | 62 | if (rc != 0) |
jjg@376 | 63 | throw new Exception("compilation failed unexpectedly"); |
jjg@376 | 64 | if (!out.equals(expect)) |
jjg@376 | 65 | throw new Exception("unexpected output from compiler"); |
jjg@376 | 66 | } |
jjg@376 | 67 | |
jjg@376 | 68 | void m(List t) { |
jjg@376 | 69 | // force a note about unchecked usage |
jjg@376 | 70 | t.add(new Object()); |
jjg@376 | 71 | } |
jjg@376 | 72 | |
jjg@376 | 73 | private File testSrc = new File(System.getProperty("test.src", ".")); |
jjg@376 | 74 | private File testClasses = new File(System.getProperty("test.classes", ".")); |
jjg@376 | 75 | private String newline = System.getProperty("line.separator"); |
jjg@376 | 76 | } |