Skip to content

Commit

Permalink
fix querying max while building providers
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Sep 23, 2024
1 parent b0763d2 commit a0f585e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/main/java/xyz/wagyourtail/jvmdg/ClassDowngrader.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ protected ClassDowngrader(@NotNull Flags flags) {
}

public int maxVersion() {
if (downgraders == null) {
return -1;
}
if (maxVersion == -1) {
synchronized (this) {
if (maxVersion == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ public byte[] apply(String s) {

@Override
protected Enumeration<URL> findResources(final String name) {
if (name.equals("META-INF/services/" + VersionProvider.class.getName())) {
return super.findResources(name);
}
if (multiVersionList.isEmpty()) {
synchronized (this) {
if (multiVersionList.isEmpty()) {
for (int i = holder.maxVersion(); i >= 52; i--) {

int max = holder.maxVersion();
// still initializing?
if (max == -1) {
return super.findResources(name);
}

for (int i = max; i >= 52; i--) {
multiVersionList.add(i);
}
multiVersionList.add(-1);
Expand Down

0 comments on commit a0f585e

Please sign in to comment.