You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andrew Madu <an...@gmail.com> on 2006/03/21 10:26:08 UTC

Instruction INVOKEVIRTUAL constraint violated

Hi,
can someone please tell me why defining a class variable in a javaflow class
like so:

public class Login extends AbstractContinuable
{
    static User userGlobal = new User();
    .........


would cause the following error to be generated?:

Instruction INVOKEVIRTUAL constraint violated: Class 'Login' is referenced,
but cannot be loaded and resolved: 'VERIFIED_REJECTED Number of
LocalVariableTable attributes of Code attribute '<CODE>' (method 'static
void <clinit>()') exceeds number of local variable slots '0' ('There may be
no more than one LocalVariableTable attribute per local variable in the Code
attribute.'). '. InstructionHandle: 4: invokevirtual[182](3) 28 Execution
Frame: Local Variables: 0: Login 1: java.lang.String 2: <unknown object> 3:
<unknown object> OperandStack: Slots used: 1 MaxStack: 5. Login (Size: 1)
Execution flow: 0: ldc 24 [InstructionContext] 2: astore_1
[InstructionContext] 3: aload_0 [InstructionContext] 4: invokevirtual 28
[InstructionContext]

org.apache.bcel.verifier.exc.StructuralCodeConstraintException: Instruction
INVOKEVIRTUAL constraint violated: Class 'Login' is referenced, but cannot
be loaded and resolved: 'VERIFIED_REJECTED Number of LocalVariableTable
attributes of Code attribute '<CODE>' (method 'static void <clinit>()')
exceeds number of local variable slots '0' ('There may be no more than one
LocalVariableTable attribute per local variable in the Code attribute.'). '.
InstructionHandle: 4: invokevirtual[182](3) 28 Execution Frame: Local
Variables: 0: Login 1: java.lang.String 2: <unknown object> 3: <unknown
object> OperandStack: Slots used: 1 MaxStack: 5. Login (Size: 1) Execution
flow: 0: ldc 24 [InstructionContext] 2: astore_1 [InstructionContext] 3:
aload_0 [InstructionContext] 4: invokevirtual 28 [InstructionContext]
Are javaflow classes not allowed to have static class variable
definitions?!! How do I resolve this?

Andrew

Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Andrew Madu <an...@gmail.com>.
Hi Torsten,
thanks for your reply. I was just seeing what I could and couldn't do with
java flow classes. I stmbled across this one by accident to be honest. Like
you say, it should work!

Andrew

On 3/21/06, Torsten Curdt <tc...@apache.org> wrote:
>
>
> On 21.03.2006, at 20:26, Andrew Madu wrote:
>
> > Hi,
> > can someone please tell me why defining a class variable in a
> > javaflow class like so:
> >
> > public class Login extends AbstractContinuable
> > {
> >     static User userGlobal = new User();
> >     .........
> >
> >
> > would cause the following error to be generated?:
>
> Andrew, that's the BCEL code verifier that barfs on you.
> Obviously for no good reason. Since I don't think you
> are using trunk upgrading to a newer javaflow version
> is probably no option.
>
> A subtile code change might make a difference. You could
> try a bit ...but rather I would re-think your approach.
> Despite the fact it should work - are you sure that a
> static global user object is the right way to go?
>
> cheers
> --
> Torsten
>
>
>
>
>

Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Simone Gianni <s....@thebug.it>.
Hi Scott,
the javaflow class is loaded by the special classloader, that also loads
other classes if needed, but should not touch them if they don't
implement Continuable; however it analyze the flow class itself, and
during this phase it traverse also the TestMe class. Anyway, this is
really weird.

The special classloader is
src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationClassLoader.java
, you could try to put a few breakpoints in it and see if it's trying to
transform your TestMe class, or if the exception happens when the flow
class is interpreted.

I've just tested adding a static fake variable in a backend class of
mine, and it works correctly. But currently we preload the classes
before flow execution, since we use spring to handle business objects.

You could also try to preload the TestMe class using the load-class
parameter in web.xml, that forces cocoon to preload (via
Class.forName()) a space-separated list of classes before actually
starting it's work. Since this is working for me, maybe it could work
for you as well :)

BTW, which version of cocoon are you using?

Simone



Scott Phillips wrote:

>
> Thank you,
> The example I provided used No inner classes, the TestMe class was
> just a standard object, nothing special and the flow class was as
> simple as I could make it.
>
> My current theory is that it is some load time issue. The TestMe class
> that i gave earlier is only used by the flow script so when the flow
> is loaded it needs to also load the TestMe class. Does JavaFlow use
> the special class loader for all classes loaded or just those that
> implement continuable?
>
> Scott--
>
>
> Simone Gianni wrote:
>
>> Hi Scott,
>> I'm using javaflow which calls backend objects having static variables
>> (for example, enumerations), and didn't incurred in this problem.
>>
>> I can't understand, are you using inner classes? In that case that's the
>> problem. Javaflow is limited in its class handling capacities, inner
>> classes can be a problem, static variables in the javaflow class can be
>> a problem, a flow subclassing another flow can be a problem. But using
>> external classes instead of inner classes should solve it, a KISS
>> approach is higly recommended :)
>>
>> The problem is mainly in BCEL parsing/verifying, that's why in Jakarta
>> commons there is a new implementation of java continuations based on ASM
>> which will be used in cocoon 2.2 instead of BCEL.
>>
>>
>> Hope this helps,
>> Simone
>>
>>
>> Scott Phillips wrote:
>>
>>
>>> I am expeirementing JavaFlow and it seems to me to be so much of a
>>> better fit for our needs than javascript. However in trying to
>>> implement it I hook it into my backend I am recieving errors which are
>>> close to the example provided but I've found that any class which is
>>> used by a javaflow class can not use static variables? This causes
>>> problems because the back-end API that I am calling uses static
>>> variables in large number of cases for it's internal logging.
>>>
>>> my javaflow contains the following lines / class:
>>>
>>> TestMe me = new TestMe();
>>> me.doIt();
>>> sendPage("some/page");
>>>
>>> public class TestMe
>>> {
>>>  // I cause the problem
>>>  private static String staticThing = "I am static";
>>>
>>>  public String doIt() {
>>>    return "I have done it.";
>>>  }
>>> }
>>>
>>>
>>> The flow will fail with:
>>> org.apache.bcel.verifier.exc.StructuralCodeConstraintException:
>>> Instruction NEW constraint violated: Class
>>> 'org.dspace.app.xmlui.eperson.TestMe' is referenced, but cannot be
>>> loaded and resolved: 'VERIFIED_REJECTED
>>> Number of LocalVariableTable attributes of Code attribute '<CODE>'
>>> (method 'public static String doItStatic()') exceeds number of local
>>> variable slots '0' ('There may be no more than one LocalVariableTable
>>> attribute per local variable in the Code attribute.').
>>> '.
>>> InstructionHandle:    0: new[187](3) 25
>>>
>>> Execution Frame:
>>> Local Variables:
>>> 0: org.dspace.app.xmlui.eperson.Flow
>>> 1: <unknown object>
>>> OperandStack:
>>> Slots used: 0 MaxStack: 2.
>>> Execution flow:
>>>   0: new 25    [InstructionContext]
>>>
>>>
>>> If I remove the "staticThing" everything will just work. Any ideas or
>>> do I not understand something and javaflow can not handle static
>>> things? I would realy like to be able to develop the website with
>>> javaflow instead of using javascript now and converting it to javaflow
>>> later.
>>>
>>> Scott--
>>>
>>> Torsten Curdt wrote:
>>>
>>>
>>>> On 21.03.2006, at 20:26, Andrew Madu wrote:
>>>>
>>>>
>>>>> Hi,
>>>>> can someone please tell me why defining a class variable in a
>>>>> javaflow class like so:
>>>>>
>>>>> public class Login extends AbstractContinuable
>>>>> {
>>>>>    static User userGlobal = new User();
>>>>>    .........
>>>>>
>>>>>
>>>>> would cause the following error to be generated?:
>>>>
>>>>
>>>>
>>>>
>>>> Andrew, that's the BCEL code verifier that barfs on you.
>>>> Obviously for no good reason. Since I don't think you
>>>> are using trunk upgrading to a newer javaflow version
>>>> is probably no option.
>>>>
>>>> A subtile code change might make a difference. You could
>>>> try a bit ...but rather I would re-think your approach.
>>>> Despite the fact it should work - are you sure that a
>>>> static global user object is the right way to go?
>>>>
>>>> cheers
>>>> -- 
>>>> Torsten
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Scott Phillips <sc...@gmail.com>.
Thank you,
The example I provided used No inner classes, the TestMe class was just 
a standard object, nothing special and the flow class was as simple as I 
could make it.

My current theory is that it is some load time issue. The TestMe class 
that i gave earlier is only used by the flow script so when the flow is 
loaded it needs to also load the TestMe class. Does JavaFlow use the 
special class loader for all classes loaded or just those that implement 
continuable?

Scott--


Simone Gianni wrote:
> Hi Scott,
> I'm using javaflow which calls backend objects having static variables
> (for example, enumerations), and didn't incurred in this problem.
> 
> I can't understand, are you using inner classes? In that case that's the
> problem. Javaflow is limited in its class handling capacities, inner
> classes can be a problem, static variables in the javaflow class can be
> a problem, a flow subclassing another flow can be a problem. But using
> external classes instead of inner classes should solve it, a KISS
> approach is higly recommended :)
> 
> The problem is mainly in BCEL parsing/verifying, that's why in Jakarta
> commons there is a new implementation of java continuations based on ASM
> which will be used in cocoon 2.2 instead of BCEL.
> 
> 
> Hope this helps,
> Simone
> 
> 
> Scott Phillips wrote:
> 
> 
>>I am expeirementing JavaFlow and it seems to me to be so much of a
>>better fit for our needs than javascript. However in trying to
>>implement it I hook it into my backend I am recieving errors which are
>>close to the example provided but I've found that any class which is
>>used by a javaflow class can not use static variables? This causes
>>problems because the back-end API that I am calling uses static
>>variables in large number of cases for it's internal logging.
>>
>>my javaflow contains the following lines / class:
>>
>>TestMe me = new TestMe();
>>me.doIt();
>>sendPage("some/page");
>>
>>public class TestMe
>>{
>>  // I cause the problem
>>  private static String staticThing = "I am static";
>>
>>  public String doIt() {
>>    return "I have done it.";
>>  }
>>}
>>
>>
>>The flow will fail with:
>>org.apache.bcel.verifier.exc.StructuralCodeConstraintException:
>>Instruction NEW constraint violated: Class
>>'org.dspace.app.xmlui.eperson.TestMe' is referenced, but cannot be
>>loaded and resolved: 'VERIFIED_REJECTED
>>Number of LocalVariableTable attributes of Code attribute '<CODE>'
>>(method 'public static String doItStatic()') exceeds number of local
>>variable slots '0' ('There may be no more than one LocalVariableTable
>>attribute per local variable in the Code attribute.').
>>'.
>>InstructionHandle:    0: new[187](3) 25
>>
>>Execution Frame:
>>Local Variables:
>>0: org.dspace.app.xmlui.eperson.Flow
>>1: <unknown object>
>>OperandStack:
>>Slots used: 0 MaxStack: 2.
>>Execution flow:
>>   0: new 25    [InstructionContext]
>>
>>
>>If I remove the "staticThing" everything will just work. Any ideas or
>>do I not understand something and javaflow can not handle static
>>things? I would realy like to be able to develop the website with
>>javaflow instead of using javascript now and converting it to javaflow
>>later.
>>
>>Scott--
>>
>>Torsten Curdt wrote:
>>
>>
>>>On 21.03.2006, at 20:26, Andrew Madu wrote:
>>>
>>>
>>>>Hi,
>>>>can someone please tell me why defining a class variable in a 
>>>>javaflow class like so:
>>>>
>>>>public class Login extends AbstractContinuable
>>>>{
>>>>    static User userGlobal = new User();
>>>>    .........
>>>>
>>>>
>>>>would cause the following error to be generated?:
>>>
>>>
>>>
>>>Andrew, that's the BCEL code verifier that barfs on you.
>>>Obviously for no good reason. Since I don't think you
>>>are using trunk upgrading to a newer javaflow version
>>>is probably no option.
>>>
>>>A subtile code change might make a difference. You could
>>>try a bit ...but rather I would re-think your approach.
>>>Despite the fact it should work - are you sure that a
>>>static global user object is the right way to go?
>>>
>>>cheers
>>>-- 
>>>Torsten
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Simone Gianni <s....@thebug.it>.
Hi Scott,
I'm using javaflow which calls backend objects having static variables
(for example, enumerations), and didn't incurred in this problem.

I can't understand, are you using inner classes? In that case that's the
problem. Javaflow is limited in its class handling capacities, inner
classes can be a problem, static variables in the javaflow class can be
a problem, a flow subclassing another flow can be a problem. But using
external classes instead of inner classes should solve it, a KISS
approach is higly recommended :)

The problem is mainly in BCEL parsing/verifying, that's why in Jakarta
commons there is a new implementation of java continuations based on ASM
which will be used in cocoon 2.2 instead of BCEL.


Hope this helps,
Simone


Scott Phillips wrote:

> I am expeirementing JavaFlow and it seems to me to be so much of a
> better fit for our needs than javascript. However in trying to
> implement it I hook it into my backend I am recieving errors which are
> close to the example provided but I've found that any class which is
> used by a javaflow class can not use static variables? This causes
> problems because the back-end API that I am calling uses static
> variables in large number of cases for it's internal logging.
>
> my javaflow contains the following lines / class:
>
> TestMe me = new TestMe();
> me.doIt();
> sendPage("some/page");
>
> public class TestMe
> {
>   // I cause the problem
>   private static String staticThing = "I am static";
>
>   public String doIt() {
>     return "I have done it.";
>   }
> }
>
>
> The flow will fail with:
> org.apache.bcel.verifier.exc.StructuralCodeConstraintException:
> Instruction NEW constraint violated: Class
> 'org.dspace.app.xmlui.eperson.TestMe' is referenced, but cannot be
> loaded and resolved: 'VERIFIED_REJECTED
> Number of LocalVariableTable attributes of Code attribute '<CODE>'
> (method 'public static String doItStatic()') exceeds number of local
> variable slots '0' ('There may be no more than one LocalVariableTable
> attribute per local variable in the Code attribute.').
> '.
> InstructionHandle:    0: new[187](3) 25
>
> Execution Frame:
> Local Variables:
> 0: org.dspace.app.xmlui.eperson.Flow
> 1: <unknown object>
> OperandStack:
> Slots used: 0 MaxStack: 2.
> Execution flow:
>    0: new 25    [InstructionContext]
>
>
> If I remove the "staticThing" everything will just work. Any ideas or
> do I not understand something and javaflow can not handle static
> things? I would realy like to be able to develop the website with
> javaflow instead of using javascript now and converting it to javaflow
> later.
>
> Scott--
>
> Torsten Curdt wrote:
>
>>
>> On 21.03.2006, at 20:26, Andrew Madu wrote:
>>
>>> Hi,
>>> can someone please tell me why defining a class variable in a 
>>> javaflow class like so:
>>>
>>> public class Login extends AbstractContinuable
>>> {
>>>     static User userGlobal = new User();
>>>     .........
>>>
>>>
>>> would cause the following error to be generated?:
>>
>>
>>
>> Andrew, that's the BCEL code verifier that barfs on you.
>> Obviously for no good reason. Since I don't think you
>> are using trunk upgrading to a newer javaflow version
>> is probably no option.
>>
>> A subtile code change might make a difference. You could
>> try a bit ...but rather I would re-think your approach.
>> Despite the fact it should work - are you sure that a
>> static global user object is the right way to go?
>>
>> cheers
>> -- 
>> Torsten
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Scott Phillips <sc...@gmail.com>.
I am expeirementing JavaFlow and it seems to me to be so much of a 
better fit for our needs than javascript. However in trying to implement 
it I hook it into my backend I am recieving errors which are close to 
the example provided but I've found that any class which is used by a 
javaflow class can not use static variables? This causes problems 
because the back-end API that I am calling uses static variables in 
large number of cases for it's internal logging.

my javaflow contains the following lines / class:

TestMe me = new TestMe();
me.doIt();
sendPage("some/page");

public class TestMe
{
   // I cause the problem
   private static String staticThing = "I am static";

   public String doIt() {
     return "I have done it.";
   }
}


The flow will fail with:
org.apache.bcel.verifier.exc.StructuralCodeConstraintException: 
Instruction NEW constraint violated: Class 
'org.dspace.app.xmlui.eperson.TestMe' is referenced, but cannot be 
loaded and resolved: 'VERIFIED_REJECTED
Number of LocalVariableTable attributes of Code attribute '<CODE>' 
(method 'public static String doItStatic()') exceeds number of local 
variable slots '0' ('There may be no more than one LocalVariableTable 
attribute per local variable in the Code attribute.').
'.
InstructionHandle:    0: new[187](3) 25

Execution Frame:
Local Variables:
0: org.dspace.app.xmlui.eperson.Flow
1: <unknown object>
OperandStack:
Slots used: 0 MaxStack: 2.
Execution flow:
    0: new 25	[InstructionContext]


If I remove the "staticThing" everything will just work. Any ideas or do 
I not understand something and javaflow can not handle static things? I 
would realy like to be able to develop the website with javaflow instead 
of using javascript now and converting it to javaflow later.

Scott--

Torsten Curdt wrote:
> 
> On 21.03.2006, at 20:26, Andrew Madu wrote:
> 
>> Hi,
>> can someone please tell me why defining a class variable in a  
>> javaflow class like so:
>>
>> public class Login extends AbstractContinuable
>> {
>>     static User userGlobal = new User();
>>     .........
>>
>>
>> would cause the following error to be generated?:
> 
> 
> Andrew, that's the BCEL code verifier that barfs on you.
> Obviously for no good reason. Since I don't think you
> are using trunk upgrading to a newer javaflow version
> is probably no option.
> 
> A subtile code change might make a difference. You could
> try a bit ...but rather I would re-think your approach.
> Despite the fact it should work - are you sure that a
> static global user object is the right way to go?
> 
> cheers
> -- 
> Torsten
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Instruction INVOKEVIRTUAL constraint violated

Posted by Torsten Curdt <tc...@apache.org>.
On 21.03.2006, at 20:26, Andrew Madu wrote:

> Hi,
> can someone please tell me why defining a class variable in a  
> javaflow class like so:
>
> public class Login extends AbstractContinuable
> {
>     static User userGlobal = new User();
>     .........
>
>
> would cause the following error to be generated?:

Andrew, that's the BCEL code verifier that barfs on you.
Obviously for no good reason. Since I don't think you
are using trunk upgrading to a newer javaflow version
is probably no option.

A subtile code change might make a difference. You could
try a bit ...but rather I would re-think your approach.
Despite the fact it should work - are you sure that a
static global user object is the right way to go?

cheers
--
Torsten