Skip to content

Commit

Permalink
Add support for Java 15
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza authored and fbricon committed Sep 18, 2020
1 parent a8b7cc9 commit 5327f23
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 2 deletions.
4 changes: 4 additions & 0 deletions org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<repository location="https://download.eclipse.org/lsp4j/updates/releases/0.9.0/"/>
<unit id="org.eclipse.lsp4j.sdk.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/eclipse/updates/4.17-P-builds/P20200916-1110"/>
<unit id="org.eclipse.jdt.java15patch.feature.group" version="0.0.0"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
</target>
Binary file added org.eclipse.jdt.ls.tests/fakejdk/15/rtstubs.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions org.eclipse.jdt.ls.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<version>0.0.0</version>
<type>eclipse-feature</type>
</dependency>
<dependency>
<artifactId>org.eclipse.jdt.java15patch</artifactId>
<version>0.0.0</version>
<type>eclipse-feature</type>
</dependency>
</dependencies>
</configuration>
</plugin>
Expand Down
10 changes: 10 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/eclipse/java15/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 changes: 17 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/eclipse/java15/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java15</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=15
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=15
org.eclipse.jdt.core.compiler.release=enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package foo.bar;

/**
* It's a Foo class
*/
public sealed interface Foo
permits Bar {
}
record Bar(String name) implements Foo { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.sample;

public class Test {
}
27 changes: 27 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/maven/salut-java15/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/maven/salut-java15/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>salut-java15</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
org.eclipse.jdt.core.compiler.compliance=15
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=15
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
26 changes: 26 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/maven/salut-java15/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo.bar</groupId>
<artifactId>salut-java15</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>15</release>
<compilerArgument>--enable-preview</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sample;

/**
* This is Bar
*/
public class Bar {

public static void main(String[] args) {
Object foo = "x";
if (foo instanceof String str) {
System.out.println(str);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private IProject mockProject(IWorkspaceRoot root, String name, boolean exists) {

@Test
public void testPreviewFeaturesDisabledByDefault() throws Exception {
String name = "java14";
String name = "java15";
importProjects("eclipse/" + name);
IProject project = getProject(name);
assertIsJavaProject(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void getPackageName() throws Exception {
public void testPreviewFeaturesEnabledByDefault() throws Exception {
String defaultJVM = JavaRuntime.getDefaultVMInstall().getId();
try {
TestVMType.setTestJREAsDefault("14");
TestVMType.setTestJREAsDefault("15");
IProject invisibleProject = copyAndImportFolder("singlefile/java14", "foo/bar/Foo.java");
assertTrue(invisibleProject.exists());
assertNoErrors(invisibleProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ public void testJava14Project() throws Exception {
IJavaProject javaProject = JavaCore.create(project);
assertEquals(JavaCore.ENABLED, javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, false));
assertEquals(JavaCore.IGNORE, javaProject.getOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, false));
assertHasErrors(project, "Preview features enabled at an invalid source release level");
}

@Test
public void testJava15Project() throws Exception {
IProject project = importMavenProject("salut-java15");
assertIsJavaProject(project);
assertEquals("15", getJavaSourceLevel(project));
IJavaProject javaProject = JavaCore.create(project);
assertEquals(JavaCore.ENABLED, javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, false));
assertEquals(JavaCore.IGNORE, javaProject.getOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, false));
assertNoErrors(project);
}

Expand Down

0 comments on commit 5327f23

Please sign in to comment.