1.1 --- a/test/tools/javac/lambda/MethodReferenceParserTest.java Tue Jan 08 10:17:29 2013 +0100 1.2 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java Tue Jan 08 13:47:57 2013 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2011, 2013, 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 @@ -27,21 +27,21 @@ 1.11 * @bug 8003280 1.12 * @summary Add lambda tests 1.13 * Add parser support for method references 1.14 + * @library ../lib 1.15 + * @build JavacTestingAbstractThreadedTest 1.16 + * @run main MethodReferenceParserTest 1.17 */ 1.18 1.19 -import com.sun.source.util.JavacTask; 1.20 import java.net.URI; 1.21 import java.util.Arrays; 1.22 import javax.tools.Diagnostic; 1.23 -import javax.tools.JavaCompiler; 1.24 import javax.tools.JavaFileObject; 1.25 import javax.tools.SimpleJavaFileObject; 1.26 -import javax.tools.StandardJavaFileManager; 1.27 -import javax.tools.ToolProvider; 1.28 +import com.sun.source.util.JavacTask; 1.29 1.30 -public class MethodReferenceParserTest { 1.31 - 1.32 - static int checkCount = 0; 1.33 +public class MethodReferenceParserTest 1.34 + extends JavacTestingAbstractThreadedTest 1.35 + implements Runnable { 1.36 1.37 enum ReferenceKind { 1.38 METHOD_REF("#Q::#Gm"), 1.39 @@ -88,7 +88,8 @@ 1.40 this.contextTemplate = contextTemplate; 1.41 } 1.42 1.43 - String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) { 1.44 + String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, 1.45 + GenericKind gk, SubExprKind sk) { 1.46 return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); 1.47 } 1.48 } 1.49 @@ -165,25 +166,21 @@ 1.50 } 1.51 1.52 public static void main(String... args) throws Exception { 1.53 - 1.54 - //create default shared JavaCompiler - reused across multiple compilations 1.55 - JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 1.56 - StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 1.57 - 1.58 for (ReferenceKind rk : ReferenceKind.values()) { 1.59 for (QualifierKind qk : QualifierKind.values()) { 1.60 for (GenericKind gk : GenericKind.values()) { 1.61 for (SubExprKind sk : SubExprKind.values()) { 1.62 for (ExprKind ek : ExprKind.values()) { 1.63 for (ContextKind ck : ContextKind.values()) { 1.64 - new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm); 1.65 + pool.execute(new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck)); 1.66 } 1.67 } 1.68 } 1.69 } 1.70 } 1.71 } 1.72 - System.out.println("Total check executed: " + checkCount); 1.73 + 1.74 + checkAfterExec(); 1.75 } 1.76 1.77 ReferenceKind rk; 1.78 @@ -227,19 +224,21 @@ 1.79 } 1.80 } 1.81 1.82 - void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { 1.83 - JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, 1.84 + @Override 1.85 + public void run() { 1.86 + JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, 1.87 null, null, Arrays.asList(source)); 1.88 try { 1.89 ct.parse(); 1.90 } catch (Throwable ex) { 1.91 - throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true)); 1.92 + processException(ex); 1.93 + return; 1.94 } 1.95 check(); 1.96 } 1.97 1.98 void check() { 1.99 - checkCount++; 1.100 + checkCount.incrementAndGet(); 1.101 1.102 if (diagChecker.errorFound != rk.erroneous()) { 1.103 throw new Error("invalid diagnostics for source:\n" + 1.104 @@ -259,4 +258,5 @@ 1.105 } 1.106 } 1.107 } 1.108 + 1.109 }