1.1 --- a/test/tools/javac/processing/model/element/TestAnonClassNames.java Wed Mar 16 09:41:30 2011 -0700 1.2 +++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java Wed Mar 16 17:21:52 2011 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2010, 2011, 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 @@ -23,7 +23,7 @@ 1.11 1.12 /* 1.13 * @test 1.14 - * @bug 6449781 1.15 + * @bug 6449781 6930508 1.16 * @summary Test that reported names of anonymous classes are non-null. 1.17 * @author Joseph D. Darcy 1.18 * @library ../../../lib 1.19 @@ -93,6 +93,7 @@ 1.20 TestAnonClassNames.class, 1.21 }; 1.22 1.23 + List<String> names = new ArrayList<String>(); 1.24 for(Class<?> clazz : classes) { 1.25 String name = clazz.getName(); 1.26 Nesting anno = clazz.getAnnotation(Nesting.class); 1.27 @@ -100,7 +101,14 @@ 1.28 clazz.getName(), 1.29 anno == null ? "(unset/ANONYMOUS)" : anno.value()); 1.30 testClassName(name); 1.31 + names.add(name); 1.32 } 1.33 + 1.34 + // test all names together 1.35 + testClassNames(names); 1.36 + 1.37 + if (errors > 0) 1.38 + throw new RuntimeException(errors + " errors occurred"); 1.39 } 1.40 1.41 /** 1.42 @@ -109,15 +117,23 @@ 1.43 * input classes are modeled as elements. 1.44 */ 1.45 static void testClassName(String className) { 1.46 - JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); 1.47 - List<String> classNames = new ArrayList<String>(); 1.48 - classNames.add(className); 1.49 + testClassNames(Arrays.asList(className)); 1.50 + } 1.51 + 1.52 + /** 1.53 + * Perform annotation processing on a list of class file names and verify 1.54 + * the existence of different flavors of class names when the 1.55 + * input classes are modeled as elements. 1.56 + */ 1.57 + static void testClassNames(List<String> classNames) { 1.58 + System.out.println("test: " + classNames); 1.59 1.60 List<String> options = new ArrayList<String>(); 1.61 options.add("-proc:only"); 1.62 options.add("-classpath"); 1.63 options.add(System.getProperty("test.classes")); 1.64 1.65 + JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); 1.66 JavaCompiler.CompilationTask compileTask = 1.67 javaCompiler.getTask(null, // Output 1.68 null, // File manager 1.69 @@ -130,9 +146,16 @@ 1.70 compileTask.setProcessors(processors); 1.71 Boolean goodResult = compileTask.call(); 1.72 if (!goodResult) { 1.73 - throw new RuntimeException("Errors found during compile."); 1.74 + error("Errors found during compile."); 1.75 } 1.76 } 1.77 + 1.78 + static int errors = 0; 1.79 + 1.80 + static void error(String msg) { 1.81 + System.out.println("Error: " + msg); 1.82 + errors++; 1.83 + } 1.84 } 1.85 1.86 @Retention(RUNTIME)