Java code analyzer recommendations?

H

Harpstein

Hey all,

I'm wondering if any products exist out there that will analyze my Java code
and report back to me about what JDK calls I'm making and what version the
calls are in. I'd prefer a free product, but anything will do at this point.

The problem I have is that my stuff has to work on Mac OS X, and since they
are still at 1.3.1 of the JDK I'm concerned that I have a bunch of "hidden"
bugs where I'm making calls to 1.4 methods that will fail on Mac. However,
they're runtime failures so the only way I know to find them right now is
through testing. One example I've already found is that I was using
String.replaceAll() which is a 1.4 method, and it was failing on Mac OS X.

Any help/suggestions would be greatly appreciated.

Thanks,

harpstein
 
A

ak

you can install on your computer java 1.3.1 and recompile all with 1.3.1
compiler.

I use to compile my library 1.18 and for javadoc creating 1.3 or 1.4
I just switch it in my IDE (Intellij IDEA).
 
H

Harpstein

My stuff is in a jar and I did compile it on my Mac with 1.3.1 and it didn't
complain about anything. Yet, there was the String.replaceAll method that
was invalid.

It seems like I always find these NoSuchMethodError errors at runtime
instead of compile-time...

-harpstein
 
M

Michael Borgwardt

Harpstein said:
My stuff is in a jar and I did compile it on my Mac with 1.3.1 and it didn't
complain about anything. Yet, there was the String.replaceAll method that
was invalid.

It seems like I always find these NoSuchMethodError errors at runtime
instead of compile-time...

Then you're doing something wrong. There WAS NO String.replaceAll() method
prior to 1.4, so the code could never compile on a 1.3 JDK.

Either you did not compile it, or you did not use a 1.3 JDK.
 
H

Harpstein

Well, 1.4.1 is installed on my Mac, but it's not the default runtime so I
just assumed that it wasn't the default compile either. Maybe that's what's
goofing me up...

-harpstein
 
A

ak

if you use IDE then you should "rebuild projekt", otherwise first manuell
delete all your class files and then recompile.
 
M

Michael Borgwardt

Harpstein said:
Well, 1.4.1 is installed on my Mac, but it's not the default runtime so I
just assumed that it wasn't the default compile either. Maybe that's what's
goofing me up...

Yes, that sounds like it.

You can explicitly specify the API to compile against with the -bootclasspath
and -extdirs options to javac. Using that and -target 1.3 you can compile code
that should definitely run on 1.3 no matter which compiler it is.
 
H

Harpstein

thanks for the ptrs. I'm using Ant to build so it should be too difficult to
do that at all.

-matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top