-
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.
- Loading branch information
Showing
5 changed files
with
47 additions
and
43 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
45 changes: 45 additions & 0 deletions
45
src/main/java/github/api/nat/test/aot/GitHubRuntimeHints.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package github.api.nat.test.aot; | ||
|
||
import org.springframework.aot.hint.MemberCategory; | ||
import org.springframework.aot.hint.RuntimeHints; | ||
import org.springframework.aot.hint.RuntimeHintsRegistrar; | ||
import org.springframework.aot.hint.TypeReference; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.jar.JarEntry; | ||
import java.util.jar.JarInputStream; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class GitHubRuntimeHints implements RuntimeHintsRegistrar { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(GitHubRuntimeHints.class.getName()); | ||
|
||
@Override | ||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { | ||
Arrays.stream(System.getProperty("java.class.path").split(File.pathSeparator)).forEach(classpathEntry -> { | ||
// If the classpathEntry is no jar skip it | ||
if (!classpathEntry.endsWith(".jar")) { | ||
return; | ||
} | ||
|
||
try (JarInputStream is = new JarInputStream(new FileInputStream(classpathEntry))) { | ||
JarEntry entry; | ||
while ((entry = is.getNextJarEntry()) != null) { | ||
if (entry.getName().endsWith(".class") && entry.getName().startsWith("org/kohsuke/github")) { | ||
String githubApiClassName = entry.getName().replace("/", "."); | ||
String githubApiClassNameWithoutClass = githubApiClassName.substring(0, githubApiClassName.length() - 6); | ||
LOGGER.log(Level.INFO, "Registered class " + githubApiClassNameWithoutClass + " for reflections and serialization."); | ||
hints.reflection().registerType(TypeReference.of(githubApiClassNameWithoutClass), MemberCategory.values()); | ||
hints.serialization().registerType(TypeReference.of(githubApiClassName)); | ||
} | ||
} | ||
} catch (IOException e) { | ||
LOGGER.log(Level.INFO, "Error while reading jars", e); | ||
} | ||
}); | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
...urces/META-INF/native-image/github-api-native-test-custom-definitions/reflect-config.json
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.aot.hint.RuntimeHintsRegistrar=github.api.nat.test.aot.GitHubRuntimeHints |