Uploaded image for project: 'Commons Sandbox'
  1. Commons Sandbox
  2. SANDBOX-319

Cannot pop operand off an empty stack

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • None
    • Javaflow
    • None

    Description

      Steps to reproduce:

      Create the file Example.java:

      --------------
      import java.util.concurrent.*;

      public class Example {
      private Executor executor = Executors.newFixedThreadPool(8);
      private ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
      public ScheduledFuture<?> schedule(final Runnable command, long delay, TimeUnit unit) {
      return stpe.schedule(new Runnable() {
      public void run()

      { executor.execute(command); }

      }, delay, unit);
      }
      }
      --------------

      and the file Rewriter.java:

      ---------------
      import org.apache.commons.javaflow.utils.RewritingUtils;
      import org.apache.commons.javaflow.bytecode.transformation.ResourceTransformer;
      import org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer;

      import java.io.File;

      public class Rewriter {
      public static void main(String[] args) throws Exception

      { ResourceTransformer transformer = new AsmClassTransformer(); RewritingUtils.rewriteClassFile(new File("Example.class"), transformer, new File("ExampleRewritten.class")); }

      }
      ----------------

      Compile:

      javac -cp $JAVAFLOW *.java

      Run:

      java -cp $JAVAFLOW Rewriter

      It produces the following error:

      org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 6: Method owner: expected LExample$1;, but found Ljava/util/concurrent/ScheduledThreadPoolExecutor;
      at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer$2.analyze(ContinuationMethodAnalyzer.java:124)
      at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer.visitEnd(ContinuationMethodAnalyzer.java:135)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:53)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:40)
      at org.apache.commons.javaflow.utils.RewritingUtils.rewriteClassFile(RewritingUtils.java:60)
      at Rewriter.main(Rewriter.java:10)
      Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Method owner: expected LExample$1;, but found Ljava/util/concurrent/ScheduledThreadPoolExecutor;
      at org.objectweb.asm.tree.analysis.BasicVerifier.naryOperation(Unknown Source)
      at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.MonitoringFrame.execute(MonitoringFrame.java:70)
      ... 9 more
      org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 9: Cannot pop operand off an empty stack.
      at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
      at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
      at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
      at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer.visitEnd(ContinuationMethodAnalyzer.java:141)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:53)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:40)
      at org.apache.commons.javaflow.utils.RewritingUtils.rewriteClassFile(RewritingUtils.java:60)
      at Rewriter.main(Rewriter.java:10)
      Caused by: java.lang.IndexOutOfBoundsException: Cannot pop operand off an empty stack.
      at org.objectweb.asm.tree.analysis.Frame.pop(Unknown Source)
      at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
      ... 11 more
      Exception in thread "main" java.lang.RuntimeException: Error at instruction 9: Cannot pop operand off an empty stack. schedule(Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
      00000 R R J . R : : L0
      00001 R R J . R : : LINENUMBER 7 L0
      00002 R R J . R : : ALOAD 0
      00003 R R J . R : R : GETFIELD Example.stpe : Ljava/util/concurrent/ScheduledThreadPoolExecutor;
      00004 R R J . R : R : ALOAD 0
      00005 R R J . R : R R : ALOAD 1
      00006 R R J . R : R R R : INVOKESPECIAL Example$1.<init> (LExample;Ljava/lang/Runnable;)V
      00007 R R J . R : : NEW Example$1
      00008 R R J . R : R : DUP
      00009 R R J . R : R R : DUP2_X2
      00010 ? : POP2
      00011 ? : LLOAD 2
      00012 ? : ALOAD 4
      00013 ? : L1
      00014 ? : INVOKEVIRTUAL java/util/concurrent/ScheduledThreadPoolExecutor.schedule (Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
      00015 ? : ARETURN

      at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
      at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
      at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.ContinuationMethodAnalyzer.visitEnd(ContinuationMethodAnalyzer.java:141)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:53)
      at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:40)
      at org.apache.commons.javaflow.utils.RewritingUtils.rewriteClassFile(RewritingUtils.java:60)
      at Rewriter.main(Rewriter.java:10)

      Attachments

        Activity

          People

            Unassigned Unassigned
            joshua.ball Joshua Ball
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: