-
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.
feat: improve API ergonomics, arbitrary class file sources
- Loading branch information
Showing
8 changed files
with
3,824 additions
and
3,780 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
Large diffs are not rendered by default.
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
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
2 changes: 1 addition & 1 deletion
2
...phx/cfr/source/OutputSinkFactoryImpl.java → ...cephx/cfr/sink/OutputSinkFactoryImpl.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,4 +1,4 @@ | ||
package dev.cephx.cfr.source; | ||
package dev.cephx.cfr.sink; | ||
|
||
import org.benf.cfr.reader.api.OutputSinkFactory; | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dev.cephx.cfr.source; | ||
|
||
import org.benf.cfr.reader.api.ClassFileSource; | ||
import org.benf.cfr.reader.bytecode.analysis.parse.utils.Pair; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
public record SimpleClassSource(Function<String, byte[]> source) implements ClassFileSource { | ||
@Override | ||
public void informAnalysisRelativePathDetail(String usePath, String classFilePath) { | ||
} | ||
|
||
@Override | ||
public Collection<String> addJar(String jarPath) { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public String getPossiblyRenamedPath(String path) { | ||
return path; | ||
} | ||
|
||
@Override | ||
public Pair<byte[], String> getClassFileContent(String path) { | ||
String name = path; | ||
|
||
final int extIndex = path.indexOf(".class"); | ||
if (extIndex != -1) { | ||
name = path.substring(0, extIndex); | ||
} | ||
|
||
final byte[] b = this.source.apply(name); | ||
return b != null ? new Pair<>(b, path) : null; | ||
} | ||
} |