94 } 95 File srcDir = new File(getVerifierDir(), "src"); 96 List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT)); 97 File tmpFile = File.createTempFile("javac", ".tmp"); 98 XCLASSES.mkdirs(); 99 FileOutputStream fos = null; 100 PrintStream ps = null; 101 try { 102 fos = new FileOutputStream(tmpFile); 103 ps = new PrintStream(fos); 104 for (File f : javaFileList) { 105 ps.println(f.getAbsolutePath()); 106 } 107 } finally { 108 close(ps); 109 close(fos); 110 } 111 112 compiler("-d", 113 XCLASSES.getName(), 114 "-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", 115 "@" + tmpFile.getAbsolutePath()); 116 117 jar("cvfe", 118 VerifierJar.getName(), 119 "sun.tools.pack.verify.Main", 120 "-C", 121 XCLASSES.getName(), 122 "."); 123 } 124 125 private static File getVerifierDir() { 126 File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME); 127 if (!srcDir.exists()) { 128 // if not available try one level above 129 srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME); 130 } 131 return srcDir; 132 } 133 134 static File getGoldenJar() { 135 return new File(new File(getVerifierDir(), "data"), "golden.jar"); 136 } 137 static void dirlist(File dir) { 138 File[] files = dir.listFiles(); 139 System.out.println("--listing " + dir.getAbsolutePath() + "---"); 140 for (File f : files) { 141 StringBuffer sb = new StringBuffer(); 142 sb.append(f.isDirectory() ? "d " : "- "); 143 sb.append(f.getName()); 144 System.out.println(sb); 145 } 146 } 147 static void doCompareVerify(File reference, File specimen) throws IOException { 148 init(); 149 List<String> cmds = new ArrayList<String>(); 150 cmds.add(getJavaCmd()); 151 cmds.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); 152 cmds.add("-cp"); 153 cmds.add(VerifierJar.getName()); 154 cmds.add("sun.tools.pack.verify.Main"); 155 cmds.add(reference.getAbsolutePath()); 156 cmds.add(specimen.getAbsolutePath()); 157 cmds.add("-O"); 158 runExec(cmds); 159 } 160 161 static void doCompareBitWise(File reference, File specimen) 162 throws IOException { 163 init(); 164 List<String> cmds = new ArrayList<String>(); 165 cmds.add(getJavaCmd()); 166 cmds.add("-cp"); 167 cmds.add(VerifierJar.getName()); 168 cmds.add("sun.tools.pack.verify.Main"); 169 cmds.add(reference.getName()); 170 cmds.add(specimen.getName()); 171 cmds.add("-O"); | 94 } 95 File srcDir = new File(getVerifierDir(), "src"); 96 List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT)); 97 File tmpFile = File.createTempFile("javac", ".tmp"); 98 XCLASSES.mkdirs(); 99 FileOutputStream fos = null; 100 PrintStream ps = null; 101 try { 102 fos = new FileOutputStream(tmpFile); 103 ps = new PrintStream(fos); 104 for (File f : javaFileList) { 105 ps.println(f.getAbsolutePath()); 106 } 107 } finally { 108 close(ps); 109 close(fos); 110 } 111 112 compiler("-d", 113 XCLASSES.getName(), 114 "--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", 115 "@" + tmpFile.getAbsolutePath()); 116 117 jar("cvfe", 118 VerifierJar.getName(), 119 "sun.tools.pack.verify.Main", 120 "-C", 121 XCLASSES.getName(), 122 "."); 123 } 124 125 private static File getVerifierDir() { 126 File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME); 127 if (!srcDir.exists()) { 128 // if not available try one level above 129 srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME); 130 } 131 return srcDir; 132 } 133 134 static File getGoldenJar() { 135 return new File(new File(getVerifierDir(), "data"), "golden.jar"); 136 } 137 static void dirlist(File dir) { 138 File[] files = dir.listFiles(); 139 System.out.println("--listing " + dir.getAbsolutePath() + "---"); 140 for (File f : files) { 141 StringBuffer sb = new StringBuffer(); 142 sb.append(f.isDirectory() ? "d " : "- "); 143 sb.append(f.getName()); 144 System.out.println(sb); 145 } 146 } 147 static void doCompareVerify(File reference, File specimen) throws IOException { 148 init(); 149 List<String> cmds = new ArrayList<String>(); 150 cmds.add(getJavaCmd()); 151 cmds.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); 152 cmds.add("-cp"); 153 cmds.add(VerifierJar.getName()); 154 cmds.add("sun.tools.pack.verify.Main"); 155 cmds.add(reference.getAbsolutePath()); 156 cmds.add(specimen.getAbsolutePath()); 157 cmds.add("-O"); 158 runExec(cmds); 159 } 160 161 static void doCompareBitWise(File reference, File specimen) 162 throws IOException { 163 init(); 164 List<String> cmds = new ArrayList<String>(); 165 cmds.add(getJavaCmd()); 166 cmds.add("-cp"); 167 cmds.add(VerifierJar.getName()); 168 cmds.add("sun.tools.pack.verify.Main"); 169 cmds.add(reference.getName()); 170 cmds.add(specimen.getName()); 171 cmds.add("-O"); |