Closed Duster-Cule closed 2 years ago
The NoSuchMethodError is a runtime error which usually happens when changes are made in source files that don't throw errors at compile time. If you have changed the library version of JMathAnim of any other it may happen. A full clean and rebuild of the project should fix this.
It doesn't work. I even deleted all of my local repository and downloaded again, also made a new maven project, the error still exist. I still dont know what causes this.
It's strange. I just proved in a fresh linux system, the same code, with v0.97-SNAPSHOT and with no errors at all, with openjdk 11.0.13, and in my windows system with java 17.0.1 2021-10-19 LTS
Oh, i got it. I was using java 8u121, which could cause this error. when i updated the jdk of my workspace into java 17.0.1+12, it was fixed.
In 0.9.7-SNAPSHOT, when i run these sample code:
30 Shape[] rects=new Shape[10]; 31 AnimationGroup ag=AnimationGroup.make(); 32 for (int i = 0; i < 10; i++) { 33 //Create 10 rectangles 34 rects[i]=Shape.square().center().fillColor("orange").fillAlpha(.2); 35 //Create an animation for each square scaling it with parameters (.2,.7,1) 36 ag.add(Commands.scale(5, Point.origin(),2, .7, 1,rects[i])); 37 } 38 add(rects); 39 ag.addDelayEffect(.5);//A delay effect of 50% 40 playAnimation(ag); 41 waitSeconds(1);
NoSuchMethodError would exist.
Error log: Exception in thread "main" java.lang.NoSuchMethodError: java.util.ArrayList.toArray(Ljava/util/function/IntFunction;)[Ljava/lang/Object; at com.jmathanim.jmathanim.JMathAnimScene.doDraws(JMathAnimScene.java:391) at com.jmathanim.jmathanim.JMathAnimScene.advanceFrame(JMathAnimScene.java:420) at com.jmathanim.jmathanim.JMathAnimScene.playAnimation(JMathAnimScene.java:546) at com.jmathanim.jmathanim.JMathAnimScene.playAnimation(JMathAnimScene.java:507) at com.my.video.Demo.runSketch(Demo.java:40) at com.jmathanim.jmathanim.JMathAnimScene.execute(JMathAnimScene.java:200) at com.my.video.Demo.main(Demo.java:19)
My maven project only have 2 dependencies, which are JMathAnim 0.9.7-SNAPSHOT and Junit 4.13.2 (I've tried to remove junit and the problem still exist)
But when i use in version 0.9.4, it can successfully complete the animation. whats the problem with it?