Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/full-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
- name: Checkout GWT tools into a sibling directory
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0
with:
repository: 'gwtproject/tools'
repository: 'zbynek/tools'
path: 'tools'
ref: 'jdt'
- name: Set up JDK ${{ matrix.java-version }}
# GWT requires Java 17+ to build
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 #v5.4.0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/quick-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ jobs:
- name: Checkout GWT tools into a sibling directory
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0
with:
repository: 'gwtproject/tools'
repository: 'zbynek/tools'
path: 'tools'
ref: 'jdt'
- name: Set up JDK ${{ matrix.java-version }}
# GWT presently requires Java 17+ to build
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 #v5.4.0
Expand Down
6 changes: 3 additions & 3 deletions dev/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<include name="apache/tapestry-util-text-4.0.2.jar"/>
<include name="apache/ant-zipscanner/ant-zipscanner-1.6.5-1-rebased.jar"/>
<include name="colt/colt-1.2.jar"/>
<include name="eclipse/3.33.0/*.jar"/>
<include name="eclipse/3.40.0/*.jar"/>
<include name="objectweb/asm-9.10.1/asm-9.10.1.jar"/>
<include name="objectweb/asm-9.10.1/asm-commons-9.10.1.jar"/>
<include name="objectweb/asm-9.10.1/asm-util-9.10.1.jar"/>
Expand Down Expand Up @@ -125,7 +125,7 @@
<zipfileset src="${gwt.tools.lib}/apache/tapestry-util-text-4.0.2.jar"/>
<zipfileset src="${gwt.tools.lib}/apache/ant-zipscanner/ant-zipscanner-1.6.5-1-rebased.jar"/>
<zipfileset src="${gwt.tools.lib}/colt/colt-1.2.jar"/>
<zipgroupfileset dir="${gwt.tools.lib}/eclipse/3.33.0">
<zipgroupfileset dir="${gwt.tools.lib}/eclipse/3.40.0">
<include name="**/*.jar"/>
</zipgroupfileset>
<zipfileset src="${gwt.tools.lib}/guava/guava-33.0/guava-33.0.0-jre-rebased.jar"/>
Expand Down Expand Up @@ -218,7 +218,7 @@
<pathelement location="${gwt.tools.lib}/objectweb/asm-9.10.1/asm-9.10.1.jar"/>
<pathelement location="${gwt.tools.lib}/objectweb/asm-9.10.1/asm-commons-9.10.1.jar"/>
<pathelement location="${gwt.tools.lib}/objectweb/asm-9.10.1/asm-util-9.10.1.jar"/>
<fileset dir="${gwt.tools.lib}/eclipse/3.33.0">
<fileset dir="${gwt.tools.lib}/eclipse/3.40.0">
<include name="**/*.jar"/>
</fileset>
<pathelement
Expand Down
5 changes: 5 additions & 0 deletions dev/core/src/com/google/gwt/dev/DevMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ public void run() {
servletValidator = ServletValidator.create(getTopLogger(), webXml);
} else {
servletWriter = new ServletWriter();
servletWriter.setJspLevel(getJspLevel());
}
}

Expand Down Expand Up @@ -757,6 +758,10 @@ protected void warnAboutNoStartupUrls() {
"No startup URLs supplied and no plausible ones found -- use " + "-startupUrl");
}

protected String getJspLevel() {
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that JSPs don't work any more in dev mode? Did they before this patch?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did they before this patch?

Yes, if you either stick with Java 1.7 syntax or provide your own web.xml.

JSPs don't work any more in dev mode

If you provide your own web.xml (setting Java level to 1.8 or higher), they should still work. Without it, they will fail.

I wasn't sure what we want (could we break something by creating web.xml for projects that don't need it?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so need a release note entry on this, that 1.7 won't work any more, and newer formats require an explicit web.xml entry.

}

private void validateServletTags(TreeLogger logger, ServletValidator servletValidator,
ServletWriter servletWriter, ModuleDef module) {
String[] servletPaths = module.getServletPaths();
Expand Down
27 changes: 25 additions & 2 deletions dev/core/src/com/google/gwt/dev/ServletWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ static String generateServletTag(String servletName, String servletClass) {
}

Map<String, String> mappings = new LinkedHashMap<String, String>();
private String jspLevel;

public void addMapping(String servletClass, String servletPath) {
mappings.put(servletClass, servletPath);
}

public void setJspLevel(String jspLevel) {
this.jspLevel = jspLevel;
}

public void realize(File webXml) throws IOException {
if (mappings.size() == 0) {
if (mappings.isEmpty() && jspLevel == null) {
// Only generate a file if necessary.
return;
}
Expand All @@ -81,7 +86,25 @@ public void realize(File webXml) throws IOException {
xmlWriter.write(generateServletMappingTag(servletName, servletPath));
xmlWriter.write('\n');
}

if (jspLevel != null) {
if (!jspLevel.matches("[0-9.]*")) { // lenient, but ensures valid XML
throw new IllegalStateException("Invalid JSP Java level: " + jspLevel);
}
xmlWriter.write(String.format("""
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>%1$s</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>%1$s</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>""", jspLevel));
}
xmlWriter.write("\n</web-app>\n");
}
}
Expand Down
5 changes: 1 addition & 4 deletions dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ private NameEnvironmentAnswer doFindTypeInClassPath(String internalName) {
try (InputStream openStream = resource.openStream()) {

ClassFileReader classFileReader =
ClassFileReader.read(openStream, resource.toExternalForm(), true);
ClassFileReader.read(openStream, resource.toExternalForm());
// In case-insensitive file systems we might have found a resource whose name is
// different in case and should not be returned as an answer.
if (internalName.equals(CharOperation.charToString(classFileReader.getName()))) {
Expand Down Expand Up @@ -674,7 +674,6 @@ public static CompilerOptions getStandardCompilerOptions() {
};

long jdtSourceLevel = jdtLevelByGwtLevel.get(SourceLevel.DEFAULT_SOURCE_LEVEL);
options.originalSourceLevel = jdtSourceLevel;
options.complianceLevel = jdtSourceLevel;
options.sourceLevel = jdtSourceLevel;
options.targetJDK = jdtSourceLevel;
Expand All @@ -694,15 +693,13 @@ public static CompilerOptions getStandardCompilerOptions() {
// Turn off all warnings, saves some memory / speed.
options.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = false;
options.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = false;
options.inlineJsrBytecode = true;
Comment thread
zbynek marked this conversation as resolved.
return options;
}

public CompilerOptions getCompilerOptions() {
CompilerOptions options = getStandardCompilerOptions();
long jdtSourceLevel = jdtLevelByGwtLevel.get(sourceLevel);

options.originalSourceLevel = jdtSourceLevel;
options.complianceLevel = jdtSourceLevel;
options.sourceLevel = jdtSourceLevel;
options.targetJDK = jdtSourceLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,54 @@ public class JavaResourceBase {
"package java.util;",
"public interface Map<K,V> { }");

public static final MockJavaResource METHOD_HANDLE =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going over the rest of GWT, I don't see actual emulation for these provided, so how does a normal compile have these (or not need them) while a test must get them from here?

I do see com.google.gwt.dev.javac.JdtCompiler.INameEnvironmentImpl#getLambdaMetafactoryBytes and friends, but nothing that provides MethodHandle or MethodHandles itself, nor StringConcatFactory. Does the newer JDT require these so we'll want general emulation for these, or maybe these were needed for an earlier iteration but no longer (e.g. to try to deal with emulating Record method before Objects was added)?

createMockJavaResource("java.lang.invoke.MethodHandle",
"""
package java.lang.invoke;
public abstract class MethodHandle { }
""");

public static final MockJavaResource METHOD_HANDLES =
createMockJavaResource("java.lang.invoke.MethodHandles",
"""
package java.lang.invoke;
public class MethodHandles {
public static final class Lookup {
public MethodHandle findVirtual(Class<?> refc, String name,
MethodType type) {
return null;
}

public MethodHandle findStatic(Class<?> refc, String name,
MethodType type) {
return null;
}
}

public static Lookup lookup() {
return null;
}
}
""");

public static final MockJavaResource METHOD_TYPE =
createMockJavaResource("java.lang.invoke.MethodType",
"""
package java.lang.invoke;
public final class MethodType {
public static MethodType methodType(Class<?> rtype, Class<?> ptype0,
Class<?>... ptypes) {
return null;
}
public static MethodType methodType(Class<?> rtype) {
return null;
}
public static MethodType genericMethodType(int objectArgCount) {
return null;
}
}
""");

public static final MockJavaResource NO_CLASS_DEF_FOUND_ERROR =
createMockJavaResource("java.lang.NoClassDefFoundError",
"package java.lang;",
Expand Down Expand Up @@ -364,6 +412,13 @@ public class JavaResourceBase {
"public final class StringBuilder {",
"}");

public static final MockJavaResource STRING_CONCAT_FACTORY =
createMockJavaResource("java.lang.invoke.StringConcatFactory",
"""
package java.lang.invoke;
public final class StringConcatFactory {}
""");

public static final MockJavaResource SUPPRESS_WARNINGS =
createMockJavaResource("java.lang.SuppressWarnings",
"package java.lang;",
Expand Down Expand Up @@ -467,7 +522,8 @@ public static MockJavaResource[] getStandardResources() {
AUTOCLOSEABLE, ANNOTATION, ARRAY_LIST, BYTE, BOOLEAN, CHARACTER, CHAR_SEQUENCE, CLASS,
CLASS_NOT_FOUND_EXCEPTION, CLONEABLE, COLLECTION, COMPARABLE, DOUBLE, ENUM, EXCEPTION,
ERROR, FUNCTIONALINTERFACE, FLOAT, INTEGER, IS_SERIALIZABLE, JAVASCRIPTEXCEPTION,
JAVASCRIPTOBJECT, LIST, LONG, MAP, NO_CLASS_DEF_FOUND_ERROR, NUMBER, OBJECT, OBJECTMETHODS,
JAVASCRIPTOBJECT, LIST, LONG, MAP, METHOD_HANDLES, NO_CLASS_DEF_FOUND_ERROR,
NUMBER, OBJECT, OBJECTMETHODS, METHOD_HANDLE, METHOD_TYPE, STRING_CONCAT_FACTORY,
OBJECTS, RECORD, RUNTIME_EXCEPTION, SERIALIZABLE, SHORT, STRING, STRING_BUILDER,
SUPPRESS_WARNINGS, SYSTEM, THROWABLE, SPECIALIZE_METHOD, DO_NOT_AUTOBOX, JSTYPE,
JSCONSTRUCTOR, JSPACKAGE, JSPROPERTY, JSMETHOD, JSIGNORE, JSFUNCTION, JSOVERLAY,
Expand Down
29 changes: 26 additions & 3 deletions dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ private TypeBinding getFirstNonObjectInIntersection(IntersectionTypeBinding18 re

@Override
public void endVisit(ConstructorDeclaration x, ClassScope scope) {
if (isOverriddenCanonicalConstructor(x)) {
return;
}
try {
List<JStatement> statements = pop(x.statements);
JStatement constructorCall = pop(x.constructorCall);
Expand Down Expand Up @@ -2267,6 +2270,10 @@ public void endVisit(SwitchExpression x, BlockScope scope) {

@Override
public void endVisit(SwitchStatement x, BlockScope scope) {
if (x instanceof SwitchExpression switchExpression) {
endVisit(switchExpression, scope);
return;
}
try {
SourceInfo info = makeSourceInfo(x);

Expand Down Expand Up @@ -2596,6 +2603,9 @@ public boolean visit(Block x, BlockScope scope) {

@Override
public boolean visit(ConstructorDeclaration x, ClassScope scope) {
if (isOverriddenCanonicalConstructor(x)) {
return false;
}
try {
JConstructor method = (JConstructor) typeMap.get(x.binding);
assert !method.isExternal();
Expand Down Expand Up @@ -2731,6 +2741,9 @@ public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {

@Override
public boolean visit(SwitchStatement x, BlockScope scope) {
if (x instanceof SwitchExpression switchExpression) {
return visit(switchExpression, scope);
}
try {
x.statements = reduceToReachable(x.statements);
return true;
Expand Down Expand Up @@ -4331,6 +4344,9 @@ private void createMembers(TypeDeclaration x) {

if (x.methods != null) {
for (AbstractMethodDeclaration method : x.methods) {
if (isOverriddenCanonicalConstructor(method)) {
continue;
}
createMethod(method);
}
}
Expand Down Expand Up @@ -4400,6 +4416,9 @@ private void createMethod(AbstractMethodDeclaration x) {
if (x instanceof Clinit) {
return;
}
if (x.binding == null) {
throw new IllegalArgumentException("Missing method binding for " + x);
}
SourceInfo info = makeSourceInfo(x);
MethodBinding b = x.binding;
ReferenceBinding declaringClass = (ReferenceBinding) b.declaringClass.erasure();
Expand Down Expand Up @@ -4630,7 +4649,7 @@ private void createTypes(TypeDeclaration x) {
}
} catch (Throwable e) {
InternalCompilerException ice = translateException(null, e);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
x.printHeader(0, sb);
ice.addNode(x.getClass().getName(), sb.toString(), info);
throw ice;
Expand Down Expand Up @@ -4679,7 +4698,7 @@ private void resolveTypeRefs(TypeDeclaration x) {
private InternalCompilerException getInternalCompilerException(TypeDeclaration x, Throwable e) {
JDeclaredType type = (JDeclaredType) typeMap.get(x.binding);
InternalCompilerException ice = translateException(null, e);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
x.printHeader(0, sb);
ice.addNode(x.getClass().getName(), sb.toString(), type.getSourceInfo());
return ice;
Expand Down Expand Up @@ -4724,9 +4743,13 @@ private static boolean isSuperReference(Expression expression) {
return expression instanceof SuperReference || expression instanceof QualifiedSuperReference;
}

private boolean isOverriddenCanonicalConstructor(AbstractMethodDeclaration method) {
return method.binding == null && method.isCanonicalConstructor();
}

static class JdtPrivateHacks {
/**
* Reflective access to {@link ForeachStatement#collectionElementType}.
* Reflective access to {@link ForeachStatement}'s {@code collectionElementType} field.
*/
private static final Field collectionElementTypeField;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
*/
package com.google.gwt.dev.jjs.impl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
* Annotation with no bytecode for GWT, and no members.
*/
@Target({ElementType.METHOD, ElementType.TYPE_USE})
public @interface SampleBytecodeOnlyMarkerAnnotation {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
*/
package com.google.gwt.dev.jjs.impl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
* Annotation with no bytecode for GWT, and multiple members.
*/
@Target({ElementType.METHOD, ElementType.TYPE_USE})
public @interface SampleBytecodeOnlyNormalAnnotation {
int a();
int b();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
*/
package com.google.gwt.dev.jjs.impl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
* Annotation with no bytecode for GWT, and a single member.
*/
@Target({ElementType.METHOD, ElementType.TYPE_USE})
Comment thread
niloc132 marked this conversation as resolved.
public @interface SampleBytecodeOnlySingleMemberAnnotation {
String value();
}
2 changes: 1 addition & 1 deletion maven/poms/gwt/pom-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.33.0</version>
<version>3.40.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
5 changes: 5 additions & 0 deletions user/src/com/google/gwt/junit/JUnitShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,11 @@ public void destroy() { }
}), path, EnumSet.of(DispatcherType.REQUEST));
}

@Override
protected String getJspLevel() {
return "17";
}

private void checkArgs() {
if (runStyle.getTries() > 1
&& !(batchingStrategy instanceof NoBatchingStrategy)) {
Expand Down
Loading
Loading