Skip to content

Commit

Permalink
* playframework#5: Update to latest Eclipse JDT Core v3.23 to enable …
Browse files Browse the repository at this point in the history
…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 authored and tomparle committed Mar 15, 2022
1 parent fa15228 commit 0055395
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 12 deletions.
23 changes: 20 additions & 3 deletions framework/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ transitiveDependencies: false
require: &allDependencies
- antlr 2.7.7
- com.mchange -> c3p0 0.9.5.2
<<<<<<< HEAD
- com.zaxxer -> HikariCP 3.2.0
- org.ow2.asm -> asm 8.0.1
- org.ow2.asm -> asm-commons 8.0.1
Expand All @@ -17,6 +18,16 @@ require: &allDependencies
- org.ow2.asm -> asm-analysis 8.0.1
- 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
>>>>>>> 6d8b253a (#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source (#1338))
- com.jamonapi -> jamon 2.81
- com.ning -> async-http-client 1.9.40
- commons-beanutils 1.9.2
Expand All @@ -28,7 +39,7 @@ 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
Expand All @@ -43,15 +54,21 @@ 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
<<<<<<< HEAD
- org.codehaus.groovy -> groovy 3.0.4
- org.codehaus.groovy -> groovy-xml 3.0.4
- org.eclipse.jdt -> org.eclipse.jdt.core 3.18.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
>>>>>>> 6d8b253a (#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source (#1338))
- 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 @@ -68,7 +85,7 @@ require: &allDependencies
- com.mchange -> mchange-commons-java 0.2.12
- 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 added framework/lib/asm-9.0.jar
Binary file not shown.
Binary file added framework/lib/asm-analysis-9.0.jar
Binary file not shown.
Binary file added framework/lib/asm-commons-9.0.jar
Binary file not shown.
Binary file added framework/lib/asm-tree-9.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 added framework/lib/groovy-3.0.6.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 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.
14 changes: 14 additions & 0 deletions framework/src/play/classloading/ApplicationCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,27 @@ public class ApplicationCompiler {
ApplicationClasses applicationClasses;
Map<String, String> settings;
private static final String JAVA_SOURCE_DEFAULT_VERSION = "1.8";
<<<<<<< HEAD
static final Map<String, String> compatibleJavaVersions = org.apache.groovy.util.Maps.of( //
"1.8", CompilerOptions.VERSION_1_8, //
"9", CompilerOptions.VERSION_9, //
"10", CompilerOptions.VERSION_10, //
"11", CompilerOptions.VERSION_11, //
"12", CompilerOptions.VERSION_12 //
);
=======
static final Map<String, String> compatibleJavaVersions = new HashMap<>();

static {
compatibleJavaVersions.put("1.8", CompilerOptions.VERSION_1_8);
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);
}
>>>>>>> 6d8b253a (#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source (#1338))

/**
* Try to guess the magic configuration options
Expand Down
32 changes: 28 additions & 4 deletions framework/src/play/templates/GroovyTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
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.Collection;
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 @@ -142,18 +139,45 @@ public void compile() {
CompilationUnit compilationUnit = new CompilationUnit(compilerConfiguration);
compilationUnit.addSource(
new SourceUnit(name, compiledSource, compilerConfiguration, tClassLoader, compilationUnit.getErrorCollector()));
<<<<<<< HEAD

Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations");
phasesF.setAccessible(true);
Collection[] phases = (Collection[]) 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() {
>>>>>>> 6d8b253a (#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source (#1338))
@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
5 changes: 4 additions & 1 deletion 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,7 +22,11 @@ private static void mockRequestAndResponse() {
}

public static void setSendOnlyIfChangedConstant(boolean value) {
<<<<<<< HEAD
Scope.SESSION_SEND_ONLY_IF_CHANGED = value;
=======
Scope.SESSION_SEND_ONLY_IF_CHANGED = value;
>>>>>>> 6d8b253a (#5: Update to latest Eclipse JDT Core v3.23 to enable JDK 14 source (#1338))
}

@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 0055395

Please sign in to comment.