crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

n➔(λ*2.0)₍ₙ₎/(λ+½)₍ₙ₎: Type 'arb/Integer' (current frame, stack[2]) is not assignable to 'arb/Real' #343

Closed crowlogic closed 8 months ago

crowlogic commented 8 months ago
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    nλTimes2•0₍ₙ₎DividedByλPlushalf₍ₙ₎.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object; @51: invokevirtual
  Reason:
    Type 'arb/Integer' (current frame, stack[2]) is not assignable to 'arb/Real'
  Current Frame:
    bci: @51
    flags: { }
    locals: { 'nλTimes2•0₍ₙ₎DividedByλPlushalf₍ₙ₎', 'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real', 'arb/Real', 'arb/Integer', integer, 'arb/Real' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162a
    0000010: b400 191d 2ab4 001c b600 222b c000 241d
    0000020: 2ab4 0027 b600 2b2a b400 16b2 0031 1d2a
    0000030: b400 34b6 0037 2bc0 0024 1d2a b400 3ab6
    0000040: 002b 1d19 04c0 0024 b600 3eb0          
  Stackmap Table:
    same_frame(@11)

    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
    at java.base/java.lang.Class.getConstructor0(Class.java:3754)
    at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
    at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1163)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:1151)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:126)
    at arb4j/arb.functions.Function.express(Function.java:161)
    at arb4j/arb.expressions.ExpressionTest.testRatioOfRisingFactorials(ExpressionTest.java:29)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at junit@4.13.2/junit.framework.TestCase.runTest(TestCase.java:177)
    at junit@4.13.2/junit.framework.TestCase.runBare(TestCase.java:142)
    at junit@4.13.2/junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit@4.13.2/junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit@4.13.2/junit.framework.TestResult.run(TestResult.java:125)
    at junit@4.13.2/junit.framework.TestCase.run(TestCase.java:130)
    at junit@4.13.2/junit.framework.TestSuite.runTest(TestSuite.java:241)
    at junit@4.13.2/junit.framework.TestSuite.run(TestSuite.java:236)
    at junit@4.13.2/org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
crowlogic commented 8 months ago

the problem is that the LiteralConstant is not casting to the resultType passed in to its generate method

  @Override
  public MethodVisitor generate(MethodVisitor mv, Class<?> resultType)
  {
    if (π.equals(fieldName))
    {
      getStaticField(mv, π);
    }
    else if (half.equals(fieldName))
    {
      getStaticField(mv, "half");
    }
    else
    {
      // todo: https://github.com/crowlogic/arb4j/issues/222: use the primitive int ,
      // the signature of the method being invoked will also have to know this has
      // been done and change correspondingly
      expression.loadFieldOntoStack(loadThisOntoStack(mv), fieldName, type().descriptorString());
    }

    if (isResult)
    {
      expression.setResult(mv, type());
    }

    return mv;
  }