Skip to content

Commit

Permalink
Update jasm to handle bad kotlin variable ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jan 10, 2025
1 parent b52c58d commit 23b29c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ image-io-ext-ico = "3.0.2"
instrument-server = "1.4.2"
jackson = "2.17.1"
jakarta-annotation = "3.0.0"
jasm = "9a413ea936"
jasm = "552630c411"
jlinker = "1.0.7"
jphantom = "1.4.4"
junit = "5.11.0"
Expand All @@ -39,7 +39,7 @@ richtextfx = "0.11.3"
treemapfx = "1.1.0"
vineflower = "1.10.1"
wordwrap = "0.1.12"
sourcesolver = "1.0.1"
sourcesolver = "1.0.2"
# Plugins
benmanes-versions = "0.42.0"
gradle-coverage-report-aggregator = "1.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public AbstractAssemblerPipeline(@Nonnull AssemblerPipelineGeneralConfig general
private void refreshContext() {
context = new PrintContext<>(generalConfig.getDisassemblyIndent().getValue());

// Enable aggressive variable name dropping to prevent use of bogus kotlin variable ranges.
context.setAggressivelyDropVars(true);

// Enable comments that outline where try-catch ranges begin/end.
if (pipelineConfig instanceof JvmAssemblerPipelineConfig jvmConfig && jvmConfig.emitTryRangeComments())
context.setDebugTryCatchRanges(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import jakarta.enterprise.context.Dependent;
import jakarta.inject.Inject;
import me.darknet.assembler.printer.JvmClassPrinter;
import me.darknet.assembler.printer.JvmMethodPrinter;
import me.darknet.assembler.printer.MethodPrinter;
import me.darknet.assembler.printer.PrintContext;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
Expand Down Expand Up @@ -186,11 +186,11 @@ public ExpressionResult compile(@Nonnull String expression) {
// Convert the compiled class to JASM
try {
PrintContext<?> context = new PrintContext<>(assemblerConfig.getDisassemblyIndent().getValue());
context.setLabelPrefix("g");
JvmClassPrinter printer = new JvmClassPrinter(new ByteArrayInputStream(klass));
JvmMethodPrinter method = (JvmMethodPrinter) printer.method(stubber.getAdaptedMethodName(), stubber.methodDescriptorWithVariables());
MethodPrinter method = printer.method(stubber.getAdaptedMethodName(), stubber.methodDescriptorWithVariables());
if (method == null)
return new ExpressionResult(new ExpressionCompileException("Target method was not in generated class"));
method.setLabelPrefix("g");
method.print(context);
return new ExpressionResult(context.toString());
} catch (IOException ex) {
Expand Down

0 comments on commit 23b29c4

Please sign in to comment.