Fri, 24 Apr 2020 03:58:51 +0100
Merge
jjg@528 | 1 | /* |
jjg@953 | 2 | * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
jjg@528 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@528 | 4 | * |
jjg@528 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@528 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@528 | 7 | * published by the Free Software Foundation. |
jjg@528 | 8 | * |
jjg@528 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@528 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@528 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@528 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@528 | 13 | * accompanied this code). |
jjg@528 | 14 | * |
jjg@528 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@528 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@528 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@528 | 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@528 | 22 | */ |
jjg@528 | 23 | |
jjg@528 | 24 | /* |
jjg@528 | 25 | * @test |
jjg@528 | 26 | * @bug 6937244 |
jjg@528 | 27 | * @summary fields display with JVMS names, not Java names |
jjg@528 | 28 | */ |
jjg@528 | 29 | |
jjg@528 | 30 | import java.io.*; |
jjg@528 | 31 | import java.util.*; |
jjg@528 | 32 | |
jjg@528 | 33 | public class T6937244A { |
jjg@528 | 34 | public static void main(String[] args) throws Exception { |
jjg@528 | 35 | new T6937244A().run(); |
jjg@528 | 36 | } |
jjg@528 | 37 | |
jjg@528 | 38 | void run() throws Exception { |
jjg@528 | 39 | StringWriter sw = new StringWriter(); |
jjg@528 | 40 | PrintWriter pw = new PrintWriter(sw); |
jjg@528 | 41 | String[] args = { "Test" }; |
jjg@528 | 42 | int rc = com.sun.tools.javap.Main.run(args, pw); |
jjg@528 | 43 | pw.close(); |
jjg@528 | 44 | String out = sw.toString(); |
jjg@528 | 45 | System.err.println(out); |
jjg@528 | 46 | if (rc != 0) |
jjg@528 | 47 | throw new Exception("unexpected exit from javap: " + rc); |
jjg@528 | 48 | |
jjg@528 | 49 | int count = 0; |
jjg@528 | 50 | |
jjg@528 | 51 | for (String line: out.split("[\r\n]+")) { |
jjg@953 | 52 | if (line.contains("implements")) { |
jjg@953 | 53 | verify(line, "implements java.util.List<java.lang.String>"); |
jjg@528 | 54 | count++; |
jjg@528 | 55 | } |
jjg@528 | 56 | |
jjg@528 | 57 | if (line.contains("field")) { |
jjg@528 | 58 | verify(line, "java.util.List<java.lang.String> field"); |
jjg@528 | 59 | count++; |
jjg@528 | 60 | } |
jjg@528 | 61 | |
jjg@528 | 62 | if (line.contains("method")) { |
jjg@528 | 63 | verify(line, "java.util.List<java.lang.String> method(java.util.List<java.lang.String>) throws java.lang.Exception"); |
jjg@528 | 64 | count++; |
jjg@528 | 65 | } |
jjg@528 | 66 | } |
jjg@528 | 67 | |
jjg@528 | 68 | // final backstop check |
jjg@528 | 69 | if (out.contains("/")) |
jjg@528 | 70 | throw new Exception("unexpected \"/\" in output"); |
jjg@528 | 71 | |
jjg@528 | 72 | if (count != 3) |
jjg@528 | 73 | throw new Exception("wrong number of matches found: " + count); |
jjg@528 | 74 | } |
jjg@528 | 75 | |
jjg@528 | 76 | void verify(String line, String expect) throws Exception { |
jjg@528 | 77 | if (!line.contains(expect)) { |
jjg@528 | 78 | System.err.println("line: " + line); |
jjg@528 | 79 | System.err.println("expect: " + expect); |
jjg@528 | 80 | throw new Exception("expected string not found in line"); |
jjg@528 | 81 | } |
jjg@528 | 82 | } |
jjg@528 | 83 | } |
jjg@528 | 84 | |
jjg@528 | 85 | |
jjg@528 | 86 | abstract class Test implements List<String> { |
jjg@528 | 87 | public List<String> field; |
jjg@528 | 88 | public List<String> method(List<String> arg) throws Exception { return null; } |
jjg@528 | 89 | } |
jjg@528 | 90 |