Skip to content

Commit

Permalink
java.lang.NoSuchMethodError: 'arb.Real arb.Real.j(int, arb.Real)'
Browse files Browse the repository at this point in the history
	at k-2*j(k,x)func.evaluate(Unknown Source)
	at arb4j/arb.functions.real.RealFunction.eval(RealFunction.java:222)
	at arb4j/arb.expressions.nodes.unary.SphericalBesselFunctionNodeOfTheFirstKindTest.testj0ViaRealFunctionalExpression(SphericalBesselFunctionNodeOfTheFirstKindTest.java:25)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at [email protected]/junit.framework.TestCase.runTest(TestCase.java:177)
	at [email protected]/junit.framework.TestCase.runBare(TestCase.java:142)
	at [email protected]/junit.framework.TestResult$1.protect(TestResult.java:122)
	at [email protected]/junit.framework.TestResult.runProtected(TestResult.java:142)
	at [email protected]/junit.framework.TestResult.run(TestResult.java:125)
	at [email protected]/junit.framework.TestCase.run(TestCase.java:130)
	at [email protected]/junit.framework.TestSuite.runTest(TestSuite.java:241)
	at [email protected]/junit.framework.TestSuite.run(TestSuite.java:236)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:530)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:758)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:453)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:211)

#253

gr8
  • Loading branch information
crowlogic committed Nov 30, 2024
1 parent ee207f5 commit 921a7f5
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/main/java/arb/expressions/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ public static MethodVisitor loadBitsParameterOntoStack(MethodVisitor methodVisit
{
CompiledExpressionClassLoader loader =
context != null ? context.classLoader : new CompiledExpressionClassLoader();
if ( context != null && context.classLoader == null )
{
context.classLoader = loader;
}
return (Class<F>) loader.defineClass(className, bytecodes);
// return (Class<F>) loader.findClass(className);
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/arb/expressions/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ public static ClassVisitor constructClassVisitor()

public Node<D, C, F> rootNode;


public boolean variablesDeclared = false;

boolean verboseTrace = false;
Expand Down Expand Up @@ -992,10 +991,10 @@ protected ClassVisitor generateEvaluationMethod(ClassVisitor classVisitor) throw
{
assert false : "gone surfing";
}
function.rootNode = (Node) rootNode.spliceInto(function);
function.className = className + "func";
function.rootNode = (Node) rootNode.spliceInto(function);
function.className = className + "func";
function.rootNode.isResult = true;

// Generate the implementation
function.generate();

Expand All @@ -1011,9 +1010,8 @@ protected ClassVisitor generateEvaluationMethod(ClassVisitor classVisitor) throw
{
String fieldName = entry.getKey();
Class<?> fieldType = entry.getValue().getClass();
mv.visitInsn(DUP);
loadThisOntoStack(mv);
loadFieldOntoStack(mv, fieldName, fieldType);
Compiler.duplicateTopOfTheStack(mv);
loadThisFieldOntoStack(mv, fieldName, fieldType);
Compiler.putField(mv, function.className, fieldName, fieldType);
}
}
Expand All @@ -1026,6 +1024,8 @@ protected ClassVisitor generateEvaluationMethod(ClassVisitor classVisitor) throw

// Return the new function instance
mv.visitInsn(ARETURN);

function.defineClass();
}
else
{
Expand Down Expand Up @@ -2025,7 +2025,7 @@ protected Expression<D, C, F> storeInstructions(ClassVisitor classVisitor)

if (context == null)
{
context = new Context();
context = new Context();
}

if (Expression.trace)
Expand Down Expand Up @@ -2061,7 +2061,7 @@ protected Expression<D, C, F> storeInstructions(ClassVisitor classVisitor)

if (context == null)
{
context = new Context();
context = new Context();
}

if (Expression.trace)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/arb/expressions/nodes/VariableNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ else if (ascendentInput)
{
returnType = reference.type();
}
assert !returnType.isInterface() : "returnType is " + returnType + " and therefore cannot be instantiated";
//assert !returnType.isInterface() : "returnType is " + returnType + " and therefore cannot be instantiated";
assert returnType != null : "returnType is null for " + this;
assert returnType != Object.class : "TODO: tried to return "
+ returnType
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/arb/functions/real/RealFunctional.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ public static <K> RealFunctional<K> express(String name, String expression, Cont
return Function.express(Object.class, RealFunction.class, RealFunctional.class, name, expression, context);
}

public default RealFunction evaluate()
{
return evaluate(null, 0);
}

public default RealFunction evaluate(int bits)
{
return evaluate(null, bits);
}

}
45 changes: 45 additions & 0 deletions src/main/java/arb/functions/real/RealNullaryFunctional.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package arb.functions.real;

import arb.documentation.BusinessSourceLicenseVersionOnePointOne;
import arb.documentation.TheArb4jLibrary;
import arb.expressions.Context;
import arb.functions.Function;
import arb.functions.NullaryFunction;

/**
*
* @see BusinessSourceLicenseVersionOnePointOne © terms of the
* {@link TheArb4jLibrary}
*/
public interface RealNullaryFunctional extends
RealFunctional<Object>,
NullaryFunction<RealFunction>
{

@Override
default RealFunction evaluate(int bits)
{
return evaluate(null, 0, bits, null);
}

public default RealFunction evaluate()
{
return evaluate(null, 0);
}

public static RealNullaryFunctional express(String expression, Context context)
{
return express(null, expression, context);
}

public static RealNullaryFunctional express(String expression)
{
return express(null, expression, null);
}

public static RealNullaryFunctional express(String name, String expression, Context context)
{
return Function.express(Object.class, RealFunction.class, RealNullaryFunctional.class, name, expression, context);
}

}
24 changes: 16 additions & 8 deletions src/test/java/arb/expressions/ExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import arb.functions.real.RealFunction;
import arb.functions.real.RealFunctional;
import arb.functions.real.RealNullaryFunction;
import arb.functions.real.RealNullaryFunctional;
import arb.functions.real.TestCompiledDerivative;
import junit.framework.TestCase;

Expand All @@ -37,8 +38,8 @@ public static void testAFractionConstantTimesAFractionConstant()
f.simplify();
assertEquals("3/4", f.toString());
RationalNullaryFunction instance = f.instantiate();
RationalFunction val = instance.evaluate();
Fraction hmm = val.evaluate(new Fraction());
RationalFunction val = instance.evaluate();
Fraction hmm = val.evaluate(new Fraction());
assertEquals(0.75, hmm.doubleValue());
}

Expand Down Expand Up @@ -165,12 +166,19 @@ public void testRealPolynomialDerivative()
*/
public void testRealFunctionDerivative()
{
var context = new Context(Real.named("a"),
Real.named("b"),
Real.named("c"));
var x = RealFunctional.express("x->∂a*x+b*x²+c*x³/∂x", context);
var y = x.evaluate(null, 128);
assertEquals("2*a*x+b", y.toString());
var context = new Context(Real.named("a").set(2),
Real.named("b").set(4),
Real.named("c").set(6));
RealNullaryFunctional x = RealNullaryFunctional.express("x->∂a*x+b*x²+c*x³/∂x", context);
var poly = x.evaluate();

var y = poly.evaluate(new Real("2.3",
128),
1,
128,
new Real());
y.printPrecision = false;
assertEquals("115.62", y.toString());
}

public void testRationalFunctionDerivative()
Expand Down
3 changes: 1 addition & 2 deletions todoList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ TODO: builtin sykbols for the classical orthogonal polynomials
"limit" is null at arb4j/arb.expressions.nodes.IntegralNode.evaluateIndefiniteIntegralAt(IntegralNode.java:217)
todo: mouse wheel zooms control or whole scene
expr compiler: fractional derivatices
java.lang.NoClassDefFoundError: k-2*j(k,x)funcat k-2*j(k,x).evaluate(Unknown Source)at arb4j/arb.functions.Function.evaluate(Function.java:240)at arb4j/arb.functions.Function.evaluate(Function.java:220)at arb4j/arb.functions.integer.Sequence.evaluate(Sequence.java:47)at arb4j/arb.expressions.nodes.unary.SphericalBesselFunctionNodeOfTheFirstKindTest.testj0ViaRealFunctionalExpression(SphericalBesselFunctionNodeOfTheFirstKindTest.java:24)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at [email protected]/junit.framework.TestCase.runTest(TestCase.java:177)at [email protected]/junit.framework.TestCase.runBare(TestCase.java:142)at [email protected]/junit.framework.TestResult$1.protect(TestResult.java:122)at [email protected]/junit.framework.TestResult.runProtected(TestResult.java:142)at [email protected]/junit.framework.TestResult.run(TestResult.java:125)at [email protected]/junit.framework.TestCase.run(TestCase.java:130)at [email protected]/junit.framework.TestSuite.runTest(TestSuite.java:241)at [email protected]/junit.framework.TestSuite.run(TestSuite.java:236)at [email protected]/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:530)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:758)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:453)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:211)Caused by: java.lang.ClassNotFoundException: k-2*j(k,x)funcat java.base/java.lang.ClassLoader.findClass(ClassLoader.java:735)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:595)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)... 22 more
arb.exceptions.UndefinedReferenceException: Undefined reference to variable 'a' at position=-1 in expression=null, independent variable is x and ascendentExpression is null, remaining='null'at arb4j/arb.expressions.nodes.VariableNode.resolveInheritedVariableReference(VariableNode.java:468)at arb4j/arb.expressions.nodes.VariableNode.resolveReference(VariableNode.java:539)at arb4j/arb.expressions.nodes.VariableNode.<init>(VariableNode.java:115)at arb4j/arb.expressions.nodes.VariableNode.spliceInto(VariableNode.java:560)at arb4j/arb.expressions.nodes.binary.AdditionNode.spliceInto(AdditionNode.java:49)at arb4j/arb.expressions.nodes.binary.AdditionNode.spliceInto(AdditionNode.java:49)at arb4j/arb.expressions.nodes.DerivativeNode.spliceInto(DerivativeNode.java:168)at arb4j/arb.expressions.Expression.generateEvaluationMethod(Expression.java:998)at arb4j/arb.expressions.Expression.generate(Expression.java:812)at arb4j/arb.expressions.Expression.defineClass(Expression.java:595)at arb4j/arb.expressions.Expression.getInstance(Expression.java:1319)at arb4j/arb.expressions.Expression.instantiate(Expression.java:1468)at arb4j/arb.functions.Function.instantiate(Function.java:126)at arb4j/arb.functions.Function.express(Function.java:89)at arb4j/arb.functions.real.RealFunctional.express(RealFunctional.java:29)at arb4j/arb.functions.real.RealFunctional.express(RealFunctional.java:18)at arb4j/arb.expressions.ExpressionTest.testRealFunctionDerivative(ExpressionTest.java:171)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at [email protected]/junit.framework.TestCase.runTest(TestCase.java:177)at [email protected]/junit.framework.TestCase.runBare(TestCase.java:142)at [email protected]/junit.framework.TestResult$1.protect(TestResult.java:122)at [email protected]/junit.framework.TestResult.runProtected(TestResult.java:142)at [email protected]/junit.framework.TestResult.run(TestResult.java:125)at [email protected]/junit.framework.TestCase.run(TestCase.java:130)at [email protected]/junit.framework.TestSuite.runTest(TestSuite.java:241)at [email protected]/junit.framework.TestSuite.run(TestSuite.java:236)at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:530)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:758)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:453)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:211)
java.lang.NoSuchMethodError: 'arb.Real arb.Real.j(int, arb.Real)'at k-2*j(k,x)func.evaluate(Unknown Source)at arb4j/arb.functions.real.RealFunction.eval(RealFunction.java:222)at arb4j/arb.expressions.nodes.unary.SphericalBesselFunctionNodeOfTheFirstKindTest.testj0ViaRealFunctionalExpression(SphericalBesselFunctionNodeOfTheFirstKindTest.java:25)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at [email protected]/junit.framework.TestCase.runTest(TestCase.java:177)at [email protected]/junit.framework.TestCase.runBare(TestCase.java:142)at [email protected]/junit.framework.TestResult$1.protect(TestResult.java:122)at [email protected]/junit.framework.TestResult.runProtected(TestResult.java:142)at [email protected]/junit.framework.TestResult.run(TestResult.java:125)at [email protected]/junit.framework.TestCase.run(TestCase.java:130)at [email protected]/junit.framework.TestSuite.runTest(TestSuite.java:241)at [email protected]/junit.framework.TestSuite.run(TestSuite.java:236)at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:530)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:758)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:453)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:211)

0 comments on commit 921a7f5

Please sign in to comment.