Skip to content

Commit

Permalink
Respect class file version also in Android plugins when resolving cla…
Browse files Browse the repository at this point in the history
…ss files.
  • Loading branch information
raphw committed Sep 25, 2024
1 parent 63c72ec commit 5cc5c73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ public void initialize(ByteBuddyInstrumentationParameters parameters) {
return;
}
try {
ClassFileVersion classFileVersion = ClassFileVersion.ofJavaVersionString(getParameters()
.getJavaTargetCompatibilityVersion()
.get()
.toString());
List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>();
classFileLocators.add(ClassFileLocator.ForClassLoader.of(ByteBuddy.class.getClassLoader()));
for (File artifact : parameters.getRuntimeClasspath()
.plus(parameters.getAndroidBootClasspath())
.plus(parameters.getByteBuddyClasspath())
.getFiles()) {
classFileLocators.add(artifact.isFile()
? ClassFileLocator.ForJarFile.of(artifact)
: new ClassFileLocator.ForFolder(artifact));
? ClassFileLocator.ForJarFile.of(artifact, classFileVersion)
: ClassFileLocator.ForFolder.of(artifact, classFileVersion));
}
ClassFileVersion classFileVersion = ClassFileVersion.ofJavaVersionString(getParameters()
.getJavaTargetCompatibilityVersion()
.get()
.toString());
ClassFileLocator classFileLocator = new ClassFileLocator.Compound(classFileLocators);
TypePool typePool = Plugin.Engine.PoolStrategy.Default.FAST.typePool(classFileLocator);
ClassLoader classLoader = new URLClassLoader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public void execute() {
List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>();
for (File file : getRuntimeClasspath().plus(getAndroidBootClasspath()).plus(getByteBuddyClasspath()).getFiles()) {
classFileLocators.add(file.isFile()
? ClassFileLocator.ForJarFile.of(file)
: new ClassFileLocator.ForFolder(file));
? ClassFileLocator.ForJarFile.of(file, classFileVersion)
: ClassFileLocator.ForFolder.of(file, classFileVersion));
}
classFileLocators.add(ClassFileLocator.ForClassLoader.of(ByteBuddy.class.getClassLoader()));
ClassFileLocator classFileLocator = new ClassFileLocator.Compound(classFileLocators);
Expand Down Expand Up @@ -173,6 +173,7 @@ public void execute() {
classFileVersion,
MethodNameTransformer.Suffixing.withRandomSuffix())
.with(classFileLocator)
.with(classFileVersion)
.apply(new Plugin.Engine.Source.Compound(sources), new Plugin.Engine.Target.ForFolder(getOutputDir().get().getAsFile()), factories);
if (!summary.getFailed().isEmpty()) {
throw new IllegalStateException(summary.getFailed() + " local type transformations have failed");
Expand Down

0 comments on commit 5cc5c73

Please sign in to comment.