【问题标题】:Compile Error: JSR/RET are not supported with computeFrames option编译错误:computeFrames 选项不支持 JSR/RET
【发布时间】:2013-10-15 12:36:54
【问题描述】:

编译 java 文件时在 IntelliJ 项目中出现此错误。没有列出特定的源文件,但失败并出现此错误。

删除以下编译器标志可修复错误:

-source 1.5 -target 1.5

但是,由于我们的目标是 Java 5,因此这些代码必须包含在内。是否有某些特定代码(可能是 try/catch 块)导致了此错误?

2013-10-15 16:21:50,556 [26947209]   INFO - ompiler.BackendCompilerWrapper - JSR/RET are not supported with computeFrames option 
java.lang.RuntimeException: JSR/RET are not supported with computeFrames option
    at org.objectweb.asm.Frame.a(Unknown Source)
    at org.objectweb.asm.MethodWriter.visitJumpInsn(Unknown Source)
    at org.objectweb.asm.MethodAdapter.visitJumpInsn(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.intellij.compiler.impl.javaCompiler.BackendCompilerWrapper$ClassParsingThread.a(BackendCompilerWrapper.java:893)
    at com.intellij.compiler.impl.javaCompiler.BackendCompilerWrapper$ClassParsingThread.run(BackendCompilerWrapper.java:846)
    at com.intellij.openapi.application.impl.ApplicationImpl$7.run(ApplicationImpl.java:386)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:130)

【问题讨论】:

标签: java intellij-idea compiler-errors java-bytecode-asm jsr


【解决方案1】:

当 try/finally 块出现在源代码中时,JSR/RET 指令出现在字节码中。即使使用 -target 1.5,Javac 1.6+ 似乎也不会发出它们,但 Eclipse java 编译器会。

例子

public class JSRDemo {
    public static void main(String[] args) {
        try {
            bodyOfTry();
        }
        finally {
            bodyOfFinally();
        }
    }

...

字节码

  // access flags 0x9
  public static main([Ljava/lang/String;)V
    TRYCATCHBLOCK L0 L1 L1 null
    TRYCATCHBLOCK L2 L3 L1 null
   L0
    LINENUMBER 4 L0
    INVOKESTATIC JSRDemo.bodyOfTry ()V
   L4
    LINENUMBER 5 L4
    GOTO L2
   L1
    LINENUMBER 6 L1
    ASTORE 2
    JSR L5               // JSR jumps to the finally block
   L6
    LINENUMBER 8 L6
    ALOAD 2
    ATHROW
   L5
    LINENUMBER 6 L5
    ASTORE 1
   L7
    LINENUMBER 7 L7
    INVOKESTATIC JSRDemo.bodyOfFinally ()V
   L8
    LINENUMBER 8 L8
    RET 1                 // RET returns from the finally block
   L2
    JSR L5                // Jump to the same finally block from another execution path
   L3
    LINENUMBER 9 L3
    RETURN
   L9
    LOCALVARIABLE args [Ljava/lang/String; L0 L9 0
    MAXSTACK = 1
    MAXLOCALS = 3

【讨论】:

  • @stealthjong 我猜,切换到javac 可能会有所帮助
【解决方案2】:

我今天收到了同样的错误:JSR/RET are not supported with computeFrames option

我发现,我在我的项目中使用了commons-io 依赖项。

implementation 'commons-io:commons-io:2.11.0'

并且我根据 Gradle Suggestion 将此依赖项更新为最新版本。

implementation 'commons-io:commons-io:20030203.000550'

此更新版本导致错误!

我放回之前的版本,错误消失了,构建成功了!

【讨论】:

    猜你喜欢
    • 2021-12-21
    • 1970-01-01
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多