Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial preparation for Java 21 #2986

Merged
merged 26 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
844e64a
Java 21 in GitHub Actions
LorenzoBettini Apr 4, 2024
47bb354
Added Java 21 to toolchains.xml
LorenzoBettini Apr 4, 2024
80273b7
strict-jdk-21 profile
LorenzoBettini Apr 4, 2024
b7d1e6f
maven.compiler.release 21 in strict-jdk-21 profile
LorenzoBettini Apr 5, 2024
f8f4957
ContentAssistTest not dependent on Java API
LorenzoBettini Apr 6, 2024
f99bc93
maven-plugin-plugin 3.12.0
LorenzoBettini Apr 6, 2024
a64804a
use StubbedList not dependent on Java AbstractList API
LorenzoBettini Apr 6, 2024
f5a59f0
don't use last as extension method
LorenzoBettini Apr 6, 2024
3546425
stubbed list in AbstractTypeArgumentTest
LorenzoBettini Apr 7, 2024
27f2cf3
discard the new wait0 private method in Object
LorenzoBettini Apr 7, 2024
57e8d52
deal with List changes in Java 21 and fixed bug in publicNativeMethod
LorenzoBettini Apr 7, 2024
7d58ba6
skip strictfp tests for Java 18 and later
LorenzoBettini Apr 7, 2024
9057ca6
don't use last as extension method in Xtend formatter
LorenzoBettini Apr 7, 2024
f168b21
fixed a few Xtend type tests
LorenzoBettini Apr 9, 2024
7736942
added some information for assertEquals
LorenzoBettini Apr 9, 2024
6ba2ac8
StubbedSuppressWarnings
LorenzoBettini Apr 9, 2024
4d84366
updated compiler tests to use lastOrNull
LorenzoBettini Apr 9, 2024
144e179
fixed Xtend outline tests for new members in Java 21
LorenzoBettini Apr 9, 2024
5e4c16d
fixed Xtend content assist tests for new members in Java 21
LorenzoBettini Apr 9, 2024
fc2847d
build matrix with Java 21 (Linux only)
LorenzoBettini Apr 9, 2024
ada1b3d
different cache based on Java version
LorenzoBettini Apr 9, 2024
69ec75d
removed isJava18OrLater and use isJava21OrLater
LorenzoBettini Apr 9, 2024
6bf27b6
JAVA_HOME_21_X64 in Jenkinsfile
LorenzoBettini Apr 9, 2024
762b1e6
simplified the custom injector provider
LorenzoBettini Apr 20, 2024
6cc978f
use toolchains.xml generated by setup-java
LorenzoBettini Apr 25, 2024
d3c35d7
updated xtend gen file
LorenzoBettini Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,32 @@ jobs:
strategy:
matrix: # 'macos-14' is arm64
os: ['ubuntu-22.04', 'macos-14', 'windows-2022']
java: [ 17 ]
include:
- os: ubuntu-22.04
java: 21
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: 'Check out repository'
uses: actions/checkout@v4

- name: 'Set up Java'
- name: 'Set up Java ${{ matrix.java }}'
uses: actions/setup-java@v4
with:
java-version: 17
java-version: ${{ matrix.java }}
distribution: 'temurin'

- name: Copy toolchains.xml
run: cat ~/.m2/toolchains.xml | tee toolchains.xml

- name: 'Cache Maven packages'
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-m2
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-m2-${{ matrix.java }}

- name: Set Maven Home environment variable
run: echo "MAVEN_WRAPPER_HOME=$(./mvnw --version | grep "Maven home:" | cut -c 13-)" >> "$GITHUB_ENV"
Expand All @@ -46,7 +53,7 @@ jobs:
- name: Build and test
uses: coactions/setup-xvfb@v1.0.1
with:
run: ./mvnw clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.full.releng
run: ./mvnw --toolchains toolchains.xml clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.full.releng

- name: Archive Test Results
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -75,6 +82,9 @@ jobs:
java-version: 17
distribution: 'temurin'

- name: Copy toolchains.xml
run: cat ~/.m2/toolchains.xml | tee toolchains.xml

- name: 'Cache Maven packages'
uses: actions/cache@v4
with:
Expand All @@ -86,7 +96,7 @@ jobs:
run: echo "MAVEN_WRAPPER_HOME=$(./mvnw --version | grep "Maven home:" | cut -c 13-)" >> "$GITHUB_ENV"

- name: Build Maven artifacts
run: ./mvnw clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.maven.releng
run: ./mvnw --toolchains toolchains.xml clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.maven.releng

- name: Archive Test Results
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pipeline {
MAVEN_OPTS = "-Xmx1500m"
JAVA_HOME_11_X64 = tool(type:'jdk', name:'temurin-jdk11-latest')
JAVA_HOME_17_X64 = tool(type:'jdk', name:'temurin-jdk17-latest')
JAVA_HOME_21_X64 = tool(type:'jdk', name:'temurin-jdk21-latest')
}
steps {
xvnc(useXauthority: true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
result += new WhitespaceData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange,
if (trace) new RuntimeException(), if (leaf.offset == 0) "" else if(leafs.containsComment) null else " ")
else
if(equalIndentationChange && leafs.leafs.last != leaf)
if(equalIndentationChange && leafs.leafs.lastOrNull != leaf)
result += new NewLineData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
else
result += new NewLineData(leaf.offset, leaf.length, if(equalIndentationChange) 0 else increaseIndentationChange, if(equalIndentationChange) 0 else decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
Expand All @@ -1023,7 +1023,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
var newLines = 1
if (leaf.leadingComment?.endsWithNewLine)
newLines = newLines - 1
if(equalIndentationChange && leafs.leafs.last != leaf)
if(equalIndentationChange && leafs.leafs.lastOrNull != leaf)
result += new NewLineData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
else
result += new NewLineData(leaf.offset, leaf.length, 0, 0, if (trace) new RuntimeException(), newLines)
Expand Down Expand Up @@ -1472,7 +1472,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
WhitespaceData _whitespaceData_1 = new WhitespaceData(_offset_2, _length_1, increaseIndentationChange, decreaseIndentationChange, _xifexpression_3, _xifexpression_4);
result.add(_whitespaceData_1);
} else {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>lastOrNull(leafs.getLeafs()), leaf)))) {
int _offset_4 = ((WhitespaceInfo)leaf).getOffset();
int _length_2 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_6 = null;
Expand Down Expand Up @@ -1515,7 +1515,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
if (_endsWithNewLine_2) {
newLines_1 = (newLines_1 - 1);
}
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>lastOrNull(leafs.getLeafs()), leaf)))) {
int _offset_6 = ((WhitespaceInfo)leaf).getOffset();
int _length_4 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_10 = null;
Expand Down Expand Up @@ -1672,5 +1672,5 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
}
}
''')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ class CompilerBug427637Test extends org.eclipse.xtend.core.tests.compiler.Compil
result += new WhitespaceData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange,
if (trace) new RuntimeException(), if (leaf.offset == 0) "" else if(leafs.containsComment) null else " ")
else
if(equalIndentationChange && leafs.leafs.last != leaf)
if(equalIndentationChange && leafs.leafs.lastOrNull != leaf)
result += new NewLineData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
else
result += new NewLineData(leaf.offset, leaf.length, if(equalIndentationChange) 0 else increaseIndentationChange, if(equalIndentationChange) 0 else decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
Expand All @@ -977,7 +977,7 @@ class CompilerBug427637Test extends org.eclipse.xtend.core.tests.compiler.Compil
var newLines = 1
if (leaf.leadingComment?.endsWithNewLine)
newLines = newLines - 1
if(equalIndentationChange && leafs.leafs.last != leaf)
if(equalIndentationChange && leafs.leafs.lastOrNull != leaf)
result += new NewLineData(leaf.offset, leaf.length, increaseIndentationChange, decreaseIndentationChange, if (trace) new RuntimeException(), newLines)
else
result += new NewLineData(leaf.offset, leaf.length, 0, 0, if (trace) new RuntimeException(), newLines)
Expand Down Expand Up @@ -1417,7 +1417,7 @@ class CompilerBug427637Test extends org.eclipse.xtend.core.tests.compiler.Compil
WhitespaceData _whitespaceData_1 = new WhitespaceData(_offset_2, _length_1, increaseIndentationChange, decreaseIndentationChange, _xifexpression_3, _xifexpression_4);
result.add(_whitespaceData_1);
} else {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>lastOrNull(leafs.getLeafs()), leaf)))) {
int _offset_4 = ((WhitespaceInfo)leaf).getOffset();
int _length_2 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_6 = null;
Expand Down Expand Up @@ -1460,7 +1460,7 @@ class CompilerBug427637Test extends org.eclipse.xtend.core.tests.compiler.Compil
if (_endsWithNewLine_2) {
newLines_1 = (newLines_1 - 1);
}
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>lastOrNull(leafs.getLeafs()), leaf)))) {
int _offset_6 = ((WhitespaceInfo)leaf).getOffset();
int _length_4 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_10 = null;
Expand Down Expand Up @@ -1613,5 +1613,5 @@ class CompilerBug427637Test extends org.eclipse.xtend.core.tests.compiler.Compil
}
}
''')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DeclarationsTest extends AbstractXtendTestCase {

@Test def testAnnotation() {
validFile('''
@SuppressWarnings("unused")
@testdata.stubs.StubbedSuppressWarnings("unused")
class MyClass {
@com.google.inject.Inject(optional=true) MyClass foo
}
Expand All @@ -44,10 +44,12 @@ class DeclarationsTest extends AbstractXtendTestCase {
assertEquals('MyClass', clazz.qualifiedName)
val suppressWarning = clazz.annotations.head
val supressWarningsDeclaration = suppressWarning.annotationTypeDeclaration
assertEquals('java.lang.SuppressWarnings', supressWarningsDeclaration.qualifiedName)
assertEquals('testdata.stubs.StubbedSuppressWarnings', supressWarningsDeclaration.qualifiedName)
assertEquals('unused', suppressWarning.getStringArrayValue('value').get(0))

assertEquals(2, supressWarningsDeclaration.annotations.size)
val annotations = supressWarningsDeclaration.annotations
assertEquals(annotations.map[it.annotationTypeDeclaration].toString,
2, annotations.size)

val valueProperty = supressWarningsDeclaration.declaredMembers.filter(typeof(AnnotationTypeElementDeclaration)).head
assertEquals("String[]", valueProperty.type.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
package org.eclipse.xtend.core.tests.resource

import com.google.inject.Inject
import java.util.Comparator
import org.eclipse.xtend.core.tests.AbstractXtendTestCase
import org.eclipse.xtext.resource.IResourceDescription
import org.junit.Test
import org.junit.Assert
import java.util.Arrays
import java.util.Comparator
import org.junit.Test

class ImportedNamesTest extends AbstractXtendTestCase {
@Inject
Expand Down Expand Up @@ -138,37 +137,37 @@ class ImportedNamesTest extends AbstractXtendTestCase {
import java.util.AbstractMap.*;

class C {
val list = new java.util.ArrayList<Map.Entry>
val list = new testdata.stubs.StubbedArrayList<Map.Entry>
val entry = new SimpleEntry(null, null)
val int i = 0
}
''', true)
val description = resourceDescriptionManager.getResourceDescription(file.eResource)
val importedNames = description.importedNames
Assert.assertEquals(Arrays.asList(
"java.io.serializable",
"java.lang.cloneable",
"java.lang.iterable",
"java.lang.java$util$arraylist",
"java.lang.object",
"java.util.abstractcollection",
"java.util.abstractlist",
"java.util.abstractmap",
"java.util.abstractmap.java$util$arraylist",
"java.util.abstractmap.simpleentry",
"java.util.abstractmap$java$util$arraylist",
"java.util.abstractmap$simpleentry",
"java.util.arraylist",
"java.util.collection",
"java.util.list",
"java.util.map",
"java.util.map$entry",
"java.util.randomaccess",
"java.util$abstractmap$java$util$arraylist",
"java$util$abstractmap$java$util$arraylist",
"my.pack.c",
"my.pack.java$util$arraylist",
"org.eclipse.xtext.xbase.lib.java$util$arraylist").join("\n"),
Assert.assertEquals('''
java.io.serializable
java.lang.cloneable
java.lang.iterable
java.lang.object
java.lang.testdata$stubs$stubbedarraylist
java.util.abstractcollection
java.util.abstractmap
java.util.abstractmap.simpleentry
java.util.abstractmap.testdata$stubs$stubbedarraylist
java.util.abstractmap$simpleentry
java.util.abstractmap$testdata$stubs$stubbedarraylist
java.util.collection
java.util.map
java.util.map$entry
java.util.randomaccess
java.util$abstractmap$testdata$stubs$stubbedarraylist
java$util$abstractmap$testdata$stubs$stubbedarraylist
my.pack.c
my.pack.testdata$stubs$stubbedarraylist
org.eclipse.xtext.xbase.lib.testdata$stubs$stubbedarraylist
testdata.stubs.stubbedabstractlist
testdata.stubs.stubbedarraylist
testdata.stubs.stubbedlist'''.toString.replace("\r", ""),
importedNames.toList.sortWith(Comparator.naturalOrder).join("\n"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import com.google.inject.Inject
import java.io.Serializable
import java.util.Collection
import java.util.Collections
import java.util.List
import org.eclipse.xtend.core.jvmmodel.IXtendJvmAssociations
import org.eclipse.xtext.util.JavaRuntimeVersion
import org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference
import org.junit.Ignore
import org.junit.Test
import org.eclipse.xtext.util.JavaRuntimeVersion
import testdata.stubs.StubbedList

/**
* @author Sebastian Zarnekow
Expand Down Expand Up @@ -167,12 +167,12 @@ class SuperTypesTest extends AbstractSuperTypesTest {

@Test
override void testRawList() {
typeof(List).assertSuperTypes("Collection")
typeof(StubbedList).assertSuperTypes("Collection")
}

@Test
override void testStringList() {
"java.util.List<String>".assertSuperTypes("Collection<String>")
"testdata.stubs.StubbedList<String>".assertSuperTypes("Collection<String>")
}

@Test
Expand Down Expand Up @@ -277,23 +277,23 @@ class AllSuperTypesTest extends AbstractSuperTypesTest {

@Test
override void testRawList() {
typeof(List).assertSuperTypes("Collection", "Iterable", "Object")
typeof(StubbedList).assertSuperTypes("Collection", "Iterable", "Object")
}

@Test
override void testStringList() {
"java.util.List<String>".assertSuperTypes("Collection<String>", "Iterable<String>", "Object")
"testdata.stubs.StubbedList<String>".assertSuperTypes("Collection<String>", "Iterable<String>", "Object")
}

@Test
override void testStringArrayArrayList() {
"java.util.ArrayList<? extends String[]>".assertSuperTypes(
"AbstractList<? extends String[]>",
"testdata.stubs.StubbedArrayList<? extends String[]>".assertSuperTypes(
"StubbedAbstractList<? extends String[]>",
"RandomAccess",
"Cloneable",
"Serializable",
"AbstractCollection<? extends String[]>",
"List<? extends String[]>",
"StubbedList<? extends String[]>",
"Collection<? extends String[]>",
"Iterable<? extends String[]>",
"Object")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2024 Lorenzo Bettini and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package testdata.stubs;

import java.util.AbstractCollection;

/**
* A stub type to use instead of relying on Java API like AbstractList, whose methods and supertypes might change in newer versions (see,
* e.g., https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/SequencedCollection.html).
*
* @author Lorenzo Bettini - Initial contribution and API
*/
public abstract class StubbedAbstractList<E> extends AbstractCollection<E> implements StubbedList<E> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2024 Lorenzo Bettini and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package testdata.stubs;

import java.util.Iterator;
import java.util.RandomAccess;

/**
* A stub type to use instead of relying on Java API like AbstractList, whose methods and supertypes might change in newer versions (see,
* e.g., https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/SequencedCollection.html).
*
* @author Lorenzo Bettini - Initial contribution and API
*/
@SuppressWarnings("serial")
public class StubbedArrayList<E> extends StubbedAbstractList<E>
implements RandomAccess, Cloneable, java.io.Serializable {

@Override
public Iterator<E> iterator() {
return null;
}

@Override
public int size() {
return 0;
}

}