Skip to content

Commit

Permalink
Merge pull request MobiVM#709 from dkimitsa/fix/building_on_jdk19
Browse files Browse the repository at this point in the history
* fixed: failed to build RoboVM using Java19
  • Loading branch information
Tom-Ski authored Mar 20, 2023
2 parents 70acf42 + d623486 commit 4a81986
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.11
java-version: '17'

- name: Install dependencies
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.11
java-version: '17'
server-id: sonatype-nexus-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand All @@ -45,4 +45,4 @@ jobs:
- name: Deploy idea plugin
run: aws s3 sync ./plugins/idea/build/distributions/ s3://${{ secrets.AWS_BUCKET }}/snapshots/idea --acl public-read --follow-symlinks --delete
- name: Deploy eclipse plugin
run: aws s3 sync ./plugins/eclipse/update-site/target/site/ s3://${{ secrets.AWS_BUCKET }}/snapshots/eclipse --acl public-read --follow-symlinks --delete
run: aws s3 sync ./plugins/eclipse/update-site/target/repository/ s3://${{ secrets.AWS_BUCKET }}/snapshots/eclipse --acl public-read --follow-symlinks --delete
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void testCreateImplNoMembers() throws Exception {
assertTrue(annotation.equals(impl1));
assertTrue(impl1.equals(annotation));
assertEquals(annotation.hashCode(), impl1.hashCode());
assertEquals(annotation.toString(), impl1.toString());
assertEquals(toString(annotation), toString(impl1));
assertSame(annotation.annotationType(), impl1.annotationType());
}

Expand Down Expand Up @@ -359,4 +359,33 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {
}.loadClass(className);
return implClass;
}

// dkitmisa: JDK19+ uses getCanonicalName() instead of getName() to build toString()
// as result this will make tests to fail as RoboVM uses old one.
// at same time have to keep compatibility when running on JDK18- hosts.
// workaround is to replace getCanonicalName() with getName() in returned string
// to make it looks same as on RoboVM and JDK18-
// details: https://github.com/openjdk/jdk/pull/7418
private static String toString(Annotation anno) {
String s = anno.toString();
if (java19orHigher) {
String canonicalName = anno.annotationType().getCanonicalName();
String binaryName = anno.annotationType().getName();
if (canonicalName != null && !canonicalName.isEmpty() && !canonicalName.equals(binaryName) &&
s.startsWith("@" + canonicalName + "(")) {
// replace canonical class name with binary name to keep compatibility with RoboVM implementation
return "@" + binaryName + "(" + s.substring(2 + canonicalName.length());
}
}

return s;
}
private final static boolean java19orHigher = isJava19orHigher();
private static boolean isJava19orHigher() {
try {
return Integer.parseInt(System.getProperty("java.specification.version")) >= 19;
} catch (NumberFormatException ignored) {
return false;
}
}
}
2 changes: 1 addition & 1 deletion plugins/eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<properties>
<robovm.version>2.3.20-SNAPSHOT</robovm.version>
<tycho.version>2.5.0</tycho.version>
<tycho.version>3.0.3</tycho.version>
<eclipse-site>https://download.eclipse.org/releases/2021-09/</eclipse-site>
</properties>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/eclipse/update-site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

<artifactId>org.robovm.eclipse.update-site</artifactId>
<name>RoboVM for Eclipse Update Site</name>
<packaging>eclipse-update-site</packaging>
<packaging>eclipse-repository</packaging>
</project>
4 changes: 2 additions & 2 deletions plugins/gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.0"
id "com.github.johnrengelman.shadow" version "8.1.0"
id 'java'
id 'groovy'
id 'maven-publish'
Expand Down Expand Up @@ -103,7 +103,7 @@ java {
}

shadowJar {
classifier = ''
archiveClassifier.set('')
dependencies {
exclude(dependency("com.mobidevelop.robovm:robovm-compiler:${roboVMVersion}"));
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions plugins/idea/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id "org.jetbrains.intellij" version "1.5.2"
id "org.jetbrains.intellij" version "1.13.2"
}

ext {
Expand Down Expand Up @@ -44,7 +44,7 @@ intellij {
updateSinceUntilBuild = false
}

task copyRoboVmDist(type: Copy) {
def copyRoboVmDist = tasks.register("copyRoboVmDist", Copy) {
from configurations.robovm_dist
into "src/main/resources/"
rename "robovm-dist-${roboVMVersion}-nocompiler.tar.gz", "robovm-dist"
Expand All @@ -53,6 +53,6 @@ task copyRoboVmDist(type: Copy) {

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava {
tasks.named("patchPluginXml").configure {
dependsOn copyRoboVmDist
}
2 changes: 1 addition & 1 deletion plugins/idea/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions plugins/idea/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
pluginManagement {
repositories {
mavenCentral() // as workaround for failing jcenter
gradlePluginPortal()
}
}

rootProject.name = 'idea'
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ git push

# Copy the update-site/target/ to whereever you want it
ssh [email protected] "mkdir -p /usr/share/nginx/html/downloads/releases/eclipse/$RELEASE_VERSION"
scp -r update-site/target/site/ [email protected]:/usr/share/nginx/html/downloads/releases/eclipse/$RELEASE_VERSION/
scp -r update-site/target/repository/ [email protected]:/usr/share/nginx/html/downloads/releases/eclipse/$RELEASE_VERSION/

# Set the pom version to the next development version
mvn org.eclipse.tycho:tycho-versions-plugin:1.5.1:set-version -DnewVersion="$DEVELOPMENT_VERSION-SNAPSHOT"
Expand Down

0 comments on commit 4a81986

Please sign in to comment.