Skip to main content

developerworkslabel >  Java technology  >  forumlabel  >  Java Virtual Machine (JVM) and Bytecode  >  developerWorks

problem of "instanceof" operator with IBM's JDK1.5    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

loginbox.header
 loginbox.welcomelabel loginbox.guestlabel
loginbox.signin
Permlink Replies: 0 - Pages: 1
shixs

Posts: 1
Registered: Nov 10, 2009 02:59:26 AM
problem of "instanceof" operator with IBM's JDK1.5
Posted: Nov 10, 2009 05:33:02 AM
Click to report abuse...   Click to reply to this thread Reply
Attachment du.class (36.3 KB)
Hi,
When using the JDK1.5 and an obfuscated libarary(by Proguard), we randomly encountered an issue. The issue occured randomly. For the same application, maybe it can run first time ok, and when run it again the issue occured. After tracing the libarary, we found maybe the cause is that the "instanceof" operator gives wrong result. For example, see attached one class file, there is a method with signature:

private boolean a(dn, String, char c1, int, int, char, short)

In this method, the work flow should be(following is what should occur in our original class, and we do not know what has happened after the class being obfuscated.):
There is one object, assume it is named as "address". "address" is got by invoking another method a(int, int, char[], int, int, int, int).
Just follows the code to get "address", we print out the class named "address" and check the type of "address" by operator "instanceof":
Object address = a(...); //invoke a(int, int, char[], int, int, int, int);
System.out.println("--------" + ... + address.getClass().getName()
+":ca " + (address instanceof gI) +":cr " + (address instanceof W)
+":nm " + (address instanceof Name));
if(address instanceof gI)
{
gI ca = (gI)address;
System.out.println("--------" + ...); //print some properties of ca
}
When running our application, the result we got is:
---------1:-1:com.aspose.cells.gI:ca true:cr false:nm false
--------7:4:false:false
This means that "address" does is instance of gI. However, when the flow goes to next step,
System.out.println("no sn");
if(address instanceof gI)
{
...;
}
else if(address instanceof W)
{
...;
}
else if(address instanceof Name)
{
...;
}
else
{
System.out.println("--------!!!!2Error here: " + address.getClass().getName()) + ":" + (s instanceof gI));
}
the output is:
no sn
--------!!!!2Error here: com.aspose.cells.gI:false
So, here address' class is still com.aspose.cells.gI but (address instanceof gI) is false.
And if we try following code:
gI v = (gI)address;
the flow will exit this method and all codes after that will be ignored just like they does not exist.

Any help will be appreciated. By the way, the obfuscated libarary can work fine with Sun's JDK.

Some other information:

The JDK:

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pwi32devifx-20080907 (SR8a + IZ297
67 + IZ30684 + IZ31214 + IZ31213))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223ifx-20080811 (JIT
enabled)
J9VM - 20080809_21892_lHdSMr
JIT - 20080620_1845_r8
GC - 200806_19)
JCL - 20080907

The OS: Windows XP
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums