forked from mike-neck/graalvm-native-image-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support the latest GraalVM release (#5)
* ci: upgrade GraalVM versions * ci: fix workflows * fix: add necessary metadata to new versions * fix: support Java 17 * fix: add options to the gu command * fix: support the latest format of ResourceBundleUsage refs oracle/graal#3557 * chore: reformat * fix: stop using Java9 feature for Java8 compatibility Arrays.compare() is not ready to use for Java8 * fix: handle nullness of lists properly * fix: handle nullness of lists properly
- Loading branch information
Showing
5 changed files
with
136 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 74 additions & 10 deletions
84
src/main/java/org/mikeneck/graalvm/config/BundleUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,106 @@ | ||
package org.mikeneck.graalvm.config; | ||
|
||
import java.util.Objects; | ||
import java.util.*; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BundleUsage implements Comparable<BundleUsage> { | ||
|
||
@NotNull public String name = ""; | ||
@Nullable public List<String> classNames; | ||
@Nullable public List<String> locales; | ||
|
||
public BundleUsage() {} | ||
|
||
BundleUsage(@NotNull String name) { | ||
this(name, null, null); | ||
} | ||
|
||
BundleUsage( | ||
@NotNull String name, @Nullable List<String> classNames, @Nullable List<String> locales) { | ||
this.name = name; | ||
this.classNames = classNames; | ||
this.locales = locales; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof BundleUsage)) return false; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
BundleUsage that = (BundleUsage) o; | ||
return name.equals(that.name); | ||
if (!name.equals(that.name)) return false; | ||
if (!Objects.equals(classNames, that.classNames)) return false; | ||
return Objects.equals(locales, that.locales); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name); | ||
int result = name.hashCode(); | ||
result = 31 * result + Objects.hashCode(classNames); | ||
result = 31 * result + Objects.hashCode(locales); | ||
return result; | ||
} | ||
|
||
@SuppressWarnings("StringBufferReplaceableByString") | ||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("ResourceBundleUsage{"); | ||
sb.append("name='").append(name).append('\''); | ||
sb.append('}'); | ||
return sb.toString(); | ||
return "BundleUsage{" | ||
+ "name='" | ||
+ name | ||
+ '\'' | ||
+ ", classNames=" | ||
+ classNames | ||
+ ", locales=" | ||
+ locales | ||
+ '}'; | ||
} | ||
|
||
@Override | ||
public int compareTo(@NotNull BundleUsage o) { | ||
return this.name.compareTo(o.name); | ||
int nameResult = name.compareTo(o.name); | ||
if (nameResult != 0) { | ||
return nameResult; | ||
} | ||
if (o.classNames == null && classNames != null) { | ||
return 1; | ||
} else if (classNames == null && o.classNames != null) { | ||
return -1; | ||
} else if (classNames != null && o.classNames != null) { | ||
Iterator<String> iterator = o.classNames.iterator(); | ||
for (String className : classNames) { | ||
if (!iterator.hasNext()) { | ||
return 1; | ||
} | ||
String other = iterator.next(); | ||
int current = className.compareTo(other); | ||
if (current != 0) { | ||
return current; | ||
} | ||
} | ||
if (iterator.hasNext()) { | ||
return -1; | ||
} | ||
} | ||
if (o.locales == null && locales != null) { | ||
return 1; | ||
} else if (locales == null && o.locales != null) { | ||
return -1; | ||
} else if (o.locales != null && locales != null) { | ||
Iterator<String> iterator = o.locales.iterator(); | ||
for (String locale : locales) { | ||
if (!iterator.hasNext()) { | ||
return 1; | ||
} | ||
String other = iterator.next(); | ||
int current = locale.compareTo(other); | ||
if (current != 0) { | ||
return current; | ||
} | ||
} | ||
if (iterator.hasNext()) { | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
} |