1.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Wed Mar 19 17:42:22 2014 +0000 1.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Wed Jan 15 13:49:57 2014 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -30,6 +30,7 @@ 1.11 import java.lang.annotation.*; 1.12 import java.lang.reflect.*; 1.13 import java.util.ArrayList; 1.14 +import java.util.Arrays; 1.15 import java.util.Collections; 1.16 import java.util.HashMap; 1.17 import java.util.List; 1.18 @@ -51,6 +52,11 @@ 1.19 new Driver().runDriver(clazz.newInstance()); 1.20 } 1.21 1.22 + String[][] extraParamsCombinations = new String[][] { 1.23 + new String[] { }, 1.24 + new String[] { "-g" }, 1.25 + }; 1.26 + 1.27 protected void runDriver(Object object) throws Exception { 1.28 int passed = 0, failed = 0; 1.29 Class<?> clazz = object.getClass(); 1.30 @@ -65,18 +71,20 @@ 1.31 throw new IllegalArgumentException("Test method needs to return a string: " + method); 1.32 String testClass = testClassOf(method); 1.33 1.34 - try { 1.35 - String compact = (String)method.invoke(object); 1.36 - String fullFile = wrap(compact); 1.37 - ClassFile cf = compileAndReturn(fullFile, testClass); 1.38 - List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); 1.39 - ReferenceInfoUtil.compare(expected, actual, cf); 1.40 - out.println("PASSED: " + method.getName()); 1.41 - ++passed; 1.42 - } catch (Throwable e) { 1.43 - out.println("FAILED: " + method.getName()); 1.44 - out.println(" " + e.toString()); 1.45 - ++failed; 1.46 + for (String[] extraParams : extraParamsCombinations) { 1.47 + try { 1.48 + String compact = (String)method.invoke(object); 1.49 + String fullFile = wrap(compact); 1.50 + ClassFile cf = compileAndReturn(fullFile, testClass, extraParams); 1.51 + List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); 1.52 + ReferenceInfoUtil.compare(expected, actual, cf); 1.53 + out.println("PASSED: " + method.getName()); 1.54 + ++passed; 1.55 + } catch (Throwable e) { 1.56 + out.println("FAILED: " + method.getName()); 1.57 + out.println(" " + e.toString()); 1.58 + ++failed; 1.59 + } 1.60 } 1.61 } 1.62 1.63 @@ -156,7 +164,7 @@ 1.64 } 1.65 } 1.66 1.67 - private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception { 1.68 + private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception { 1.69 File source = writeTestFile(fullFile); 1.70 File clazzFile = compileTestFile(source, testClass); 1.71 return ClassFile.read(clazzFile); 1.72 @@ -170,8 +178,12 @@ 1.73 return f; 1.74 } 1.75 1.76 - protected File compileTestFile(File f, String testClass) { 1.77 - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() }); 1.78 + protected File compileTestFile(File f, String testClass, String... extraParams) { 1.79 + List<String> options = new ArrayList<>(); 1.80 + options.addAll(Arrays.asList("-source", "1.8")); 1.81 + options.addAll(Arrays.asList(extraParams)); 1.82 + options.add(f.getPath()); 1.83 + int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()])); 1.84 if (rc != 0) 1.85 throw new Error("compilation failed. rc=" + rc); 1.86 String path;