FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   java.lang.VerifyError
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: java.lang.VerifyError  (Read 279 times)
mr.prufrock

WWW Email
java.lang.VerifyError
« on: Jul 11th, 2003, 2:15am »

I got a "java.lang.VerifyError", when I try to access a String array inside the constructor of a class...  
 
I find that if I remove all the parameters in the constructor, then it will work fine... and if I put the offending code in another init() method, it will also work fine.
 
 
- - - - - - - - - - - - - - - -  
 
Strip strip;  
 
String[] poem = new String[2];  
 
void setup() {  
 
  poem[0] = "The detail of the pattern is movement";  
  poem[1] = "As in the figure of the ten stairs";  
 
  strip = new Strip( 0, 0, 0, 150, 150, 20 );  
   
  /* println( poem.length ); // this works fine though */  
}  
 
void loop() {  
 
}  
 
class Strip {  
 
  float tx, ty, tz, w, h;  
 
  Strip ( float x, float y, float z, float w, float h, int num ) {  
 
    tx = x;  
    ty = y;  
    tz = z;  
    this.w = w;  
    this.h = h;  
 
    // *** this causes the problem *** //  
    println( poem.length );  
 
  }  
 
}  
 

I grow old...I grow old
I shall wear the bottoms of my trousers rolled.
benelek

35160983516098 WWW Email
Re: java.lang.VerifyError
« Reply #1 on: Jul 11th, 2003, 3:23am »

this is one of the oldest unfixed bugs in Processing: you can't use P5-specific / p5-tailored functions within the constructor of a class. you should also notice that things like random() and max() won't work within the constructor.
 
mr.prufrock

WWW Email
Re: java.lang.VerifyError
« Reply #2 on: Jul 11th, 2003, 6:45pm »

I see. Thanks benelek.
 

I grow old...I grow old
I shall wear the bottoms of my trousers rolled.
benelek

35160983516098 WWW Email
Re: java.lang.VerifyError
« Reply #3 on: Jul 12th, 2003, 5:32am »

i'm not sure if this issue's going to be fixed any time soon (we'll have to ask the dev deam), but you can usually get around it by doing all the processing stuff before using the constructor, and then feed it into the object using the constructor. for example:
 
Code:

someObject theObject;
void setup() {
  float randomWhatever = random(a,b);
  theObject = new someObject(randomWhatever);
}
 
class someObject {
  float myRandomNum;
  someObject(float rn) {
    myRandomNum=rn;
  }
}
 
void loop() {
}

 
instead of...
 
Code:

someObject theObject;
void setup() {
  theObject = new someObject();
}
 
class someObject {
  float myRandomNum;
  someObject() {
    myRandomNum=random(a,b);
  }
}
 
void loop() {
}
 
fry


WWW
Re: java.lang.VerifyError
« Reply #4 on: Jul 14th, 2003, 3:52pm »

yup, it'll be fixed soon. maybe even for 57. the problem is the kjc compiler, at least the version that we're using. we've got dan mosedale on the case, and he's working to swap it out for jikes. the switch is in super early testing now.
 
benelek

35160983516098 WWW Email
Re: java.lang.VerifyError
« Reply #5 on: Jul 14th, 2003, 4:11pm »

yay! now i can go make all my old sketches *better*!
 
toxi

WWW
Re: java.lang.VerifyError
« Reply #6 on: Jul 14th, 2003, 7:53pm »

another solution is to call an init method from the constructor of your class. in general this is not a bad coding practice either:
 
Code:

class Test {
  float x;
  Test(float arg) {
    init(arg);
  }
  void init(float limit) {
    x=random(limit);
  }
}

 

http://toxi.co.uk/
fry


WWW
Re: java.lang.VerifyError
« Reply #7 on: Jul 27th, 2003, 7:41pm »

ivrea sponsored hacker dan mosedale has repaired this by plugging in support for a better compiler (namely, jikes) which is faster and better than the previous compiler.
 
the results will be available in 57.
 
Pages: 1 

« Previous topic | Next topic »