preprocessor support in j2me-maven-plugin

20 views
Skip to first unread message

M2 Mixa

unread,
Mar 29, 2010, 9:08:14 AM3/29/10
to pyx4me...@googlegroups.com
Hi all,
is my understanding correct that j2me-maven-plugin doesn't support
preprocessing (offered by antenna) except for instrumentation offered
by jour? And per my understanding would be the same as using
'-assumenosideeffects' option of proguard?

TIA,
Mike

Vlad Skarzhevskyy

unread,
Mar 29, 2010, 10:37:57 AM3/29/10
to pyx4me...@googlegroups.com
Yes java code manipulations no supported. only byte code.

Vlad



--
You received this message because you are subscribed to the Google Groups "pyx4me-users" group.
To post to this group, send email to pyx4me...@googlegroups.com.
To unsubscribe from this group, send email to pyx4me-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyx4me-users?hl=en.


M2 Mixa

unread,
Mar 29, 2010, 11:25:27 AM3/29/10
to pyx4me...@googlegroups.com
OK, now I'm trying to figure how I can use instrumentation properly
for such purposes (I'm preprocess-minded so it takes a bit). Let's
assume I have a class dedicated for some feature. Let's call it
Feature1.java:

class Feature1 {
public Feature1() {
}
public static final boolean isFeature1Supported() {
... some run-time checks if a feature (ie an JSR) is supported on
device ...
}
public void doFeature() {
if(isFeature1Supported()) {
... feature's code here ...
}
}
}

My approach is to tell jour that isFeature1Supported() returns false,
so proguard will eliminate
unnecessary code. Sounds good? How can I do that in jour (make a
function to return false) - do I need to write my own instrumentation
or can use a standard one?

TIA,
Mike

Vlad Skarzhevskyy

unread,
Mar 29, 2010, 11:30:02 AM3/29/10
to pyx4me...@googlegroups.com
I have not done this out of the box.
You probably need to do something with Javassist.

Vlad

M2 Mixa

unread,
Mar 29, 2010, 11:32:27 AM3/29/10
to pyx4me...@googlegroups.com
If I use MakeEmptyMethodInstrumentor for isFeature1Supported() - what
will be result of its evaluation, in the 'if' statement?

Mike

Vlad Skarzhevskyy

unread,
Mar 29, 2010, 11:33:15 AM3/29/10
to pyx4me...@googlegroups.com
It is up to proguard . Try and see.

Vlad

M2 Mixa

unread,
Mar 30, 2010, 11:07:16 AM3/30/10
to pyx4me...@googlegroups.com
Well, I did the experiment - applied MakeEmptyMethodInstrumentor to a
boolean function normally returning true. After instrumentation it
returns false. It would do for me, but I'm not sure if it is OK from
bytecode point of view - 'false' could be just a garbage on JVM stack.

Probably I should use something more certain - make my own
instrumentor. So I need to add it to cldcunit-instrument artifact,
correct?

Mike

On Mon, Mar 29, 2010 at 7:33 PM, Vlad Skarzhevskyy

Vlad Skarzhevskyy

unread,
Mar 30, 2010, 11:31:14 AM3/30/10
to pyx4me...@googlegroups.com
Instrumentation is just a separate module. You add it to class path of plugin.  cldcunit-instrument   can be used as example to create your own bytecode instrumentor.

Vlad

M2 Mixa

unread,
Mar 30, 2010, 11:43:54 AM3/30/10
to pyx4me...@googlegroups.com
Thanks for the info.

I had a look at sources of jour, to see how
MakeEmptyMethodInstrumentor works, to use it as a start point, and
found out that it already handles return values for the empty method
(and returns false for boolean ones). So it is WAD and meets my needs.

Thanks for that,
Mike

Reply all
Reply to author
Forward
0 new messages