langtools/test/tools/javap/T6729471.java
changeset 27579 d1a63c99cdd5
parent 27323 babdaa819add
child 30730 d3ce7619db2c
--- a/langtools/test/tools/javap/T6729471.java	Tue Nov 18 15:25:18 2014 -0800
+++ b/langtools/test/tools/javap/T6729471.java	Wed Dec 03 14:25:46 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,19 +26,23 @@
  * @test
  * @bug 6729471
  * @summary javap does not output inner interfaces of an interface
+ * @library /tools/lib
+ * @build ToolBox
+ * @run main T6729471
  */
 
 import java.io.*;
 import java.net.*;
 import java.util.*;
+import javax.tools.*;
 
 public class T6729471
 {
-    public static void main(String... args) {
+    public static void main(String... args) throws IOException {
         new T6729471().run();
     }
 
-    void run() {
+    void run() throws IOException {
         File testClasses = new File(System.getProperty("test.classes"));
 
         // simple class
@@ -57,34 +61,31 @@
         verify(new File(testClasses, "T6729471.class").toURI().toString(),
                 "public static void main(java.lang.String...)");
 
-        // jar url: rt.jar
-        File java_home = new File(System.getProperty("java.home"));
-        if (java_home.getName().equals("jre"))
-            java_home = java_home.getParentFile();
-        File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar");
+        // jar url
+        File testJar = createJar("test.jar", "java.util.*");
         try {
-            verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class",
+            verify("jar:" + testJar.toURL() + "!/java/util/Map.class",
                 "public abstract boolean containsKey(java.lang.Object)");
         } catch (MalformedURLException e) {
             error(e.toString());
         }
 
-        // jar url: ct.sym, if it exists
-        File ct_sym = new File(new File(java_home, "lib"), "ct.sym");
-        if (ct_sym.exists()) {
-            try {
-                verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class",
-                    "public abstract boolean containsKey(java.lang.Object)");
-            } catch (MalformedURLException e) {
-                error(e.toString());
-            }
-        } else
-            System.err.println("warning: ct.sym not found");
-
         if (errors > 0)
             throw new Error(errors + " found.");
     }
 
+    File createJar(String name, String... paths) throws IOException {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        try (JavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+            File f = new File(name);
+            ToolBox tb = new ToolBox();
+            tb.new JarTask(f.getPath())
+                .files(fm, StandardLocation.PLATFORM_CLASS_PATH, paths)
+                .run();
+            return f;
+        }
+    }
+
     void verify(String className, String... expects) {
         String output = javap(className);
         for (String expect: expects) {