Skip to content

Commit

Permalink
playframework#5: Update to latest Eclipse JDT Core v3.23 to enable JD…
Browse files Browse the repository at this point in the history
…K 14 source (playframework#1338)

* playframework#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source

Task-Url: tazmaniax#5

* playframework#5: Updated Groovy to v3.0.6

Task-Url: tazmaniax#5

* 5: Replace LinkedList with Collection

Task-Url: tazmaniax#5

* Remove old versions of groovy

* Replace reflection based approach to adding compiler phase operation

* Fix groovy template compilation test

A change between Groovy 3.0.4 and 3.0.5 resulted in a change in the
compiler output message

* Updated a few dependencies

Not strictly part of this change but while there is an opportunity :)
  • Loading branch information
tazmaniax committed Dec 14, 2020
1 parent 8a423b0 commit 6d8b253
Show file tree
Hide file tree
Showing 35 changed files with 50 additions and 48 deletions.
32 changes: 16 additions & 16 deletions framework/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ transitiveDependencies: false
require: &allDependencies
- antlr 2.7.7
- com.mchange -> c3p0 0.9.5.2
- com.zaxxer -> HikariCP 3.2.0
- org.ow2.asm -> asm 7.0
- org.ow2.asm -> asm-commons 7.0
- org.ow2.asm -> asm-util 7.0
- org.ow2.asm -> asm-tree 7.0
- org.ow2.asm -> asm-analysis 7.0
- cglib -> cglib 3.2.7
- com.google.code.gson -> gson 2.8.5
- com.zaxxer -> HikariCP 3.4.5
- org.ow2.asm -> asm 9.0
- org.ow2.asm -> asm-commons 9.0
- org.ow2.asm -> asm-util 9.0
- org.ow2.asm -> asm-tree 9.0
- org.ow2.asm -> asm-analysis 9.0
- cglib -> cglib 3.3.0
- com.google.code.gson -> gson 2.8.6
- com.jamonapi -> jamon 2.81
- com.ning -> async-http-client 1.9.40
- commons-beanutils 1.9.2
Expand All @@ -28,12 +28,12 @@ require: &allDependencies
- commons-lang 2.6
- commons-logging 1.2
- dom4j 1.6.1
- com.h2database -> h2 1.4.196
- com.h2database -> h2 1.4.200
- javax.activation -> activation 1.1.1
- com.sun.mail -> javax.mail 1.6.2
- javax.inject 1.0
- javax.validation -> validation-api 1.1.0.Final
- jaxen 1.1.6
- jaxen 1.2.0
- joda-time 2.10
- org.hamcrest -> hamcrest-all 1.3
- junit 4.12
Expand All @@ -43,15 +43,15 @@ require: &allDependencies
- net.sf.ezmorph -> ezmorph 1.0.6
- net.sf.jsr107cache -> jsr107cache 1.1
- net.sf.oval -> oval 1.86
- mysql -> mysql-connector-java 8.0.17
- mysql -> mysql-connector-java 8.0.22
- oauth.signpost -> signpost-core 1.2.1.2
- org.apache.geronimo.specs -> geronimo-servlet_2.5_spec 1.2
- org.apache.ivy -> ivy 2.4.0
- org.bouncycastle -> bcprov-jdk15on 1.61
- org.bouncycastle -> bcpkix-jdk15on 1.61
- org.codehaus.groovy -> groovy 2.5.3
- org.codehaus.groovy -> groovy-xml 2.5.3
- org.eclipse.jdt -> org.eclipse.jdt.core 3.16.0
- org.codehaus.groovy -> groovy 3.0.6
- org.codehaus.groovy -> groovy-xml 3.0.6
- org.eclipse.jdt -> org.eclipse.jdt.core 3.23.0
- org.hibernate -> hibernate-core 5.4.1.Final.patched
- net.bytebuddy -> byte-buddy 1.9.5
- javax.persistence -> javax.persistence-api 2.2
Expand All @@ -66,9 +66,9 @@ require: &allDependencies
- org.hibernate -> hibernate-c3p0 5.4.1.Final
- org.hibernate -> hibernate-ehcache 5.4.1.Final
- com.mchange -> mchange-commons-java 0.2.12
- org.javassist -> javassist 3.24.0-GA
- org.javassist -> javassist 3.27.0-GA
- io.netty -> netty 3.10.6.Final
- org.postgresql -> postgresql 42.2.4
- org.postgresql -> postgresql 42.2.18
- org.slf4j -> slf4j-api 1.7.22
- org.slf4j -> slf4j-log4j12 1.7.22
- org.yaml -> snakeyaml 1.17
Expand Down
Binary file removed framework/lib/HikariCP-3.2.0.jar
Binary file not shown.
Binary file added framework/lib/HikariCP-3.4.5.jar
Binary file not shown.
Binary file removed framework/lib/asm-7.0.jar
Binary file not shown.
Binary file added framework/lib/asm-9.0.jar
Binary file not shown.
Binary file removed framework/lib/asm-analysis-7.0.jar
Binary file not shown.
Binary file added framework/lib/asm-analysis-9.0.jar
Binary file not shown.
Binary file removed framework/lib/asm-commons-7.0.jar
Binary file not shown.
Binary file added framework/lib/asm-commons-9.0.jar
Binary file not shown.
Binary file removed framework/lib/asm-tree-7.0.jar
Binary file not shown.
Binary file added framework/lib/asm-tree-9.0.jar
Binary file not shown.
Binary file removed framework/lib/asm-util-7.0.jar
Binary file not shown.
Binary file added framework/lib/asm-util-9.0.jar
Binary file not shown.
Binary file not shown.
Binary file removed framework/lib/groovy-2.5.3.jar
Binary file not shown.
Binary file added framework/lib/groovy-3.0.6.jar
Binary file not shown.
Binary file removed framework/lib/groovy-xml-2.5.3.jar
Binary file not shown.
Binary file added framework/lib/groovy-xml-3.0.6.jar
Binary file not shown.
Binary file removed framework/lib/gson-2.8.5.jar
Binary file not shown.
Binary file added framework/lib/gson-2.8.6.jar
Binary file not shown.
Binary file removed framework/lib/h2-1.4.196.jar
Binary file not shown.
Binary file added framework/lib/h2-1.4.200.jar
Binary file not shown.
Binary file not shown.
Binary file removed framework/lib/jaxen-1.1.6.jar
Binary file not shown.
Binary file added framework/lib/jaxen-1.2.0.jar
Binary file not shown.
Binary file removed framework/lib/mysql-connector-java-8.0.17.jar
Binary file not shown.
Binary file added framework/lib/mysql-connector-java-8.0.22.jar
Binary file not shown.
Binary file not shown.
Binary file added framework/lib/postgresql-42.2.18.jar
Binary file not shown.
Binary file removed framework/lib/postgresql-42.2.4.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions framework/src/play/classloading/ApplicationCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class ApplicationCompiler {
compatibleJavaVersions.put("9", CompilerOptions.VERSION_9);
compatibleJavaVersions.put("10", CompilerOptions.VERSION_10);
compatibleJavaVersions.put("11", CompilerOptions.VERSION_11);
compatibleJavaVersions.put("12", CompilerOptions.VERSION_12);
compatibleJavaVersions.put("13", CompilerOptions.VERSION_13);
compatibleJavaVersions.put("14", CompilerOptions.VERSION_14);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/src/play/mvc/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Scope {
public static final String COOKIE_EXPIRE = Play.configuration.getProperty("application.session.maxAge");
public static final boolean SESSION_HTTPONLY = Play.configuration.getProperty("application.session.httpOnly", "false").toLowerCase()
.equals("true");
public static final boolean SESSION_SEND_ONLY_IF_CHANGED = Play.configuration
public static boolean SESSION_SEND_ONLY_IF_CHANGED = Play.configuration
.getProperty("application.session.sendOnlyIfChanged", "false").toLowerCase().equals("true");

public static SessionStore sessionStore = createSessionStore();
Expand Down
36 changes: 25 additions & 11 deletions framework/src/play/templates/GroovyTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilationUnit.GroovyClassOperation;
import org.codehaus.groovy.control.CompilationUnit.IGroovyClassOperation;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.MultipleCompilationErrorsException;
import org.codehaus.groovy.control.Phases;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.messages.ExceptionMessage;
import org.codehaus.groovy.control.messages.Message;
Expand Down Expand Up @@ -141,18 +138,35 @@ public void compile() {
CompilationUnit compilationUnit = new CompilationUnit(compilerConfiguration);
compilationUnit.addSource(
new SourceUnit(name, compiledSource, compilerConfiguration, tClassLoader, compilationUnit.getErrorCollector()));

Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations");
phasesF.setAccessible(true);
LinkedList[] phases = (LinkedList[]) phasesF.get(compilationUnit);
LinkedList<GroovyClassOperation> output = new LinkedList<>();
phases[Phases.OUTPUT] = output;
output.add(new GroovyClassOperation() {

// The following approach to adding the phase operation replaces the original
// reflection based approach commented out lower down. This appears to be the
// canonical approach and possibly has only been made available in the v3.x
// stream but it differs in two ways from the reflection based approach and it's
// not clear if and what the impact is:
// 1. It does NOT guarantee an empty list of OUTPUT phases operations to begin with.
// 2. The new phase operation is added to the start and not the end.
// See https://github.com/apache/groovy/blob/GROOVY_3_0_6/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L349
compilationUnit.addPhaseOperation(new IGroovyClassOperation() {
@Override
public void call(GroovyClass gclass) {
groovyClassesForThisTemplate.add(gclass);
}
});

// TOOD: Remove once the above replacement logic has been confirmed.
// Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations");
// phasesF.setAccessible(true);
// Collection[] phases = (Collection[]) phasesF.get(compilationUnit);
// LinkedList<IGroovyClassOperation> output = new LinkedList<>();
// phases[Phases.OUTPUT] = output;
// output.add(new IGroovyClassOperation() {
// @Override
// public void call(GroovyClass gclass) {
// groovyClassesForThisTemplate.add(gclass);
// }
// });

compilationUnit.compile();
// ouf

Expand Down
17 changes: 1 addition & 16 deletions framework/test-src/play/mvc/SessionTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package play.mvc;

import java.lang.reflect.*;
import org.junit.*;

import play.Play;
Expand All @@ -23,21 +22,7 @@ private static void mockRequestAndResponse() {
}

public static void setSendOnlyIfChangedConstant(boolean value) {
try {
/*
* Set the final static value Scope.SESSION_SEND_ONLY_IF_CHANGED using reflection.
*/
Field field = Scope.class.getField("SESSION_SEND_ONLY_IF_CHANGED");
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

// Set the new value
field.setBoolean(null, value);
} catch(Exception e) {
throw new RuntimeException(e);
}
Scope.SESSION_SEND_ONLY_IF_CHANGED = value;
}

@Test
Expand Down
8 changes: 4 additions & 4 deletions samples-and-tests/i-am-a-developer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ def testSimpleProjectCreation(self):
self.assert_(browser.title() == 'Application error')
html = ''.join(error.readlines())
self.assert_(html.count('Template compilation error'))
self.assert_(html.count('In /app/views/Application/index.html (around line 4)'))
self.assert_(html.count('The template <strong>/app/views/Application/index.html</strong> does not compile : <strong>Unexpected input: \'{\' </strong>'))
self.assert_(waitFor(self.play, 'ERROR ~'))
self.assert_(waitFor(self.play, 'Template compilation error (In /app/views/Application/index.html around line 4)'))
self.assert_(waitFor(self.play, 'Template compilation error (In /app/views/Application/index.html around line 0)'))
self.assert_(waitFor(self.play, 'at Invocation.HTTP Request(Play!)'))

# Refresh again
Expand All @@ -542,9 +542,9 @@ def testSimpleProjectCreation(self):
self.assert_(browser.title() == 'Application error')
html = ''.join(error.readlines())
self.assert_(html.count('Template compilation error'))
self.assert_(html.count('In /app/views/Application/index.html (around line 4)'))
self.assert_(html.count('The template <strong>/app/views/Application/index.html</strong> does not compile : <strong>Unexpected input: \'{\' </strong>'))
self.assert_(waitFor(self.play, 'ERROR ~'))
self.assert_(waitFor(self.play, 'Template compilation error (In /app/views/Application/index.html around line 4)'))
self.assert_(waitFor(self.play, 'Template compilation error (In /app/views/Application/index.html around line 0)'))
self.assert_(waitFor(self.play, 'at Invocation.HTTP Request(Play!)'))

# Try a template runtime exception
Expand Down

0 comments on commit 6d8b253

Please sign in to comment.