You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by tc...@apache.org on 2005/08/16 12:00:43 UTC
svn commit: r232971 - in /jakarta/commons/sandbox/jci/trunk: .classpath
project.xml
src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
Author: tcurdt
Date: Tue Aug 16 03:00:36 2005
New Revision: 232971
URL: http://svn.apache.org/viewcvs?rev=232971&view=rev
Log:
upgraded to janinio >= 2.3.4,
removed an unnecessary else
(thanks to Joerg for the patches)
Modified:
jakarta/commons/sandbox/jci/trunk/.classpath
jakarta/commons/sandbox/jci/trunk/project.xml
jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
Modified: jakarta/commons/sandbox/jci/trunk/.classpath
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/.classpath?rev=232971&r1=232970&r2=232971&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/.classpath (original)
+++ jakarta/commons/sandbox/jci/trunk/.classpath Tue Aug 16 03:00:36 2005
@@ -8,9 +8,9 @@
<classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar"/>
<classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-api-1.0.4.jar"/>
<classpathentry kind="var" path="MAVEN_REPO/commons-collections/jars/commons-collections-3.1.jar"/>
- <classpathentry kind="var" path="MAVEN_REPO/janino/jars/janino-2.3.0.jar"/>
<classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
<classpathentry kind="var" path="MAVEN_REPO/eclipse/jars/jdtcore-3.1.0.jar"/>
<classpathentry kind="var" path="MAVEN_REPO/groovy/jars/groovy-1.0-jsr-02.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/janino/jars/janino-2.3.7.jar"/>
<classpathentry kind="output" path="eclipse"/>
</classpath>
Modified: jakarta/commons/sandbox/jci/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/project.xml?rev=232971&r1=232970&r2=232971&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/project.xml (original)
+++ jakarta/commons/sandbox/jci/trunk/project.xml Tue Aug 16 03:00:36 2005
@@ -113,7 +113,7 @@
<dependency>
<groupId>janino</groupId>
<artifactId>janino</artifactId>
- <version>2.3.0</version>
+ <version>2.3.7</version>
</dependency>
<dependency>
Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java?rev=232971&r1=232970&r2=232971&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java Tue Aug 16 03:00:36 2005
@@ -159,41 +159,38 @@
log.debug("compile " + clazzName);
ICompilationUnit compilationUnit = new CompilationUnit(pReader, clazzName);
return new NameEnvironmentAnswer(compilationUnit, null);
- } else {
- final String resourceName = clazzName.replace('.', '/') + ".class";
- final InputStream is = this.getClass().getClassLoader()
- .getResourceAsStream(resourceName);
- if (is != null) {
- final byte[] buffer = new byte[8192];
- final ByteArrayOutputStream baos = new ByteArrayOutputStream(buffer.length);
- int count;
+ }
+
+ final String resourceName = clazzName.replace('.', '/') + ".class";
+ final InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName);
+ if (is != null) {
+ final byte[] buffer = new byte[8192];
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream(buffer.length);
+ int count;
+ try {
+ while ((count = is.read(buffer, 0, buffer.length)) > 0) {
+ baos.write(buffer, 0, count);
+ }
+ baos.flush();
+ clazzBytes = baos.toByteArray();
+ final char[] fileName = clazzName.toCharArray();
+ ClassFileReader classFileReader =
+ new ClassFileReader(clazzBytes, fileName, true);
+ return new NameEnvironmentAnswer(classFileReader, null);
+ } catch (final IOException e) {
+ log.error("could not read class", e);
+ } catch (final ClassFormatException e) {
+ log.error("wrong class format", e);
+ } finally {
try {
- while ((count = is.read(buffer, 0, buffer.length)) > 0) {
- baos.write(buffer, 0, count);
- }
- baos.flush();
- clazzBytes = baos.toByteArray();
- final char[] fileName = clazzName.toCharArray();
- ClassFileReader classFileReader =
- new ClassFileReader(clazzBytes, fileName, true);
- return new NameEnvironmentAnswer(classFileReader, null);
- } catch (final IOException e) {
- log.error("could not read class", e);
- } catch (final ClassFormatException e) {
- log.error("wrong class format", e);
- } finally {
- try {
- baos.close();
- } catch (final IOException oe) {
- log.error("could not close output stream", oe);
- }
- if (is != null) {
- try {
- is.close();
- } catch (final IOException ie) {
- log.error("could not close input stream", ie);
- }
- }
+ baos.close();
+ } catch (final IOException oe) {
+ log.error("could not close output stream", oe);
+ }
+ try {
+ is.close();
+ } catch (final IOException ie) {
+ log.error("could not close input stream", ie);
}
}
}
@@ -262,10 +259,10 @@
}
}
};
-
+
final Compiler compiler =
new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory);
-
+
compiler.compile(compilationUnits);
}
}
Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java?rev=232971&r1=232970&r2=232971&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java Tue Aug 16 03:00:36 2005
@@ -36,7 +36,8 @@
import org.codehaus.janino.Java;
import org.codehaus.janino.Parser;
import org.codehaus.janino.Scanner;
-import org.codehaus.janino.Java.CompileException;
+import org.codehaus.janino.CompileException;
+import org.codehaus.janino.UnitCompiler;
import org.codehaus.janino.Parser.ParseException;
import org.codehaus.janino.Scanner.ScanException;
import org.codehaus.janino.util.ClassFile;
@@ -90,13 +91,14 @@
try {
scanner = new Scanner(fileNameForClass, instream, "UTF-8");
Java.CompilationUnit unit = new Parser(scanner).parseCompilationUnit();
+ UnitCompiler uc = new UnitCompiler(unit, loader);
log.debug("compile " + className);
- ClassFile[] classFiles = unit.compile(this, DebuggingInformation.ALL);
+ ClassFile[] classFiles = uc.compileUnit(DebuggingInformation.ALL);
for (int i = 0; i < classFiles.length; i++) {
log.debug("compiled " + classFiles[i].getThisClassName());
classes.put(classFiles[i].getThisClassName(), classFiles[i].toByteArray());
}
- IClass ic = unit.findClass(className);
+ IClass ic = uc.findClass(className);
if (null != ic) {
types.put(type, ic);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org