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@38 | 1 | /* |
ohair@798 | 2 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
jjg@38 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@38 | 4 | * |
jjg@38 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@38 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@38 | 7 | * published by the Free Software Foundation. |
jjg@38 | 8 | * |
jjg@38 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@38 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@38 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@38 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@38 | 13 | * accompanied this code). |
jjg@38 | 14 | * |
jjg@38 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@38 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@38 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@38 | 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@38 | 22 | */ |
jjg@38 | 23 | |
jjg@38 | 24 | /* |
jjg@38 | 25 | * @test |
jjg@38 | 26 | * @bug 6705935 |
jjg@38 | 27 | * @summary javac reports path name of entry in ZipFileIndex incorectly |
jjg@38 | 28 | */ |
jjg@38 | 29 | |
jjg@38 | 30 | import java.io.*; |
jjg@38 | 31 | import java.util.*; |
jjg@38 | 32 | import javax.tools.*; |
jjg@50 | 33 | import com.sun.tools.javac.file.*; |
jjg@714 | 34 | import com.sun.tools.javac.file.ZipArchive.ZipFileObject; |
jjg@714 | 35 | import com.sun.tools.javac.file.ZipFileIndexArchive.ZipFileIndexFileObject; |
jjg@38 | 36 | |
jjg@38 | 37 | public class T6705935 { |
jjg@38 | 38 | public static void main(String... args) throws Exception { |
jjg@38 | 39 | new T6705935().run(); |
jjg@38 | 40 | } |
jjg@38 | 41 | |
jjg@38 | 42 | public void run() throws Exception { |
jjg@38 | 43 | File java_home = new File(System.getProperty("java.home")); |
jjg@38 | 44 | if (java_home.getName().equals("jre")) |
jjg@38 | 45 | java_home = java_home.getParentFile(); |
jjg@38 | 46 | |
jjg@38 | 47 | JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
jjg@714 | 48 | StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); |
jjg@714 | 49 | //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH))); |
jjg@714 | 50 | |
jjg@38 | 51 | for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH, |
jjg@38 | 52 | "java.lang", |
jjg@38 | 53 | Collections.singleton(JavaFileObject.Kind.CLASS), |
jjg@38 | 54 | false)) { |
jjg@714 | 55 | test++; |
jjg@714 | 56 | |
jjg@714 | 57 | if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) { |
jjg@714 | 58 | System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName()); |
jjg@714 | 59 | skip++; |
jjg@714 | 60 | continue; |
jjg@714 | 61 | } |
jjg@714 | 62 | |
jjg@714 | 63 | //System.err.println(fo.getName()); |
jjg@415 | 64 | String p = fo.getName(); |
jjg@38 | 65 | int bra = p.indexOf("("); |
jjg@38 | 66 | int ket = p.indexOf(")"); |
jjg@38 | 67 | //System.err.println(bra + "," + ket + "," + p.length()); |
jjg@38 | 68 | if (bra == -1 || ket != p.length() -1) |
jjg@38 | 69 | throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length()); |
jjg@38 | 70 | String part1 = p.substring(0, bra); |
jjg@38 | 71 | String part2 = p.substring(bra + 1, ket); |
jjg@38 | 72 | //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home); |
jjg@38 | 73 | if (part1.equals(part2) || !part1.startsWith(java_home.getPath())) |
jjg@38 | 74 | throw new Exception("bad path: " + p); |
jjg@38 | 75 | |
jjg@38 | 76 | } |
jjg@714 | 77 | |
jjg@714 | 78 | if (test == 0) |
jjg@714 | 79 | throw new Exception("no files found"); |
jjg@714 | 80 | |
jjg@714 | 81 | if (skip == 0) |
jjg@714 | 82 | System.out.println(test + " files found"); |
jjg@714 | 83 | else |
jjg@714 | 84 | System.out.println(test + " files found, " + skip + " files skipped"); |
jjg@714 | 85 | |
jjg@714 | 86 | if (test == skip) |
jjg@714 | 87 | System.out.println("Warning: all files skipped; no platform classes found in zip files."); |
jjg@38 | 88 | } |
jjg@714 | 89 | |
jjg@714 | 90 | private <T> List<T> asList(Iterable<? extends T> items) { |
jjg@714 | 91 | List<T> list = new ArrayList<T>(); |
jjg@714 | 92 | for (T item: items) |
jjg@714 | 93 | list.add(item); |
jjg@714 | 94 | return list; |
jjg@714 | 95 | } |
jjg@714 | 96 | |
jjg@714 | 97 | private int skip; |
jjg@714 | 98 | private int test; |
jjg@38 | 99 | } |