Skip to content

Commit 94e70e0

Browse files
committed
* fixed: failed to build RoboVM using Java19
## Root cases: - Tests started to fail due JDK changes in toString() of annotations (openjdk/jdk#7418). - Eclipse Tycho has to be updated to know JDK19-env ## Fixes: - tycho updated to 3.0.3. This also cause update-side to be migrated to repository (as first one was removed) -- completely not tested - test cases: host JDK18 and JDK19 has different behaviour -- test cases were updated just to recognize this case and adapt string to match JDK18/RoboVM
1 parent 0816ac5 commit 94e70e0

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

.github/workflows/snapshot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
- name: Deploy idea plugin
4545
run: aws s3 sync ./plugins/idea/build/distributions/ s3://${{ secrets.AWS_BUCKET }}/snapshots/idea --acl public-read --follow-symlinks --delete
4646
- name: Deploy eclipse plugin
47-
run: aws s3 sync ./plugins/eclipse/update-site/target/site/ s3://${{ secrets.AWS_BUCKET }}/snapshots/eclipse --acl public-read --follow-symlinks --delete
47+
run: aws s3 sync ./plugins/eclipse/update-site/target/repository/ s3://${{ secrets.AWS_BUCKET }}/snapshots/eclipse --acl public-read --follow-symlinks --delete

compiler/compiler/src/test/java/org/robovm/compiler/plugin/annotation/AnnotationImplPluginTest.java

+30-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void testCreateImplNoMembers() throws Exception {
195195
assertTrue(annotation.equals(impl1));
196196
assertTrue(impl1.equals(annotation));
197197
assertEquals(annotation.hashCode(), impl1.hashCode());
198-
assertEquals(annotation.toString(), impl1.toString());
198+
assertEquals(toString(annotation), toString(impl1));
199199
assertSame(annotation.annotationType(), impl1.annotationType());
200200
}
201201

@@ -359,4 +359,33 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {
359359
}.loadClass(className);
360360
return implClass;
361361
}
362+
363+
// dkitmisa: JDK19+ uses getCanonicalName() instead of getName() to build toString()
364+
// as result this will make tests to fail as RoboVM uses old one.
365+
// at same time have to keep compatibility when running on JDK18- hosts.
366+
// workaround is to replace getCanonicalName() with getName() in returned string
367+
// to make it looks same as on RoboVM and JDK18-
368+
// details: https://github.com/openjdk/jdk/pull/7418
369+
private static String toString(Annotation anno) {
370+
String s = anno.toString();
371+
if (java19orHigher) {
372+
String canonicalName = anno.annotationType().getCanonicalName();
373+
String binaryName = anno.annotationType().getName();
374+
if (canonicalName != null && !canonicalName.isEmpty() && !canonicalName.equals(binaryName) &&
375+
s.startsWith("@" + canonicalName + "(")) {
376+
// replace canonical class name with binary name to keep compatibility with RoboVM implementation
377+
return "@" + binaryName + "(" + s.substring(2 + canonicalName.length());
378+
}
379+
}
380+
381+
return s;
382+
}
383+
private final static boolean java19orHigher = isJava19orHigher();
384+
private static boolean isJava19orHigher() {
385+
try {
386+
return Integer.parseInt(System.getProperty("java.specification.version")) >= 19;
387+
} catch (NumberFormatException ignored) {
388+
return false;
389+
}
390+
}
362391
}

plugins/eclipse/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<properties>
3131
<robovm.version>2.3.19-SNAPSHOT</robovm.version>
32-
<tycho.version>2.5.0</tycho.version>
32+
<tycho.version>3.0.3</tycho.version>
3333
<eclipse-site>https://download.eclipse.org/releases/2021-09/</eclipse-site>
3434
</properties>
3535

File renamed without changes.

plugins/eclipse/update-site/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
<artifactId>org.robovm.eclipse.update-site</artifactId>
1313
<name>RoboVM for Eclipse Update Site</name>
14-
<packaging>eclipse-update-site</packaging>
14+
<packaging>eclipse-repository</packaging>
1515
</project>

release.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ git push
2929

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

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

0 commit comments

Comments
 (0)