Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 34410 invoked from network); 25 Apr 2007 14:58:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Apr 2007 14:58:27 -0000 Received: (qmail 35503 invoked by uid 500); 25 Apr 2007 14:58:06 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 35367 invoked by uid 500); 25 Apr 2007 14:58:04 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 35138 invoked by uid 500); 25 Apr 2007 14:58:02 -0000 Received: (qmail 34789 invoked by uid 99); 25 Apr 2007 14:58:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 07:57:58 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 07:57:47 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8F9641A9838; Wed, 25 Apr 2007 07:57:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r532377 [1/3] - in /jakarta/commons/proper/jci/trunk: compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/ compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/ compilers/groovy/src/main/java/org/apache/commons/jci/... Date: Wed, 25 Apr 2007 14:57:24 -0000 To: commons-cvs@jakarta.apache.org From: niallp@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070425145726.8F9641A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: niallp Date: Wed Apr 25 07:57:21 2007 New Revision: 532377 URL: http://svn.apache.org/viewvc?view=rev&rev=532377 Log: Remove tab characters from source (no actual code changes) Modified: jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompilerSettings.java jakarta/commons/proper/jci/trunk/compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/EclipseJavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompilerSettings.java jakarta/commons/proper/jci/trunk/compilers/groovy/src/test/java/org/apache/commons/jci/compilers/GroovyJavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompilerSettings.java jakarta/commons/proper/jci/trunk/compilers/janino/src/test/java/org/apache/commons/jci/compilers/JaninoJavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacClassLoader.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacCompilationProblem.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompilerSettings.java jakarta/commons/proper/jci/trunk/compilers/javac/src/test/java/org/apache/commons/jci/compilers/JavacJavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199CompilationProblem.java jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199JavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/jsr199/src/test/java/org/apache/commons/jci/compilers/Jsr199JavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoCompilationProblem.java jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoJavaCompiler.java jakarta/commons/proper/jci/trunk/compilers/rhino/src/test/java/org/apache/commons/jci/compilers/RhinoJavaCompilerTestCase.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/compilers/AbstractJavaCompiler.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/compilers/CompilationResult.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/compilers/JavaCompiler.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/compilers/JavaCompilerSettings.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/CompilingListener.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/FileChangeListener.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadNotificationListener.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/problems/CompilationProblem.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/problems/CompilationProblemHandler.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/readers/ResourceReader.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/MemoryResourceStore.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/ResourceStore.java jakarta/commons/proper/jci/trunk/core/src/main/java/org/apache/commons/jci/utils/ConversionUtils.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/AbstractTestCase.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/CompilingClassLoaderTestCase.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/classes/ExtendedDump.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/classes/SimpleDump.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/readers/ResourceReaderTestCase.java jakarta/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/stores/ResourceStoreTestCase.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/commandline/CommandlineCompiler.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/configuration/Configurable.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/configuration/ConfigurationException.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/configuration/ConfigurationReloading.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/configuration/Something.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/serverpages/JspGenerator.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/serverpages/JspReader.java jakarta/commons/proper/jci/trunk/examples/src/main/java/org/apache/commons/jci/examples/serverpages/ServerPageServlet.java jakarta/commons/proper/jci/trunk/fam/src/main/java/org/apache/commons/jci/listeners/AbstractFilesystemAlterationListener.java jakarta/commons/proper/jci/trunk/fam/src/main/java/org/apache/commons/jci/monitor/FilesystemAlterationListener.java jakarta/commons/proper/jci/trunk/fam/src/main/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java jakarta/commons/proper/jci/trunk/fam/src/main/java/org/apache/commons/jci/monitor/FilesystemAlterationObserver.java jakarta/commons/proper/jci/trunk/fam/src/main/java/org/apache/commons/jci/monitor/FilesystemAlterationObserverImpl.java jakarta/commons/proper/jci/trunk/fam/src/test/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java Modified: jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompiler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompiler.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompiler.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompiler.java Wed Apr 25 07:57:21 2007 @@ -104,13 +104,13 @@ } public char[] getContents() { - final byte[] content = reader.getBytes(fileName); - - if (content == null) { - return null; - //throw new RuntimeException("resource " + fileName + " could not be found"); - } - + final byte[] content = reader.getBytes(fileName); + + if (content == null) { + return null; + //throw new RuntimeException("resource " + fileName + " could not be found"); + } + return new String(content).toCharArray(); } @@ -141,44 +141,44 @@ final String sourceFile = pSourceFiles[i]; if (pReader.isAvailable(sourceFile)) { - compilationUnits[i] = new CompilationUnit(pReader, sourceFile); + compilationUnits[i] = new CompilationUnit(pReader, sourceFile); log.debug("compiling " + sourceFile); } else { - // log.error("source not found " + sourceFile); - + // log.error("source not found " + sourceFile); + final CompilationProblem problem = new CompilationProblem() { - public int getEndColumn() { - return 0; - } - - public int getEndLine() { - return 0; - } - - public String getFileName() { - return sourceFile; - } - - public String getMessage() { - return "Source " + sourceFile + " could not be found"; - } - - public int getStartColumn() { - return 0; - } - - public int getStartLine() { - return 0; - } - - public boolean isError() { - return true; - } - - public String toString() { - return getMessage(); - } + public int getEndColumn() { + return 0; + } + + public int getEndLine() { + return 0; + } + + public String getFileName() { + return sourceFile; + } + + public String getMessage() { + return "Source " + sourceFile + " could not be found"; + } + + public int getStartColumn() { + return 0; + } + + public int getStartLine() { + return 0; + } + + public boolean isError() { + return true; + } + + public String toString() { + return getMessage(); + } }; if (problemHandler != null) { @@ -192,7 +192,7 @@ if (problems.size() > 0) { final CompilationProblem[] result = new CompilationProblem[problems.size()]; problems.toArray(result); - return new org.apache.commons.jci.compilers.CompilationResult(result); + return new org.apache.commons.jci.compilers.CompilationResult(result); } final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); @@ -210,7 +210,7 @@ //log.debug("finding compoundTypeName=" + result.toString()); - return findType(result.toString()); + return findType(result.toString()); } public NameEnvironmentAnswer findType( final char[] pTypeName, final char[][] pPackageName ) { @@ -220,22 +220,22 @@ result.append('.'); } -// log.debug("finding typeName=" + new String(typeName) + " packageName=" + result.toString()); +// log.debug("finding typeName=" + new String(typeName) + " packageName=" + result.toString()); - result.append(pTypeName); + result.append(pTypeName); return findType(result.toString()); } private NameEnvironmentAnswer findType( final String pClazzName ) { - - if (isPackage(pClazzName)) { - return null; - } - - log.debug("finding " + pClazzName); - - final String resourceName = ConversionUtils.convertClassToResourcePath(pClazzName); - + + if (isPackage(pClazzName)) { + return null; + } + + log.debug("finding " + pClazzName); + + final String resourceName = ConversionUtils.convertClassToResourcePath(pClazzName); + final byte[] clazzBytes = pStore.read(pClazzName); if (clazzBytes != null) { log.debug("loading from store " + pClazzName); @@ -250,12 +250,12 @@ } } - log.debug("not in store " + pClazzName); - + log.debug("not in store " + pClazzName); + final InputStream is = pClassLoader.getResourceAsStream(resourceName); if (is == null) { - log.debug("class " + pClazzName + " not found"); - return null; + log.debug("class " + pClazzName + " not found"); + return null; } final byte[] buffer = new byte[8192]; @@ -290,21 +290,21 @@ } private boolean isPackage( final String pClazzName ) { - - final InputStream is = pClassLoader.getResourceAsStream(ConversionUtils.convertClassToResourcePath(pClazzName)); - if (is != null) { - log.debug("found the class for " + pClazzName + "- no package"); - return false; - } - - // FIXME: this should not be tied to the extension - final String source = pClazzName.replace('.', '/') + ".java"; - if (pReader.isAvailable(source)) { - log.debug("found the source " + source + " for " + pClazzName + " - no package "); - return false; - } - - return true; + + final InputStream is = pClassLoader.getResourceAsStream(ConversionUtils.convertClassToResourcePath(pClazzName)); + if (is != null) { + log.debug("found the class for " + pClazzName + "- no package"); + return false; + } + + // FIXME: this should not be tied to the extension + final String source = pClazzName.replace('.', '/') + ".java"; + if (pReader.isAvailable(source)) { + log.debug("found the source " + source + " for " + pClazzName + " - no package "); + return false; + } + + return true; } public boolean isPackage( char[][] parentPackageName, char[] pPackageName ) { @@ -328,7 +328,7 @@ } public void cleanup() { - log.debug("cleanup"); + log.debug("cleanup"); } }; @@ -372,7 +372,7 @@ return new org.apache.commons.jci.compilers.CompilationResult(result); } - public JavaCompilerSettings createDefaultSettings() { - return defaultSettings; - } + public JavaCompilerSettings createDefaultSettings() { + return defaultSettings; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompilerSettings.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompilerSettings.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompilerSettings.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/eclipse/src/main/java/org/apache/commons/jci/compilers/EclipseJavaCompilerSettings.java Wed Apr 25 07:57:21 2007 @@ -32,24 +32,24 @@ final private Map defaultEclipseSettings = new HashMap(); public EclipseJavaCompilerSettings() { - defaultEclipseSettings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); - defaultEclipseSettings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); - defaultEclipseSettings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE); + defaultEclipseSettings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); + defaultEclipseSettings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); + defaultEclipseSettings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE); defaultEclipseSettings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); } public EclipseJavaCompilerSettings( final Map pMap ) { - defaultEclipseSettings.putAll(pMap); + defaultEclipseSettings.putAll(pMap); } Map getMap() { final Map map = new HashMap(defaultEclipseSettings); - - map.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.GENERATE); + + map.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.GENERATE); map.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); map.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); map.put(CompilerOptions.OPTION_Encoding, "UTF-8"); - + return map; } Modified: jakarta/commons/proper/jci/trunk/compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/EclipseJavaCompilerTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/EclipseJavaCompilerTestCase.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/EclipseJavaCompilerTestCase.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/eclipse/src/test/java/org/apache/commons/jci/compilers/EclipseJavaCompilerTestCase.java Wed Apr 25 07:57:21 2007 @@ -19,12 +19,12 @@ public final class EclipseJavaCompilerTestCase extends AbstractCompilerTestCase { - public String getCompilerName() { - return "eclipse"; - } + public String getCompilerName() { + return "eclipse"; + } - public JavaCompiler createJavaCompiler() { - return new EclipseJavaCompiler(); - } + public JavaCompiler createJavaCompiler() { + return new EclipseJavaCompiler(); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompiler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompiler.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompiler.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompiler.java Wed Apr 25 07:57:21 2007 @@ -52,7 +52,7 @@ private final GroovyJavaCompilerSettings defaultSettings; public GroovyJavaCompiler() { - defaultSettings = new GroovyJavaCompilerSettings(new CompilerConfiguration()); + defaultSettings = new GroovyJavaCompilerSettings(new CompilerConfiguration()); } public CompilationResult compile( @@ -63,7 +63,7 @@ final JavaCompilerSettings pSettings ) { - final CompilerConfiguration configuration = ((GroovyJavaCompilerSettings) pSettings).getCompilerConfiguration(); + final CompilerConfiguration configuration = ((GroovyJavaCompilerSettings) pSettings).getCompilerConfiguration(); final ErrorCollector collector = new ErrorCollector(configuration); final GroovyClassLoader groovyClassLoader = new GroovyClassLoader(pClassLoader); final CompilationUnit unit = new CompilationUnit(configuration, null, groovyClassLoader); @@ -126,7 +126,7 @@ return new CompilationResult(result); } - public JavaCompilerSettings createDefaultSettings() { - return defaultSettings; - } + public JavaCompilerSettings createDefaultSettings() { + return defaultSettings; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompilerSettings.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompilerSettings.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompilerSettings.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/groovy/src/main/java/org/apache/commons/jci/compilers/GroovyJavaCompilerSettings.java Wed Apr 25 07:57:21 2007 @@ -26,14 +26,14 @@ */ public final class GroovyJavaCompilerSettings extends JavaCompilerSettings { - private final CompilerConfiguration settings; - - public GroovyJavaCompilerSettings( final CompilerConfiguration pSettings ) { - settings = pSettings; - } - - public CompilerConfiguration getCompilerConfiguration() { - return settings; - } - + private final CompilerConfiguration settings; + + public GroovyJavaCompilerSettings( final CompilerConfiguration pSettings ) { + settings = pSettings; + } + + public CompilerConfiguration getCompilerConfiguration() { + return settings; + } + } Modified: jakarta/commons/proper/jci/trunk/compilers/groovy/src/test/java/org/apache/commons/jci/compilers/GroovyJavaCompilerTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/groovy/src/test/java/org/apache/commons/jci/compilers/GroovyJavaCompilerTestCase.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/groovy/src/test/java/org/apache/commons/jci/compilers/GroovyJavaCompilerTestCase.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/groovy/src/test/java/org/apache/commons/jci/compilers/GroovyJavaCompilerTestCase.java Wed Apr 25 07:57:21 2007 @@ -23,16 +23,16 @@ */ public final class GroovyJavaCompilerTestCase extends AbstractCompilerTestCase { - public String getCompilerName() { - return "groovy"; - } + public String getCompilerName() { + return "groovy"; + } - public JavaCompiler createJavaCompiler() { - return new GroovyJavaCompiler(); - } + public JavaCompiler createJavaCompiler() { + return new GroovyJavaCompiler(); + } + + public void testInternalClassCompile() throws Exception { + // FIXME: inner classes not supported in groovy? + } - public void testInternalClassCompile() throws Exception { - // FIXME: inner classes not supported in groovy? - } - } Modified: jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompiler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompiler.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompiler.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompiler.java Wed Apr 25 07:57:21 2007 @@ -143,7 +143,7 @@ public CompilationResult compile( final String[] pSourceNames, final ResourceReader pResourceReader, final ResourceStore pStore, final ClassLoader pClassLoader, final JavaCompilerSettings pSettings ) { - final Map classFilesByName = new HashMap(); + final Map classFilesByName = new HashMap(); final CompilingIClassLoader icl = new CompilingIClassLoader(pResourceReader, classFilesByName, pClassLoader); for (int i = 0; i < pSourceNames.length; i++) { @@ -164,9 +164,9 @@ return new CompilationResult(result); } - public JavaCompilerSettings createDefaultSettings() { - // FIXME - return null; - } + public JavaCompilerSettings createDefaultSettings() { + // FIXME + return null; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompilerSettings.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompilerSettings.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompilerSettings.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/janino/src/main/java/org/apache/commons/jci/compilers/JaninoJavaCompilerSettings.java Wed Apr 25 07:57:21 2007 @@ -18,5 +18,5 @@ package org.apache.commons.jci.compilers; public final class JaninoJavaCompilerSettings extends JavaCompilerSettings { - // TODO: implement the native janino compiler settings + // TODO: implement the native janino compiler settings } Modified: jakarta/commons/proper/jci/trunk/compilers/janino/src/test/java/org/apache/commons/jci/compilers/JaninoJavaCompilerTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/janino/src/test/java/org/apache/commons/jci/compilers/JaninoJavaCompilerTestCase.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/janino/src/test/java/org/apache/commons/jci/compilers/JaninoJavaCompilerTestCase.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/janino/src/test/java/org/apache/commons/jci/compilers/JaninoJavaCompilerTestCase.java Wed Apr 25 07:57:21 2007 @@ -23,12 +23,12 @@ */ public final class JaninoJavaCompilerTestCase extends AbstractCompilerTestCase { - public String getCompilerName() { - return "janino"; - } - - public JavaCompiler createJavaCompiler() { - return new JaninoJavaCompiler(); - } + public String getCompilerName() { + return "janino"; + } + + public JavaCompiler createJavaCompiler() { + return new JaninoJavaCompiler(); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileInputStreamProxy.java Wed Apr 25 07:57:21 2007 @@ -32,75 +32,75 @@ * @author tcurdt */ public final class FileInputStreamProxy extends InputStream { - - private final static ThreadLocal readerThreadLocal = new ThreadLocal(); - - private final InputStream in; - private final String name; - - public static void setResourceReader( final ResourceReader pReader ) { - readerThreadLocal.set(pReader); - } - - public FileInputStreamProxy(File pFile) throws FileNotFoundException { - this("" + pFile); - } - - public FileInputStreamProxy(FileDescriptor fdObj) { - throw new RuntimeException(); - } - - public FileInputStreamProxy(String pName) throws FileNotFoundException { - name = ConversionUtils.getResourceNameFromFileName(pName); - - final ResourceReader reader = (ResourceReader) readerThreadLocal.get(); - - if (reader == null) { - throw new RuntimeException("forgot to set the ResourceReader for this thread?"); - } - - final byte[] bytes = reader.getBytes(name); - - if (bytes == null) { - throw new FileNotFoundException(name); - } - - in = new ByteArrayInputStream(bytes); - } - - public int read() throws IOException { - return in.read(); - } - - public int available() throws IOException { - return in.available(); - } - - public void close() throws IOException { - in.close(); - } - - public synchronized void mark(int readlimit) { - in.mark(readlimit); - } - - public boolean markSupported() { - return in.markSupported(); - } - - public int read(byte[] b, int off, int len) throws IOException { - return in.read(b, off, len); - } - - public int read(byte[] b) throws IOException { - return in.read(b); - } - - public synchronized void reset() throws IOException { - in.reset(); - } - - public long skip(long n) throws IOException { - return in.skip(n); - } + + private final static ThreadLocal readerThreadLocal = new ThreadLocal(); + + private final InputStream in; + private final String name; + + public static void setResourceReader( final ResourceReader pReader ) { + readerThreadLocal.set(pReader); + } + + public FileInputStreamProxy(File pFile) throws FileNotFoundException { + this("" + pFile); + } + + public FileInputStreamProxy(FileDescriptor fdObj) { + throw new RuntimeException(); + } + + public FileInputStreamProxy(String pName) throws FileNotFoundException { + name = ConversionUtils.getResourceNameFromFileName(pName); + + final ResourceReader reader = (ResourceReader) readerThreadLocal.get(); + + if (reader == null) { + throw new RuntimeException("forgot to set the ResourceReader for this thread?"); + } + + final byte[] bytes = reader.getBytes(name); + + if (bytes == null) { + throw new FileNotFoundException(name); + } + + in = new ByteArrayInputStream(bytes); + } + + public int read() throws IOException { + return in.read(); + } + + public int available() throws IOException { + return in.available(); + } + + public void close() throws IOException { + in.close(); + } + + public synchronized void mark(int readlimit) { + in.mark(readlimit); + } + + public boolean markSupported() { + return in.markSupported(); + } + + public int read(byte[] b, int off, int len) throws IOException { + return in.read(b, off, len); + } + + public int read(byte[] b) throws IOException { + return in.read(b); + } + + public synchronized void reset() throws IOException { + in.reset(); + } + + public long skip(long n) throws IOException { + return in.skip(n); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/FileOutputStreamProxy.java Wed Apr 25 07:57:21 2007 @@ -32,63 +32,63 @@ * @author tcurdt */ public final class FileOutputStreamProxy extends OutputStream { - - private final static ThreadLocal storeThreadLocal = new ThreadLocal(); - private final ByteArrayOutputStream out = new ByteArrayOutputStream(); - private final String name; - - - public static void setResourceStore( final ResourceStore pStore ) { - storeThreadLocal.set(pStore); - } - - - public FileOutputStreamProxy(File pFile, boolean append) throws FileNotFoundException { - this("" + pFile); - } - - public FileOutputStreamProxy(File pFile) throws FileNotFoundException { - this("" + pFile); - } - - public FileOutputStreamProxy(FileDescriptor fdObj) { - throw new RuntimeException(); - } - - public FileOutputStreamProxy(String pName, boolean append) throws FileNotFoundException { - this(pName); - } - - public FileOutputStreamProxy(String pName) throws FileNotFoundException { - name = ConversionUtils.getResourceNameFromFileName(pName); - } - - public void write(int value) throws IOException { - out.write(value); - } - - public void close() throws IOException { - out.close(); - - final ResourceStore store = (ResourceStore) storeThreadLocal.get(); - - if (store == null) { - throw new RuntimeException("forgot to set the ResourceStore for this thread?"); - } - - store.write(name, out.toByteArray()); - } - - public void flush() throws IOException { - out.flush(); - } - - public void write(byte[] b, int off, int len) throws IOException { - out.write(b, off, len); - } - - public void write(byte[] b) throws IOException { - out.write(b); - } + private final static ThreadLocal storeThreadLocal = new ThreadLocal(); + + private final ByteArrayOutputStream out = new ByteArrayOutputStream(); + private final String name; + + + public static void setResourceStore( final ResourceStore pStore ) { + storeThreadLocal.set(pStore); + } + + + public FileOutputStreamProxy(File pFile, boolean append) throws FileNotFoundException { + this("" + pFile); + } + + public FileOutputStreamProxy(File pFile) throws FileNotFoundException { + this("" + pFile); + } + + public FileOutputStreamProxy(FileDescriptor fdObj) { + throw new RuntimeException(); + } + + public FileOutputStreamProxy(String pName, boolean append) throws FileNotFoundException { + this(pName); + } + + public FileOutputStreamProxy(String pName) throws FileNotFoundException { + name = ConversionUtils.getResourceNameFromFileName(pName); + } + + public void write(int value) throws IOException { + out.write(value); + } + + public void close() throws IOException { + out.close(); + + final ResourceStore store = (ResourceStore) storeThreadLocal.get(); + + if (store == null) { + throw new RuntimeException("forgot to set the ResourceStore for this thread?"); + } + + store.write(name, out.toByteArray()); + } + + public void flush() throws IOException { + out.flush(); + } + + public void write(byte[] b, int off, int len) throws IOException { + out.write(b, off, len); + } + + public void write(byte[] b) throws IOException { + out.write(b); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacClassLoader.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacClassLoader.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacClassLoader.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacClassLoader.java Wed Apr 25 07:57:21 2007 @@ -45,110 +45,110 @@ * @author tcurdt */ public final class JavacClassLoader extends URLClassLoader { - - private final Map loaded = new HashMap(); - - public JavacClassLoader( final ClassLoader pParent ) { - super(getToolsJar(), pParent); - } - - private static URL[] getToolsJar() { - try { - Class.forName("com.sun.tools.javac.Main"); - - // found - no addtional classpath entry required - return new URL[0]; - - } catch (Exception e) { - } - - // no compiler in current classpath, let's try to find the tools.jar - - String javaHome = System.getProperty("java.home"); - if (javaHome.toLowerCase(Locale.US).endsWith(File.separator + "jre")) { - javaHome = javaHome.substring(0, javaHome.length()-4); - } - - final File toolsJar = new File(javaHome + "/lib/tools.jar"); - - if (toolsJar.exists()) { - try { - return new URL[] { toolsJar.toURL() }; - } catch (MalformedURLException e) { - } - } - - final StringBuffer sb = new StringBuffer(); - sb.append("Could not find javac compiler class (should be in the tools.jar/classes.jar in your JRE/JDK). "); - sb.append("os.name").append('=').append(System.getProperty("os.name")).append(", "); - sb.append("os.version").append('=').append(System.getProperty("os.version")).append(", "); - sb.append("java.class.path").append('=').append(System.getProperty("java.class.path")); - - throw new RuntimeException(sb.toString()); - } - - protected Class findClass( final String name ) throws ClassNotFoundException { - - if (name.startsWith("java.")) { - return super.findClass(name); - } - - try { - - final Class clazz = (Class) loaded.get(name); - if (clazz != null) { - return clazz; - } - - final byte[] classBytes; - - if (name.startsWith("com.sun.tools.javac.")) { - final InputStream classStream = getResourceAsStream(name.replace('.', '/') + ".class"); - - final ClassWriter renamedCw = new ClassWriter(true, false); - new ClassReader(classStream).accept(new RenamingVisitor(new CheckClassAdapter(renamedCw), new ResourceRenamer() { - public String getNewNameFor(final String pOldName) { - if (pOldName.startsWith(FileOutputStream.class.getName())) { - return FileOutputStreamProxy.class.getName(); - } - if (pOldName.startsWith(FileInputStream.class.getName())) { - return FileInputStreamProxy.class.getName(); - } - return pOldName; - } - }), false); - - classBytes = renamedCw.toByteArray(); - - } else { - return super.findClass(name); - } - - final Class newClazz = defineClass(name, classBytes, 0, classBytes.length); - loaded.put(name, newClazz); - return newClazz; - } catch (IOException e) { - throw new ClassNotFoundException("", e); - } - } - - protected synchronized Class loadClass( final String classname, final boolean resolve ) throws ClassNotFoundException { - - Class theClass = findLoadedClass(classname); - if (theClass != null) { - return theClass; - } - - try { - theClass = findClass(classname); - } catch (ClassNotFoundException cnfe) { - theClass = getParent().loadClass(classname); - } - - if (resolve) { - resolveClass(theClass); - } - return theClass; - } + private final Map loaded = new HashMap(); + + public JavacClassLoader( final ClassLoader pParent ) { + super(getToolsJar(), pParent); + } + + private static URL[] getToolsJar() { + try { + Class.forName("com.sun.tools.javac.Main"); + + // found - no addtional classpath entry required + return new URL[0]; + + } catch (Exception e) { + } + + // no compiler in current classpath, let's try to find the tools.jar + + String javaHome = System.getProperty("java.home"); + if (javaHome.toLowerCase(Locale.US).endsWith(File.separator + "jre")) { + javaHome = javaHome.substring(0, javaHome.length()-4); + } + + final File toolsJar = new File(javaHome + "/lib/tools.jar"); + + if (toolsJar.exists()) { + try { + return new URL[] { toolsJar.toURL() }; + } catch (MalformedURLException e) { + } + } + + final StringBuffer sb = new StringBuffer(); + sb.append("Could not find javac compiler class (should be in the tools.jar/classes.jar in your JRE/JDK). "); + sb.append("os.name").append('=').append(System.getProperty("os.name")).append(", "); + sb.append("os.version").append('=').append(System.getProperty("os.version")).append(", "); + sb.append("java.class.path").append('=').append(System.getProperty("java.class.path")); + + throw new RuntimeException(sb.toString()); + } + + protected Class findClass( final String name ) throws ClassNotFoundException { + + if (name.startsWith("java.")) { + return super.findClass(name); + } + + try { + + final Class clazz = (Class) loaded.get(name); + if (clazz != null) { + return clazz; + } + + final byte[] classBytes; + + if (name.startsWith("com.sun.tools.javac.")) { + final InputStream classStream = getResourceAsStream(name.replace('.', '/') + ".class"); + + final ClassWriter renamedCw = new ClassWriter(true, false); + new ClassReader(classStream).accept(new RenamingVisitor(new CheckClassAdapter(renamedCw), new ResourceRenamer() { + public String getNewNameFor(final String pOldName) { + if (pOldName.startsWith(FileOutputStream.class.getName())) { + return FileOutputStreamProxy.class.getName(); + } + if (pOldName.startsWith(FileInputStream.class.getName())) { + return FileInputStreamProxy.class.getName(); + } + return pOldName; + } + }), false); + + classBytes = renamedCw.toByteArray(); + + } else { + return super.findClass(name); + } + + final Class newClazz = defineClass(name, classBytes, 0, classBytes.length); + loaded.put(name, newClazz); + return newClazz; + } catch (IOException e) { + throw new ClassNotFoundException("", e); + } + } + + protected synchronized Class loadClass( final String classname, final boolean resolve ) throws ClassNotFoundException { + + Class theClass = findLoadedClass(classname); + if (theClass != null) { + return theClass; + } + + try { + theClass = findClass(classname); + } catch (ClassNotFoundException cnfe) { + theClass = getParent().loadClass(classname); + } + + if (resolve) { + resolveClass(theClass); + } + + return theClass; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacCompilationProblem.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacCompilationProblem.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacCompilationProblem.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacCompilationProblem.java Wed Apr 25 07:57:21 2007 @@ -25,66 +25,66 @@ */ public class JavacCompilationProblem implements CompilationProblem { - private int endCoumn; - private int endLine; - private String fileName; - private String message; - private int startCoumn; - private int startLine; - private boolean isError; - - public JavacCompilationProblem(String message, boolean isError) { - this.message = message; - this.isError = isError; - this.fileName = ""; - } - - public JavacCompilationProblem(String fileName, boolean isError, int startLine, int startCoumn, int endLine, int endCoumn, String message) { - this.message = message; - this.isError = isError; - this.fileName = fileName; - this.startCoumn = startCoumn; - this.endCoumn = endCoumn; - this.startLine = startLine; - this.endLine = endLine; - } - - public int getEndColumn() { - return endCoumn; - } - - public int getEndLine() { - return endLine; - } - - public String getFileName() { - return fileName; - } - - public String getMessage() { - return message; - } - - public int getStartColumn() { - return startCoumn; - } - - public int getStartLine() { - return startLine; - } - - public boolean isError() { - return isError; - } - - public String toString() { - final StringBuffer sb = new StringBuffer(); - sb.append(getFileName()).append(" ("); - sb.append(getStartLine()); - sb.append(":"); - sb.append(getStartColumn()); - sb.append(") : "); - sb.append(getMessage()); - return sb.toString(); - } + private int endCoumn; + private int endLine; + private String fileName; + private String message; + private int startCoumn; + private int startLine; + private boolean isError; + + public JavacCompilationProblem(String message, boolean isError) { + this.message = message; + this.isError = isError; + this.fileName = ""; + } + + public JavacCompilationProblem(String fileName, boolean isError, int startLine, int startCoumn, int endLine, int endCoumn, String message) { + this.message = message; + this.isError = isError; + this.fileName = fileName; + this.startCoumn = startCoumn; + this.endCoumn = endCoumn; + this.startLine = startLine; + this.endLine = endLine; + } + + public int getEndColumn() { + return endCoumn; + } + + public int getEndLine() { + return endLine; + } + + public String getFileName() { + return fileName; + } + + public String getMessage() { + return message; + } + + public int getStartColumn() { + return startCoumn; + } + + public int getStartLine() { + return startLine; + } + + public boolean isError() { + return isError; + } + + public String toString() { + final StringBuffer sb = new StringBuffer(); + sb.append(getFileName()).append(" ("); + sb.append(getStartLine()); + sb.append(":"); + sb.append(getStartColumn()); + sb.append(") : "); + sb.append(getMessage()); + return sb.toString(); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompiler.java Wed Apr 25 07:57:21 2007 @@ -45,221 +45,221 @@ */ public final class JavacJavaCompiler extends AbstractJavaCompiler { - private static final String EOL = System.getProperty("line.separator"); - private static final String WARNING_PREFIX = "warning: "; - private static final String NOTE_PREFIX = "Note: "; - private static final String ERROR_PREFIX = "error: "; - - private final JavacJavaCompilerSettings settings; - - public JavacJavaCompiler() { - settings = new JavacJavaCompilerSettings(); - } - - public JavacJavaCompiler( final JavacJavaCompilerSettings pSettings ) { - settings = pSettings; - } - - public CompilationResult compile( final String[] pSourcePaths, final ResourceReader pReader, ResourceStore pStore, final ClassLoader pClasspathClassLoader, final JavaCompilerSettings pSettings ) { - - try { - final ClassLoader cl = new JavacClassLoader(pClasspathClassLoader); - final Class renamedClass = cl.loadClass("com.sun.tools.javac.Main"); - - FileInputStreamProxy.setResourceReader(pReader); - FileOutputStreamProxy.setResourceStore(pStore); - - final Method compile = renamedClass.getMethod("compile", new Class[] { String[].class, PrintWriter.class }); - final StringWriter out = new StringWriter(); - final Integer ok = (Integer) compile.invoke(null, new Object[] { buildCompilerArguments(pSourcePaths, pClasspathClassLoader), new PrintWriter(out) }); - - final CompilationResult result = parseModernStream(new BufferedReader(new StringReader(out.toString()))); - - if (result.getErrors().length == 0 && ok.intValue() != 0) { - return new CompilationResult(new CompilationProblem[] { - new JavacCompilationProblem("Failure executing javac, but could not parse the error: " + out.toString(), true) }); - } - - return result; - - } catch(Exception e) { - return new CompilationResult(new CompilationProblem[] { - new JavacCompilationProblem("Error while executing the compiler: " + e.toString(), true) }); - } finally { - // help GC - FileInputStreamProxy.setResourceReader(null); - FileOutputStreamProxy.setResourceStore(null); - } - } - - private CompilationResult parseModernStream( final BufferedReader pReader ) throws IOException { - final List problems = new ArrayList(); - String line; - - while (true) { - // cleanup the buffer - final StringBuffer buffer = new StringBuffer(); - - // most errors terminate with the '^' char - do { - line = pReader.readLine(); - if (line == null) { - return new CompilationResult((CompilationProblem[]) problems.toArray(new CompilationProblem[problems.size()])); - } - - // TODO: there should be a better way to parse these - if (buffer.length() == 0 && line.startsWith(ERROR_PREFIX)) { - problems.add(new JavacCompilationProblem(line, true)); - } - else if (buffer.length() == 0 && line.startsWith(NOTE_PREFIX)) { - // skip this one - it is JDK 1.5 telling us that the - // interface is deprecated. - } else { - buffer.append(line); - buffer.append(EOL); - } - } while (!line.endsWith("^")); - - // add the error - problems.add(parseModernError(buffer.toString())); - } - } - - private CompilationProblem parseModernError( final String pError ) { - final StringTokenizer tokens = new StringTokenizer(pError, ":"); - boolean isError = true; - try { - String file = tokens.nextToken(); - // When will this happen? - if (file.length() == 1) { - file = new StringBuffer(file).append(":").append( - tokens.nextToken()).toString(); - } - final int line = Integer.parseInt(tokens.nextToken()); - final StringBuffer msgBuffer = new StringBuffer(); - - String msg = tokens.nextToken(EOL).substring(2); - isError = !msg.startsWith(WARNING_PREFIX); - - // Remove the 'warning: ' prefix - if (!isError) { - msg = msg.substring(WARNING_PREFIX.length()); - } - msgBuffer.append(msg); - - String context = tokens.nextToken(EOL); - String pointer = tokens.nextToken(EOL); - - if (tokens.hasMoreTokens()) { - msgBuffer.append(EOL); - msgBuffer.append(context); // 'symbol' line - msgBuffer.append(EOL); - msgBuffer.append(pointer); // 'location' line - msgBuffer.append(EOL); - - context = tokens.nextToken(EOL); - - try { - pointer = tokens.nextToken(EOL); - } catch (NoSuchElementException e) { - pointer = context; - context = null; - } - } - final String message = msgBuffer.toString(); - int startcolumn = pointer.indexOf("^"); - int endcolumn = context == null ? startcolumn : context.indexOf(" ", startcolumn); - if (endcolumn == -1) { - endcolumn = context.length(); - } - return new JavacCompilationProblem(file, isError, line, startcolumn, line, endcolumn, message); - } - catch (NoSuchElementException e) { - return new JavacCompilationProblem("no more tokens - could not parse error message: " + pError, isError); - } - catch (NumberFormatException e) { - return new JavacCompilationProblem("could not parse error message: " + pError, isError); - } - catch (Exception e) { - return new JavacCompilationProblem("could not parse error message: " + pError, isError); - } - } - - public JavaCompilerSettings createDefaultSettings() { - return settings; - } - - private String[] buildCompilerArguments( final String[] resourcePaths, final ClassLoader classloader ) { - - // FIXME: build classpath from classloader information - return resourcePaths; - -// { -// final List args = new ArrayList(); -// for (int i = 0; i < resourcePaths.length; i++) { -// args.add(resourcePaths[i]); -// } -// -// if (settings != null) { -// if (settings.isOptimize()) { -// args.add("-O"); -// } -// -// if (settings.isDebug()) { -// args.add("-g"); -// } -// -// if (settings.isVerbose()) { -// args.add("-verbose"); -// } -// -// if (settings.isShowDeprecation()) { -// args.add("-deprecation"); -// // This is required to actually display the deprecation messages -// settings.setShowWarnings(true); -// } -// -// if (settings.getMaxmem() != null) { -// args.add("-J-Xmx" + settings.getMaxmem()); -// } -// -// if (settings.getMeminitial() != null) { -// args.add("-J-Xms" + settings.getMeminitial()); -// } -// -// if (!settings.isShowWarnings()) { -// args.add("-nowarn"); -// } -// -// // TODO: this could be much improved -// if (settings.getTargetVersion() != null) { -// // Required, or it defaults to the target of your JDK (eg 1.5) -// args.add("-target"); -// args.add("1.1"); -// } else { -// args.add("-target"); -// args.add(settings.getTargetVersion()); -// } -// -// // TODO suppressSource -// if (settings.getSourceVersion() != null) { -// // If omitted, later JDKs complain about a 1.1 target -// args.add("-source"); -// args.add("1.3"); -// } else { -// args.add("-source"); -// args.add(settings.getSourceVersion()); -// } -// -// // TODO suppressEncoding -// if (settings.getSourceEncoding() != null) { -// args.add("-encoding"); -// args.add(settings.getSourceEncoding()); -// } + private static final String EOL = System.getProperty("line.separator"); + private static final String WARNING_PREFIX = "warning: "; + private static final String NOTE_PREFIX = "Note: "; + private static final String ERROR_PREFIX = "error: "; + + private final JavacJavaCompilerSettings settings; + + public JavacJavaCompiler() { + settings = new JavacJavaCompilerSettings(); + } + + public JavacJavaCompiler( final JavacJavaCompilerSettings pSettings ) { + settings = pSettings; + } + + public CompilationResult compile( final String[] pSourcePaths, final ResourceReader pReader, ResourceStore pStore, final ClassLoader pClasspathClassLoader, final JavaCompilerSettings pSettings ) { + + try { + final ClassLoader cl = new JavacClassLoader(pClasspathClassLoader); + final Class renamedClass = cl.loadClass("com.sun.tools.javac.Main"); + + FileInputStreamProxy.setResourceReader(pReader); + FileOutputStreamProxy.setResourceStore(pStore); + + final Method compile = renamedClass.getMethod("compile", new Class[] { String[].class, PrintWriter.class }); + final StringWriter out = new StringWriter(); + final Integer ok = (Integer) compile.invoke(null, new Object[] { buildCompilerArguments(pSourcePaths, pClasspathClassLoader), new PrintWriter(out) }); + + final CompilationResult result = parseModernStream(new BufferedReader(new StringReader(out.toString()))); + + if (result.getErrors().length == 0 && ok.intValue() != 0) { + return new CompilationResult(new CompilationProblem[] { + new JavacCompilationProblem("Failure executing javac, but could not parse the error: " + out.toString(), true) }); + } + + return result; + + } catch(Exception e) { + return new CompilationResult(new CompilationProblem[] { + new JavacCompilationProblem("Error while executing the compiler: " + e.toString(), true) }); + } finally { + // help GC + FileInputStreamProxy.setResourceReader(null); + FileOutputStreamProxy.setResourceStore(null); + } + } + + private CompilationResult parseModernStream( final BufferedReader pReader ) throws IOException { + final List problems = new ArrayList(); + String line; + + while (true) { + // cleanup the buffer + final StringBuffer buffer = new StringBuffer(); + + // most errors terminate with the '^' char + do { + line = pReader.readLine(); + if (line == null) { + return new CompilationResult((CompilationProblem[]) problems.toArray(new CompilationProblem[problems.size()])); + } + + // TODO: there should be a better way to parse these + if (buffer.length() == 0 && line.startsWith(ERROR_PREFIX)) { + problems.add(new JavacCompilationProblem(line, true)); + } + else if (buffer.length() == 0 && line.startsWith(NOTE_PREFIX)) { + // skip this one - it is JDK 1.5 telling us that the + // interface is deprecated. + } else { + buffer.append(line); + buffer.append(EOL); + } + } while (!line.endsWith("^")); + + // add the error + problems.add(parseModernError(buffer.toString())); + } + } + + private CompilationProblem parseModernError( final String pError ) { + final StringTokenizer tokens = new StringTokenizer(pError, ":"); + boolean isError = true; + try { + String file = tokens.nextToken(); + // When will this happen? + if (file.length() == 1) { + file = new StringBuffer(file).append(":").append( + tokens.nextToken()).toString(); + } + final int line = Integer.parseInt(tokens.nextToken()); + final StringBuffer msgBuffer = new StringBuffer(); + + String msg = tokens.nextToken(EOL).substring(2); + isError = !msg.startsWith(WARNING_PREFIX); + + // Remove the 'warning: ' prefix + if (!isError) { + msg = msg.substring(WARNING_PREFIX.length()); + } + msgBuffer.append(msg); + + String context = tokens.nextToken(EOL); + String pointer = tokens.nextToken(EOL); + + if (tokens.hasMoreTokens()) { + msgBuffer.append(EOL); + msgBuffer.append(context); // 'symbol' line + msgBuffer.append(EOL); + msgBuffer.append(pointer); // 'location' line + msgBuffer.append(EOL); + + context = tokens.nextToken(EOL); + + try { + pointer = tokens.nextToken(EOL); + } catch (NoSuchElementException e) { + pointer = context; + context = null; + } + } + final String message = msgBuffer.toString(); + int startcolumn = pointer.indexOf("^"); + int endcolumn = context == null ? startcolumn : context.indexOf(" ", startcolumn); + if (endcolumn == -1) { + endcolumn = context.length(); + } + return new JavacCompilationProblem(file, isError, line, startcolumn, line, endcolumn, message); + } + catch (NoSuchElementException e) { + return new JavacCompilationProblem("no more tokens - could not parse error message: " + pError, isError); + } + catch (NumberFormatException e) { + return new JavacCompilationProblem("could not parse error message: " + pError, isError); + } + catch (Exception e) { + return new JavacCompilationProblem("could not parse error message: " + pError, isError); + } + } + + public JavaCompilerSettings createDefaultSettings() { + return settings; + } + + private String[] buildCompilerArguments( final String[] resourcePaths, final ClassLoader classloader ) { + + // FIXME: build classpath from classloader information + return resourcePaths; + +// { +// final List args = new ArrayList(); +// for (int i = 0; i < resourcePaths.length; i++) { +// args.add(resourcePaths[i]); +// } +// +// if (settings != null) { +// if (settings.isOptimize()) { +// args.add("-O"); +// } +// +// if (settings.isDebug()) { +// args.add("-g"); +// } +// +// if (settings.isVerbose()) { +// args.add("-verbose"); +// } +// +// if (settings.isShowDeprecation()) { +// args.add("-deprecation"); +// // This is required to actually display the deprecation messages +// settings.setShowWarnings(true); +// } +// +// if (settings.getMaxmem() != null) { +// args.add("-J-Xmx" + settings.getMaxmem()); +// } +// +// if (settings.getMeminitial() != null) { +// args.add("-J-Xms" + settings.getMeminitial()); +// } +// +// if (!settings.isShowWarnings()) { +// args.add("-nowarn"); +// } +// +// // TODO: this could be much improved +// if (settings.getTargetVersion() != null) { +// // Required, or it defaults to the target of your JDK (eg 1.5) +// args.add("-target"); +// args.add("1.1"); +// } else { +// args.add("-target"); +// args.add(settings.getTargetVersion()); +// } +// +// // TODO suppressSource +// if (settings.getSourceVersion() != null) { +// // If omitted, later JDKs complain about a 1.1 target +// args.add("-source"); +// args.add("1.3"); +// } else { +// args.add("-source"); +// args.add(settings.getSourceVersion()); +// } +// +// // TODO suppressEncoding +// if (settings.getSourceEncoding() != null) { +// args.add("-encoding"); +// args.add(settings.getSourceEncoding()); +// } // -// // TODO CustomCompilerArguments -// } +// // TODO CustomCompilerArguments +// } // -// return (String[]) args.toArray(new String[args.size()]); - } +// return (String[]) args.toArray(new String[args.size()]); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompilerSettings.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompilerSettings.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompilerSettings.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/main/java/org/apache/commons/jci/compilers/JavacJavaCompilerSettings.java Wed Apr 25 07:57:21 2007 @@ -21,42 +21,42 @@ public final class JavacJavaCompilerSettings extends JavaCompilerSettings { - private boolean optimize; - private String maxmem; - private String meminitial; - - private List customCompilerArguments; - - public List getCustomCompilerArguments() { - return customCompilerArguments; - } - - public void setCustomCompilerArguments(List customCompilerArguments) { - this.customCompilerArguments = customCompilerArguments; - } - - public String getMaxmem() { - return maxmem; - } - - public void setMaxmem(String maxmem) { - this.maxmem = maxmem; - } - - public String getMeminitial() { - return meminitial; - } - - public void setMeminitial(String meminitial) { - this.meminitial = meminitial; - } - - public boolean isOptimize() { - return optimize; - } - - public void setOptimize(boolean optimize) { - this.optimize = optimize; - } + private boolean optimize; + private String maxmem; + private String meminitial; + + private List customCompilerArguments; + + public List getCustomCompilerArguments() { + return customCompilerArguments; + } + + public void setCustomCompilerArguments(List customCompilerArguments) { + this.customCompilerArguments = customCompilerArguments; + } + + public String getMaxmem() { + return maxmem; + } + + public void setMaxmem(String maxmem) { + this.maxmem = maxmem; + } + + public String getMeminitial() { + return meminitial; + } + + public void setMeminitial(String meminitial) { + this.meminitial = meminitial; + } + + public boolean isOptimize() { + return optimize; + } + + public void setOptimize(boolean optimize) { + this.optimize = optimize; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/javac/src/test/java/org/apache/commons/jci/compilers/JavacJavaCompilerTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/javac/src/test/java/org/apache/commons/jci/compilers/JavacJavaCompilerTestCase.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/javac/src/test/java/org/apache/commons/jci/compilers/JavacJavaCompilerTestCase.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/javac/src/test/java/org/apache/commons/jci/compilers/JavacJavaCompilerTestCase.java Wed Apr 25 07:57:21 2007 @@ -19,12 +19,12 @@ public class JavacJavaCompilerTestCase extends AbstractCompilerTestCase { - public JavaCompiler createJavaCompiler() { - return new JavacJavaCompiler(); - } + public JavaCompiler createJavaCompiler() { + return new JavacJavaCompiler(); + } - public String getCompilerName() { - return "javac"; - } + public String getCompilerName() { + return "javac"; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199CompilationProblem.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199CompilationProblem.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199CompilationProblem.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199CompilationProblem.java Wed Apr 25 07:57:21 2007 @@ -23,46 +23,46 @@ public class Jsr199CompilationProblem implements CompilationProblem { - final Diagnostic problem; - - public Jsr199CompilationProblem( final Diagnostic pProblem ) { - problem = pProblem; - } - - public int getEndColumn() { - // TODO Auto-generated method stub - return 0; - } - - public int getEndLine() { - // TODO Auto-generated method stub - return 0; - } - - public String getFileName() { - // TODO Auto-generated method stub - return null; - } - - public String getMessage() { - // TODO Auto-generated method stub - return null; - } - - public int getStartColumn() { - // TODO Auto-generated method stub - return 0; - } - - public int getStartLine() { - // TODO Auto-generated method stub - return 0; - } - - public boolean isError() { - // TODO Auto-generated method stub - return false; - } + final Diagnostic problem; + + public Jsr199CompilationProblem( final Diagnostic pProblem ) { + problem = pProblem; + } + + public int getEndColumn() { + // TODO Auto-generated method stub + return 0; + } + + public int getEndLine() { + // TODO Auto-generated method stub + return 0; + } + + public String getFileName() { + // TODO Auto-generated method stub + return null; + } + + public String getMessage() { + // TODO Auto-generated method stub + return null; + } + + public int getStartColumn() { + // TODO Auto-generated method stub + return 0; + } + + public int getStartLine() { + // TODO Auto-generated method stub + return 0; + } + + public boolean isError() { + // TODO Auto-generated method stub + return false; + } } Modified: jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199JavaCompiler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199JavaCompiler.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199JavaCompiler.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/jsr199/src/main/java/org/apache/commons/jci/compilers/Jsr199JavaCompiler.java Wed Apr 25 07:57:21 2007 @@ -50,163 +50,163 @@ private final Log log = LogFactory.getLog(Jsr199JavaCompiler.class); private class CompilationUnit extends SimpleJavaFileObject { - final private ResourceReader reader; - final private String name; - - public CompilationUnit( final String pName, final ResourceReader pReader ) { + final private ResourceReader reader; + final private String name; + + public CompilationUnit( final String pName, final ResourceReader pReader ) { super(URI.create("reader:///" + pName), Kind.SOURCE); reader = pReader; name = pName; - } + } + + public boolean delete() { + log.debug("delete"); + return super.delete(); + } + + public CharSequence getCharContent(boolean arg0) throws IOException { + log.debug("getCharContent of " + name); + byte[] content = reader.getBytes(name); + return new String(content); + } + + public Kind getKind() { + log.debug("getKind" + super.getKind()); + return super.getKind(); + } + + public long getLastModified() { + log.debug("getLastModified"); + return super.getLastModified(); + } + + public String getName() { + log.debug("getName " + super.getName()); + return super.getName(); + } + + public boolean isNameCompatible(String arg0, Kind arg1) { + log.debug("isNameCompatible " + arg0); + return super.isNameCompatible(arg0, arg1); + } + + public InputStream openInputStream() throws IOException { + log.debug("openInputStream"); + return super.openInputStream(); + } + + public OutputStream openOutputStream() throws IOException { + log.debug("openOutputStream"); + return super.openOutputStream(); + } + + public Reader openReader(boolean arg0) throws IOException { + log.debug("openReader"); + return super.openReader(arg0); + } + + public Writer openWriter() throws IOException { + log.debug("openWriter"); + return super.openWriter(); + } + + public URI toUri() { + log.debug("toUri " + super.toUri()); + return super.toUri(); + } + - public boolean delete() { - log.debug("delete"); - return super.delete(); - } - - public CharSequence getCharContent(boolean arg0) throws IOException { - log.debug("getCharContent of " + name); - byte[] content = reader.getBytes(name); - return new String(content); - } - - public Kind getKind() { - log.debug("getKind" + super.getKind()); - return super.getKind(); - } - - public long getLastModified() { - log.debug("getLastModified"); - return super.getLastModified(); - } - - public String getName() { - log.debug("getName " + super.getName()); - return super.getName(); - } - - public boolean isNameCompatible(String arg0, Kind arg1) { - log.debug("isNameCompatible " + arg0); - return super.isNameCompatible(arg0, arg1); - } - - public InputStream openInputStream() throws IOException { - log.debug("openInputStream"); - return super.openInputStream(); - } - - public OutputStream openOutputStream() throws IOException { - log.debug("openOutputStream"); - return super.openOutputStream(); - } - - public Reader openReader(boolean arg0) throws IOException { - log.debug("openReader"); - return super.openReader(arg0); - } - - public Writer openWriter() throws IOException { - log.debug("openWriter"); - return super.openWriter(); - } - - public URI toUri() { - log.debug("toUri " + super.toUri()); - return super.toUri(); - } - - } private class JciJavaFileManager implements JavaFileManager { - private final ResourceStore store; - final Collection units; - + private final ResourceStore store; + final Collection units; + public JciJavaFileManager( final Collection pUnits, final ResourceStore pStore ) { store = pStore; units = pUnits; } - - public void close() { - log.debug("close"); - } - public void flush() { - log.debug("flush"); - } - public ClassLoader getClassLoader(JavaFileManager.Location location) { - log.debug("getClassLoader"); - return null; - } - public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) { - log.debug("getFileForInput"); - return null; - } - public FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) { - log.debug("getFileForOutput"); - return null; - } - public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) { - log.debug("getJavaFileForInput"); - return null; - } - public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) { - log.debug("getJavaFileForOutput"); - return null; - } - public int isSupportedOption(String option) { - log.debug("isSupportedOption"); - return 0; - } - public boolean handleOption(String current, Iterator remaining) { - log.debug("handleOption"); - return false; - } - public boolean hasLocation(JavaFileManager.Location location) { - log.debug("hasLocation"); - return false; - } - public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file) { - log.debug("inferBinaryName " + file.getName()); - return file.getName().replaceFirst(".java", ".class"); - } - public Iterable list(JavaFileManager.Location location, String packageName, Set kinds, boolean recurse) { - log.debug("list " + location + packageName + kinds + recurse); - return units; - } + + public void close() { + log.debug("close"); + } + public void flush() { + log.debug("flush"); + } + public ClassLoader getClassLoader(JavaFileManager.Location location) { + log.debug("getClassLoader"); + return null; + } + public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) { + log.debug("getFileForInput"); + return null; + } + public FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) { + log.debug("getFileForOutput"); + return null; + } + public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) { + log.debug("getJavaFileForInput"); + return null; + } + public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) { + log.debug("getJavaFileForOutput"); + return null; + } + public int isSupportedOption(String option) { + log.debug("isSupportedOption"); + return 0; + } + public boolean handleOption(String current, Iterator remaining) { + log.debug("handleOption"); + return false; + } + public boolean hasLocation(JavaFileManager.Location location) { + log.debug("hasLocation"); + return false; + } + public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file) { + log.debug("inferBinaryName " + file.getName()); + return file.getName().replaceFirst(".java", ".class"); + } + public Iterable list(JavaFileManager.Location location, String packageName, Set kinds, boolean recurse) { + log.debug("list " + location + packageName + kinds + recurse); + return units; + } } - public CompilationResult compile( final String[] pResourcePaths, final ResourceReader pReader, final ResourceStore pStore, final ClassLoader classLoader) { + public CompilationResult compile( final String[] pResourcePaths, final ResourceReader pReader, final ResourceStore pStore, final ClassLoader classLoader) { - final Collection units = new ArrayList(); - for (int i = 0; i < pResourcePaths.length; i++) { - final String sourcePath = pResourcePaths[i]; - log.debug("compiling " + sourcePath); - units.add(new CompilationUnit(sourcePath, pReader)); - } - - final JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool(); -// final JavaFileManager fileManager = compiler.getStandardFileManager(diagnostics); - final JavaFileManager fileManager = new JciJavaFileManager(units, pStore); - final DiagnosticCollector diagnostics = new DiagnosticCollector(); - - - compiler.getTask(null, fileManager, diagnostics, null, null, units).run(); - - try { - fileManager.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - final List> jsrProblems = diagnostics.getDiagnostics(); - final CompilationProblem[] problems = new CompilationProblem[jsrProblems.size()]; - int i = 0; - for (final Diagnostic jsrProblem : jsrProblems) { - problems[i++] = new Jsr199CompilationProblem(jsrProblem); - } - - return new CompilationResult(problems); - } + final Collection units = new ArrayList(); + for (int i = 0; i < pResourcePaths.length; i++) { + final String sourcePath = pResourcePaths[i]; + log.debug("compiling " + sourcePath); + units.add(new CompilationUnit(sourcePath, pReader)); + } + + final JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool(); +// final JavaFileManager fileManager = compiler.getStandardFileManager(diagnostics); + final JavaFileManager fileManager = new JciJavaFileManager(units, pStore); + final DiagnosticCollector diagnostics = new DiagnosticCollector(); + + + compiler.getTask(null, fileManager, diagnostics, null, null, units).run(); + + try { + fileManager.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + final List> jsrProblems = diagnostics.getDiagnostics(); + final CompilationProblem[] problems = new CompilationProblem[jsrProblems.size()]; + int i = 0; + for (final Diagnostic jsrProblem : jsrProblems) { + problems[i++] = new Jsr199CompilationProblem(jsrProblem); + } + + return new CompilationResult(problems); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/jsr199/src/test/java/org/apache/commons/jci/compilers/Jsr199JavaCompilerTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/jsr199/src/test/java/org/apache/commons/jci/compilers/Jsr199JavaCompilerTestCase.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/jsr199/src/test/java/org/apache/commons/jci/compilers/Jsr199JavaCompilerTestCase.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/jsr199/src/test/java/org/apache/commons/jci/compilers/Jsr199JavaCompilerTestCase.java Wed Apr 25 07:57:21 2007 @@ -2,12 +2,12 @@ public final class Jsr199JavaCompilerTestCase extends AbstractCompilerTestCase { - public String getCompilerName() { - return "jsr199"; - } - - public JavaCompiler createJavaCompiler() { - return new Jsr199JavaCompiler(); - } + public String getCompilerName() { + return "jsr199"; + } + + public JavaCompiler createJavaCompiler() { + return new Jsr199JavaCompiler(); + } } Modified: jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoCompilationProblem.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoCompilationProblem.java?view=diff&rev=532377&r1=532376&r2=532377 ============================================================================== --- jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoCompilationProblem.java (original) +++ jakarta/commons/proper/jci/trunk/compilers/rhino/src/main/java/org/apache/commons/jci/compilers/RhinoCompilationProblem.java Wed Apr 25 07:57:21 2007 @@ -25,46 +25,46 @@ */ public final class RhinoCompilationProblem implements CompilationProblem { - private final String message; - private final String fileName; - private final int line; - private final int column; - private final boolean error; - - public RhinoCompilationProblem( final String pMessage, final String pFileName, final int pLine, final String pScript, final int pColumn, final boolean pError ) { - message = pMessage; - fileName = pFileName; - line = pLine; - column = pColumn; - error = pError; - } - - public int getEndColumn() { - return column; - } - - public int getEndLine() { - return line; - } - - public String getFileName() { - return fileName; - } - - public String getMessage() { - return message; - } - - public int getStartColumn() { - return column; - } - - public int getStartLine() { - return line; - } - - public boolean isError() { - return error; - } + private final String message; + private final String fileName; + private final int line; + private final int column; + private final boolean error; + + public RhinoCompilationProblem( final String pMessage, final String pFileName, final int pLine, final String pScript, final int pColumn, final boolean pError ) { + message = pMessage; + fileName = pFileName; + line = pLine; + column = pColumn; + error = pError; + } + + public int getEndColumn() { + return column; + } + + public int getEndLine() { + return line; + } + + public String getFileName() { + return fileName; + } + + public String getMessage() { + return message; + } + + public int getStartColumn() { + return column; + } + + public int getStartLine() { + return line; + } + + public boolean isError() { + return error; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org