Skip to main content

How to make squawk + spolibs work together

18 replies [Last post]
tcolakov
Offline
Joined: 2009-06-29
Points: 0

Hi,

I've this:
-I have x86-64 wiht x86 libs, java 1.5
-I have working squawk-native environment
-I have SunSpot SDK installed and working

And I want:
-I want to take spotlibs and transducer libs and put them into my squawk environment and make them working. My idea is, that I'd be able to take apps from SunSpot/sdk/Demos and run them in my squawk environment.

And I already tried/did:
-unpacked transducerlib.jar, spotlib_common.jar, spotlib_device.jar sources, recompiled it and put into my squawk env.
-then I tried to issue this command:
java -jar build.jar user-suite -cp:spotlib_common.jar:spotlib_device.jar:transducer_device.jar test
(test is org.sunspotworld.demo.LEDSampleCode)

and I've got this error:
at com.sun.squawk.util.ComputationTimer.execute(ComputationTimer.java:125)
at com.sun.squawk.util.ComputationTimer.time(ComputationTimer.java:159)
at com.sun.squawk.translator.Translator.load(Translator.java:662)
at com.sun.squawk.translator.Translator.load(Translator.java:356)
at com.sun.squawk.translator.ci.ConstantPool.getResolvedClass(ConstantPool.java:788)
at com.sun.squawk.translator.ci.ConstantPool$FieldOrMethod.getDefiningClass(ConstantPool.java:1014)
at com.sun.squawk.translator.ci.ConstantPool.getResolvedMethod(ConstantPool.java:878)
at com.sun.squawk.translator.ci.CodeParser.parseMethodOperand(CodeParser.java:1297)
at com.sun.squawk.translator.ir.IRBuilder.parseInstructions(IRBuilder.java:404)
at com.sun.squawk.translator.ir.IRBuilder.(IRBuilder.java:110)
at com.sun.squawk.translator.Code.convertPhase1(Code.java:240)
at com.sun.squawk.translator.Code.convert0(Code.java:389)
at com.sun.squawk.translator.Code.access$000(Code.java:44)
at com.sun.squawk.translator.Code$1.run(Code.java:427)
at com.sun.squawk.util.ComputationTimer.execute(ComputationTimer.java:125)
at com.sun.squawk.util.ComputationTimer.time(ComputationTimer.java:159)
at com.sun.squawk.translator.Code.convert(Code.java:425)
at com.sun.squawk.translator.ClassFile.convertMethods(ClassFile.java:418)
at com.sun.squawk.translator.ClassFile.convertPhase1(ClassFile.java:471)
at com.sun.squawk.translator.Translator.convert(Translator.java:376)
at com.sun.squawk.translator.Translator.computeClosure(Translator.java:685)
at com.sun.squawk.translator.Translator.close(Translator.java:428)
at com.sun.squawk.Romizer.translate(Romizer.java:725)
at com.sun.squawk.Romizer.access$000(Romizer.java:44)
at com.sun.squawk.Romizer$1.run
(Romizer.java:386)
at com.sun.squawk.util.ComputationTimer.execute(ComputationTimer.java:127)
at com.sun.squawk.util.ComputationTimer.time(ComputationTimer.java:177)
at com.sun.squawk.Romizer.run(Romizer.java:384)
at com.sun.squawk.Romizer.main(Romizer.java:348)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at com.sun.squawk.builder.Build.java(Build.java:3055)
at com.sun.squawk.builder.JavaCommand.run(JavaCommand.java:71)
at com.sun.squawk.builder.commands.LinkTarget.run(LinkTarget.java:154)
at com.sun.squawk.builder.Build$UserCommand.run(Build.java:1221)
at com.sun.squawk.builder.Build.run(Build.java:1656)
at com.sun.squawk.builder.Build.runCommand(Build.java:1612)
at com.sun.squawk.builder.Build.mainProgrammatic(Build.java:2154)
at com.sun.squawk.builder.Build.main(Build.java:2114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at com.sun.squawk.builder.launcher.Launcher.main(Launcher.java:58)
WARNING: Deferring NoClassDefFoundError for class com.sun.spot.sensorboard.EDemoBoard: javax.microedition.io.ConnectionNotFoundException: com/sun/spot/sensorboard/EDemoBoard.class while translating com.sun.spot.sensorboard.EDemoBoard
[translating suite test [closed: false, parent: transducerlib] ...]
WARNING: Deferring NoClassDefFoundError for class com.sun.spot.sensorboard.EDemoBoard while translating org.sunspotworld.demo.LEDSampleCode
[translating suite test [closed: false, parent: transducerlib] ...]
Romizer processed 0 classes and generated these files:
/home/store/work/phd/research/squawk/Todor/squawkSim/test/test.sym
/home/store/work/phd/research/squawk/Todor/squawkSim/test/test.suite
/home/store/work/phd/research/squawk/Todor/squawkSim/test/test.suite.metadata
/home/store/work/phd/research/squawk/Todor/squawkSim/test/test.suite.api

But last lines are saying, that the suite has been compiled. Also that's not problem of not having clasess, because when I omited to add transducer_device.jar, I've got errors like this

test/preprocessed/org/sunspotworld/demo/LEDSampleCode.java:25: package com.sun.spot.sensorboard does not exist
import com.sun.spot.sensorboard.EDemoBoard;
^
When I tried to run suite compiled by the commands above, with the following command:

./squawk -suite:test.test -cp:transducer_device.jar:spotlib_common.jar:spotlib_device.jar

I've got this new error:

org.sunspotworld.demo.LEDSampleCode
calling setupMemory
Bootstrap suite loaded
In Startup
java.lang.RuntimeException
at java.lang.Throwable.(bci=16)
at java.lang.Exception.(bci=5)
at java.lang.RuntimeException.(bci=5)
in static method #3 of com.sun.squawk.Suite(bci=33)
in static method #4 of com.sun.squawk.Suite(bci=6)
in virtual method #45 of com.sun.squawk.Isolate(bci=28)
at com.sun.squawk.Isolate.(bci=132)
at com.sun.squawk.JavaApplicationManager.main(bci=117)
in virtual method #97 of com.sun.squawk.Klass(bci=25)
at com.sun.squawk.Isolate.run(bci=411)
at java.lang.Thread.run(bci=17)
in virtual method #47 of com.sun.squawk.VMThread(bci=42)
in static method #3 of com.sun.squawk.VM(bci=6)
Error constructing Isolate based on suite: file://test.test.suite and classpath: transducer_device.jar:spotlib_common.jar:spotlib_device.jar
java.lang.Error: IO error while loading suite from 'file://test.test.suite': javax.microedition.io.ConnectionNotFoundException

I will welcome any help or direction or text, which can push me forward. I has been stuck in this for two days, I desperately need help.

Todor

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fraybentos
Offline
Joined: 2007-11-16
Points: 0

This isn't going to work. The SPOT SDKs assume the presence of Sun SPOT hardware.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

I don't think you are completely right. Solarium does it quite successfully, even without SunSPOT.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

You are both correct :)

The Sun SPOT libraries assume that there is an implementation of various interfaces that connect to the actual hardware.

Solarium, via the Emulator, does this.

So what I am not sure about here is what you are trying to do? The Emulator from the Sun SPOT SDK already does this, so what do you need that it doesn't already do?

tcolakov
Offline
Joined: 2009-06-29
Points: 0

> You are both correct :)
>
> The Sun SPOT libraries assume that there is an
> implementation of various interfaces that connect to
> the actual hardware.
>
> Solarium, via the Emulator, does this.

Ok, so If I take the Emulator class, add it (somehow) to my project so then I'd be able to run
the application without SunSpot? Is there a easy way how to add it? Or it's comprise difficult squawk-fu?

>
> So what I am not sure about here is what you are
> trying to do? The Emulator from the Sun SPOT SDK
> already does this, so what do you need that it
> doesn't already do?
Because call me weird, but I'd like to know, how it works together (and how it works inside). To achieve this, I usually try to get a working subset of original and try to make it working. With Squawk it's all the same, I'm trying to understand it, so I'd like to have small environment without SpotSDK (and solarium), where I'd be able to do experiments.

Todor

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Ok, so you should be able to experiment by compiling Squawk on the desktop OS you are running on and having it work. The issue will be to try and get the Sun SPOT classes, ie spotlib, over to this environment. This is harder to do than one would think.

So is having just Squawk good enough?

tcolakov
Offline
Joined: 2009-06-29
Points: 0

I'd like to have not just squawk, but also spotlibs working with squawk. I understand, that it can be challenge, but I ready for it. Are you able to (and willing to ;) help me? I will then write it into a walkthrough for others.
Thanks
Todor

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

I am always willing to help, however in this case it may need a lot more than I can do via these forums.

If you have checked out the code from sunspot side, taken a look at how the Emulator is built, then I think you have a chance of succeeding and would love to see it. The Emulator is already ready to build itself and squawk, so it should be doable.

Let us know how it goes.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Hi,

so as far as I can tell, the Emulator class is basically combination of debugger proxy (it accepts commands from solarium and then it executes them) and internal states of SunSpot. I found, that it builds its own isolate, so it replaces debugger isolate. Thus to make spotlibs working together with squawk, I should take Emulator class, build a emulator isolate (somehow) with my squawk installation and then run sunspot program trough this isolate (somehow). Am I right?
Todor
P.S> I'm glad that there are still people willing to help :)

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Some of it sounds right, but suble.

The Emulator is not a debugger proxy in the Squawk sense, it is an implementation of a SpotClient I think, but you are right that it accepts commands from Solarium.

No it does not replace the debugger Isolate. It creates a suite which the Emulator then launches a Squawk instance to load up the suite. The suite has its own spotlib that implements the sensors and such on top of Squawk for desktop.

Hope that helps.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Ok, I've managed to get Emulator working without solarium and I think that I understand how it works (at least to some degree :). I've tried to do next step, which is to compile my own version of spotlibraries (core, multihop and transducer), but I've hit another problem. They don't want to compile :/ I use svn version of core libraries. I svn them from trunk first, then I issue these commands:

cd spotlib
ant jar-app

and I get this as output:
-do-compile:
[mkdir] Created dir: /home/research/sde/src/spots-core-libraries/spotlib/build
[javac] Compiling 235 source files to /home/store/work/research/sde/src/spots-core-libraries/spotlib/build
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/midp/io/j2me/multicast/DatagramObject.java:37: cannot find symbol
[javac] symbol : class MulticastDatagram
[javac] location: package javax.microedition.io
[javac] import javax.microedition.io.MulticastDatagram;
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/midp/io/j2me/multicast/DatagramObject.java:42: cannot find symbol
[javac] symbol: class MulticastDatagram
[javac] public class DatagramObject implements MulticastDatagram {
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/midp/io/j2me/multicast/Protocol.java:39: cannot find symbol
[javac] symbol : class MulticastConnection
[javac] location: package javax.microedition.io
[javac] import javax.microedition.io.MulticastConnection;
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/midp/io/j2me/multicast/Protocol.java:65: cannot find symbol
[javac] symbol: class MulticastConnection
[javac] public class Protocol extends ConnectionBase implements MulticastConnection {
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/squawk/io/j2me/serversocket/Protocol.java:30: cannot find symbol
[javac] symbol : class ServerSocketConnection
[javac] location: package javax.microedition.io
[javac] import javax.microedition.io.ServerSocketConnection;
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/squawk/io/j2me/serversocket/Protocol.java:42: cannot find symbol
[javac] symbol: class ServerSocketConnection
[javac] public class Protocol extends ConnectionBase implements ServerSocketConnection {
[javac] ^
[javac] /home/research/sde/src/spots-core-libraries/spotlib/src/com/sun/squawk/io/j2me/socket/Protocol.java:43: cannot find symbol

... and so on (13 errors in total).

My .sunspot.properties contains this paths:

sunspot.home=
sunspot.lib=${sunspot.home}/lib

I think the problem my lie in those libraries (maybe they are older than svn version), sdk is the recent version. When I tried to change the location to my squawk build, I've got like 100 errors. So I assumed, that the builder is not able to find correctly named jar files. Is there a easy way to build spotlib on my squawk build? (Some how-to somewhere possibly?)

Thank you
Todor
P.S> yes, your message helped a lot.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Are you sure that what you build made it into the location you are using for sdk path and lib?

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Hmm, no, I'm not. So should I go through ant script and find which location it uses? My second question is if the command ant jar-app issued in the spotlib directory is enough to build it.
Thanks
Todor

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

You need to replace the appropriate parts in sdk/lib I think is the location.

You can use ant suite, which will make sure that all the parts you need are there to build the suite that can be deployed or run on Squawk.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Hello,

I'm progressing well. I've managed to build squawk+spotlibs+emulator (through a script - I may post it here, if you (or anybody else) wish it). I've found, that problem wasn't just with path, but also with build.properties, I had to change two options to true in order to compile spotlibs
FLASH_MEMORY
VERIFY_SIGNATURES

But the FLASH_MEMORY brings me another problem at the end, when I tried to run squawk executable, I've got this error
Exception in thread "main" java.lang.RuntimeException: Assertion failed: should not reach here: Unknown global IO operation opcode: 303
at com.sun.squawk.util.Assert.throwAssertFailedException(Assert.java:70)
at com.sun.squawk.util.Assert.throwAssertFailedException(Assert.java:80)
at com.sun.squawk.util.Assert.shouldNotReachHere(Assert.java:152)
at com.sun.squawk.vm.ChannelIO.execute(ChannelIO.java:166)
CIO_execute failure

Can you direct me further?
Thanks Todor

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

You need to implement the primitives that are normally implemented in the VM. If you look at com.sun.squawk.cm.ChannelConstants, it defines a bunch of constants. These correspond to some native functions that need to be implemented. 303 seems to be GET_CURRENT_TIME_ADDR.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Ok, but I'm not quite sure, what should this GET_CURRENT_TIME_ADDR do. From its name, I would suppose, that it return current time, probably stored on some address in memory?
Todor

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

I would derive the same from the name, it is the address of the bytes to read to get the current time. Now, if you wanted to know more generally, just look at the users of the constant and see what they do with it. For the native functionality, this should be pretty simple.

tcolakov
Offline
Joined: 2009-06-29
Points: 0

Hi,

so after some time of not-responding... I've a news - my problem is finally solved, though not as cleanly as I would like... I've just by deleted the part which called the ChannelIO with "unknow opp code" - it worked, because it is called just from one place (VM.java:getCurrentMilis or something like that) and it has working code for non-Flash version. So it works. But, i don't know, it this could cause some problems in future (hope it wont). Anyway, I tried to implement the native function (which seemed quite straight), but I ended up on two things - first: I didn't know where to put the code and how to call it. I would like to do it right, so I'd be yet again grateful if you helped me on this, but I you are as busy as I suppose you to be, there is no rush (until first error ;), because it works (for now). Thank you for support.
Todor