Andy Young

Greenhorn
+ Follow
since Nov 03, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andy Young

Hi,

I found the problem by accident: I refactored some code meaning that i was no longer parsing xml and thus i noticed i had a dom4j.jar on the classpath. removing this meant that it all worked fine. I presume it was getting confused between the classes inside the dom4j.jar and the DatatypeAttribute.class file, probably because like you said, the parent is searching for classes first (when it finds the jar file), and then cannot access the required classes as these are only known to my class loader (the child).

Thanks for your help.

Andy
15 years ago
Hi,

I need to be able to create a URLClassLoader at runtime which i then load classes from. I load a number of compiled classes and some jar files into the URLClassLoader like this:



where jars in an array of URLs pointing to jar files and classes is the root directory of some classes.

When i attempt to load a class (in the compiled class directory, NOT in a jar), which uses classes from one or more of the certain jars, i get a java.lang.NoClassDefFoundError.


For example, attempting
throws

because DatatypeAttribute uses SerializationContext (which is in a jar file).

But, if i try then it loads the SerializationContext class with no problems, so i know the class within the jar exists and is accessible, so why cant the call to loadClass("org.dom4j.datatype.DatatypeAttribute") load the DerializationContext class?


Some other classes which i load that use classes from other jar files load correctly.


Does anyone have any idea what can be causing this?


Thanks,
Andy


15 years ago
How would i go about getting references to methods from within the .class files?
15 years ago
no, because i don't actually want to have to execute the code, just analyse the content of the source
15 years ago
i want to be able to work out which methods in a particular set of java source files are the most called throughout the code. Hence, i need to be able to know how many times each method is called. any other ideas?
15 years ago
Can you suggest any tools which would allow me to go about that?
15 years ago
Hi,

I need a way to be able to programatically get the number of references to a given method(number of times it is called) within a group of source code files.

Basically i need to do the same as the NetBeans "Find Usages" refactoring tool, but i need to do it programatically. I have played around with the Netbeans jar files but cannot work out how to do it!

Does anyone know how to call the netbeans "Find Usages" programatically? Or have any other ideas of how to implement this (perhaps by parsing the source files etc.)

Thanks,

Andy
15 years ago
Hi and thanks for your replies.

After googleing "java cyclomatic complexity" it appears that Cyvis will work nicely for me to look at how complex a method's content is.

As for the code coverage tools...something like Emma is not sufficient for what I am looking to do. Perhaps i should explain for thoroughly...

I want to write a Java program to analyse some given Java source code (from a different program) and work out which methods in that source code are called the most. Emma and Clover just state which parts of a running program were called (and i dont intend to run the source code i want to analyse). I would like to know how many places within the given source code call each of the methods in that source code (like the NetBeans "Find Usages" functionality when right-clicking a method). Any ideas?

Thanks,

Andy
15 years ago
Hi guys,

I am trying to look at the content of a Java method in order to analyse how "complex" it is. E.g. how many If, while, switch etc. statements there are. In addition to this, I would also like to know how many times a method is called from within a package (much like the Netbeans "Find Usages" functionality).

My initial idea is that I need to create a parser for the Java language (probably using ANTLR) though I'm not entirely sure this will do what I want. Can anyone advise me on this? Or know of any other way of analysing the content of a method?

Thanks,

Andy
15 years ago