J
Jeffy
Two specific questions:
First, when given a package name ("java.util"), how can I determine
that--first of all--the package truly exists in the CLASSPATH, and
then retrieve all the class names that exist in that package?
Second, say I have the below Java source code. I need to determine
the fully-qualified class name for an identifier ("Vector" in this
case, only the class names, not the variable names), depending on
where it is found. Are there any parsers existing that can help me
with this? Is there any way to access the parsing abilities of the
javac compiler?
Thank you for any insights :' )
---------------
---------------
---------------
---------------
import java.util.Vector;
public class MyClass {
MyClass() {
Vector vJavaUtil = new Vector();
System.out.println("cnstr a: " + vJavaUtil.getClass().getName());
class Vector {
Vector() {
}
}
Vector vInner = new Vector();
System.out.println("cnstr b: " + vInner.getClass().getName());
}
public void myFunction() {
Vector vJavaUtil = new Vector();
System.out.println("mf a: " + vJavaUtil.getClass().getName());
class Vector {
Vector() {
}
}
//The inner class Vector
Vector vInner = new Vector();
System.out.println("mf b: " + vInner.getClass().getName());
}
public static void main(String[] as_cmdLineParams) {
(new MyClass()).myFunction();
}
}
First, when given a package name ("java.util"), how can I determine
that--first of all--the package truly exists in the CLASSPATH, and
then retrieve all the class names that exist in that package?
Second, say I have the below Java source code. I need to determine
the fully-qualified class name for an identifier ("Vector" in this
case, only the class names, not the variable names), depending on
where it is found. Are there any parsers existing that can help me
with this? Is there any way to access the parsing abilities of the
javac compiler?
Thank you for any insights :' )
---------------
---------------
---------------
---------------
import java.util.Vector;
public class MyClass {
MyClass() {
Vector vJavaUtil = new Vector();
System.out.println("cnstr a: " + vJavaUtil.getClass().getName());
class Vector {
Vector() {
}
}
Vector vInner = new Vector();
System.out.println("cnstr b: " + vInner.getClass().getName());
}
public void myFunction() {
Vector vJavaUtil = new Vector();
System.out.println("mf a: " + vJavaUtil.getClass().getName());
class Vector {
Vector() {
}
}
//The inner class Vector
Vector vInner = new Vector();
System.out.println("mf b: " + vInner.getClass().getName());
}
public static void main(String[] as_cmdLineParams) {
(new MyClass()).myFunction();
}
}