You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Carlos Quiroz <cq...@gemini.edu> on 2011/04/19 17:02:48 UTC
Invalid bytecode generated on Scala based iPojo component
Hi all
I'm trying to use scala to produce iPojo components but I'm getting a verification class error that I have traced to the way iPojo manipulates the class files and generates new bytecodes. This happens when using the @Requires annotation in the constructor.
Here is what the java code looks like and the bytecodes produced:
<code>
@Component
@Instantiate
class StartObservationFactory(@(Requires @param) epicsReader: EpicsReader) extends KeywordActorsFactory {
</code>
and iPojo makes a new constructor taking an InstanceManager and an EpicsReader with the following bytecodes:
<bytecode>
private edu.gemini.aspen.gds.keywordssets.factory.StartObservationFactory(org.apache.felix.ipojo.InstanceManager, edu.gemini.epics.EpicsReader);
Code:
0: aload_0
1: aload_2
2: invokevirtual #159; //Method __setepicsReader:(Ledu/gemini/epics/EpicsReader;)V
5: aload_0
6: invokespecial #160; //Method java/lang/Object."<init>":()V
9: aload_0
10: aload_1
11: invokespecial #164; //Method _setInstanceManager:(Lorg/apache/felix/ipojo/InstanceManager;)V
14: return
</bytecode>
I think the verify error I get is due to the call of __setepicsReader before the call to the java/lang/Object constructor
This should be exactly as the Java code below:
<code>
@Component
@Instantiate(name = "epicsObserver")
public class EpicsObserverImpl implements EpicsObserver {
public EpicsObserverImpl(@Requires JCAContextController contextController)
</code>
But this produces a different bytecode:
<bytecode>
private edu.gemini.epics.impl.EpicsObserverImpl(org.apache.felix.ipojo.InstanceManager, edu.gemini.epics.JCAContextController);
Code:
0: aload_0
1: invokespecial #67; //Method java/lang/Object."<init>":()V
4: aload_0
5: aload_1
6: invokespecial #71; //Method _setInstanceManager:(Lorg/apache/felix/ipojo/InstanceManager;)V
9: aload_0
</bytecode>
Any ideas? I guess this is due to how the scala compiler produces the classes that are then process by the iPojo manipulator but I'm not able to propose a workaround now:
Regards
Carlos Quiroz
PS: This is the error I get when launching the bundle in felix:
[edu.gemini.aspen.gds.keywordssets.factory.StartObservationFactory-0] createInstance -> The POJO constructor invocation failed : (class: edu/gemini/aspen/gds/keywordssets/factory/StartObservationFactory, method: <init> signature: (Lorg/apache/felix/ipojo/InstanceManager;Ledu/gemini/epics/EpicsReader;)V) Expecting to find object/array on stack
java.lang.VerifyError: (class: edu/gemini/aspen/gds/keywordssets/factory/StartObservationFactory, method: <init> signature: (Lorg/apache/felix/ipojo/InstanceManager;Ledu/gemini/epics/EpicsReader;)V) Expecting to find object/array on stack
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:638)
at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:858)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__stateChanged(LifecycleCallbackHandler.java:156)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:471)
at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:353)
at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:166)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
at org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:343)
at org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89)
at org.apache.felix.ipojo.Extender.parse(Extender.java:269)
at org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:208)
at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
at org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:682)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Invalid bytecode generated on Scala based iPojo component
Posted by Clement Escoffier <cl...@gmail.com>.
Hi,
I'm not a Scala Expert. I've ask around and one hypothesis is the @param
annotation. Could you send me in the code and the instructions to run it.
I want to see if I can improve the iPOJO manipulator to turn around this
case.
Regards,
Clement
On 19.04.11 17:02, "Carlos Quiroz" <cq...@gemini.edu> wrote:
>Hi all
>
>I'm trying to use scala to produce iPojo components but I'm getting a
>verification class error that I have traced to the way iPojo manipulates
>the class files and generates new bytecodes. This happens when using the
>@Requires annotation in the constructor.
>
>Here is what the java code looks like and the bytecodes produced:
>
><code>
>@Component
>@Instantiate
>class StartObservationFactory(@(Requires @param) epicsReader:
>EpicsReader) extends KeywordActorsFactory {
></code>
>
>and iPojo makes a new constructor taking an InstanceManager and an
>EpicsReader with the following bytecodes:
>
><bytecode>
>private
>edu.gemini.aspen.gds.keywordssets.factory.StartObservationFactory(org.apac
>he.felix.ipojo.InstanceManager, edu.gemini.epics.EpicsReader);
> Code:
> 0: aload_0
> 1: aload_2
> 2: invokevirtual #159; //Method
>__setepicsReader:(Ledu/gemini/epics/EpicsReader;)V
> 5: aload_0
> 6: invokespecial #160; //Method java/lang/Object."<init>":()V
> 9: aload_0
> 10: aload_1
> 11: invokespecial #164; //Method
>_setInstanceManager:(Lorg/apache/felix/ipojo/InstanceManager;)V
> 14: return
></bytecode>
>
>I think the verify error I get is due to the call of __setepicsReader
>before the call to the java/lang/Object constructor
>
>This should be exactly as the Java code below:
>
><code>
>@Component
>@Instantiate(name = "epicsObserver")
>public class EpicsObserverImpl implements EpicsObserver {
>
> public EpicsObserverImpl(@Requires JCAContextController
>contextController)
></code>
>
>But this produces a different bytecode:
>
><bytecode>
>private
>edu.gemini.epics.impl.EpicsObserverImpl(org.apache.felix.ipojo.InstanceMan
>ager, edu.gemini.epics.JCAContextController);
> Code:
> 0: aload_0
> 1: invokespecial #67; //Method java/lang/Object."<init>":()V
> 4: aload_0
> 5: aload_1
> 6: invokespecial #71; //Method
>_setInstanceManager:(Lorg/apache/felix/ipojo/InstanceManager;)V
> 9: aload_0
></bytecode>
>
>Any ideas? I guess this is due to how the scala compiler produces the
>classes that are then process by the iPojo manipulator but I'm not able
>to propose a workaround now:
>
>Regards
>Carlos Quiroz
>
>PS: This is the error I get when launching the bundle in felix:
>[edu.gemini.aspen.gds.keywordssets.factory.StartObservationFactory-0]
>createInstance -> The POJO constructor invocation failed : (class:
>edu/gemini/aspen/gds/keywordssets/factory/StartObservationFactory,
>method: <init> signature:
>(Lorg/apache/felix/ipojo/InstanceManager;Ledu/gemini/epics/EpicsReader;)V)
> Expecting to find object/array on stack
>java.lang.VerifyError: (class:
>edu/gemini/aspen/gds/keywordssets/factory/StartObservationFactory,
>method: <init> signature:
>(Lorg/apache/felix/ipojo/InstanceManager;Ledu/gemini/epics/EpicsReader;)V)
> Expecting to find object/array on stack
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
> at java.lang.Class.getConstructor0(Class.java:2699)
> at java.lang.Class.getDeclaredConstructor(Class.java:1985)
> at
>org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:6
>38)
> at
>org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:
>858)
> at
>org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandle
>r.__stateChanged(LifecycleCallbackHandler.java:156)
> at
>org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandle
>r.stateChanged(LifecycleCallbackHandler.java)
> at
>org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:471)
> at
>org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:353)
> at
>org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.ja
>va:166)
> at
>org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.j
>ava:301)
> at
>org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.j
>ava:238)
> at
>org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCrea
>tor.java:343)
> at
>org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89
>)
> at org.apache.felix.ipojo.Extender.parse(Extender.java:269)
> at
>org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:208)
> at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
> at
>org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:682)
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>For additional commands, e-mail: users-help@felix.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org