Skip to content

Commit cf26c21

Browse files
initial
0 parents  commit cf26c21

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
classpath
2+
target/*
3+
src/java/junit/*
4+
.idea
5+
*.iml

pom.xml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" >
4+
<dependencies>
5+
<dependency>
6+
<groupId>org.codehaus.janino</groupId>
7+
<artifactId>commons-compiler-jdk</artifactId>
8+
<version>3.0.7</version>
9+
</dependency>
10+
<dependency>
11+
<groupId>junit</groupId>
12+
<artifactId>junit</artifactId>
13+
<version>4.12</version>
14+
</dependency>
15+
</dependencies>
16+
<version>0.0</version>
17+
<groupId>com.datomic</groupId>
18+
<name>janino-repro-3</name>
19+
<artifactId>janino-repro-3</artifactId>
20+
<properties>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
</properties>
23+
<modelVersion>4.0.0</modelVersion>
24+
<build>
25+
<pluginManagement>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>3.0</version>
31+
<configuration>
32+
<!-- put your configurations here -->
33+
</configuration>
34+
</plugin>
35+
</plugins>
36+
</pluginManagement>
37+
<sourceDirectory>src/java</sourceDirectory>
38+
<resources>
39+
<resource>
40+
<directory>src/resources</directory>
41+
</resource>
42+
</resources>
43+
</build>
44+
<repositories>
45+
<repository>
46+
<id>Sonatype</id>
47+
<name>Sonatype Release</name>
48+
<url>http://oss.sonatype.org/content/repositories/releases</url>
49+
<releases>
50+
<enabled>true</enabled>
51+
</releases>
52+
<snapshots>
53+
<enabled>false</enabled>
54+
</snapshots>
55+
</repository>
56+
</repositories>
57+
</project>

run-repro

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
mvn -q dependency:build-classpath -Dmdep.outputFile=classpath
4+
5+
rm -f src/java/junit/framework/subpackage/*
6+
7+
mvn -q clean compile
8+
9+
echo "================================"
10+
echo "Run 1. Compiled classes: "
11+
find target/classes
12+
13+
java -cp target/classes:`cat classpath` datomic.JaninoRepro3
14+
15+
cp siderail/Breaker.java src/java/junit/framework/subpackage/
16+
17+
mvn -q clean compile
18+
19+
echo "================================"
20+
echo "Run 2. Compiled classes: "
21+
find target/classes
22+
23+
java -cp target/classes:`cat classpath` datomic.JaninoRepro3
24+

siderail/Breaker.java

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package junit.framework.subpackage;
2+
3+
// the existence of this class changes the behavior of Janino compilation.
4+
public class Breaker {
5+
}

src/java/datomic/JaninoRepro3.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package datomic;
2+
3+
import org.codehaus.commons.compiler.CompileException;
4+
import org.codehaus.commons.compiler.jdk.ScriptEvaluator;
5+
6+
public class JaninoRepro3 {
7+
public static void main(String[] args) throws CompileException {
8+
System.out.println("Class location:");
9+
System.out.println(ClassLoader.getSystemClassLoader().getResource("junit/framework/TestCase.class"));
10+
11+
System.out.println("Classpath:");
12+
System.out.println(System.getProperty("java.class.path"));
13+
14+
System.out.println("Run trivial script:");
15+
ScriptEvaluator ev = new ScriptEvaluator();
16+
ev.setDefaultImports(new String[]{"junit.framework.TestCase"});
17+
Runnable r = (Runnable) ev.createFastEvaluator("System.out.println(123);", Runnable.class, new String[]{});
18+
r.run();
19+
}
20+
}

0 commit comments

Comments
 (0)