[
http://jira.codehaus.org/browse/QDOX-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=218787#action_218787
]
Robert Scholte edited comment on QDOX-208 at 4/25/10 11:29 AM:
---------------------------------------------------------------
Sorry i have to agree that i provided much too less information. My only excuse
is that it was in the middle of the night and the onyl thing i wanted was to go
to bed.
I have here some very simple sample code to show the problem. I will just past
it in here. I hope i will not break your conventions in doing so.
There are 2 classes, one simple analyser and some piece of rubbish code to be
analysed.
Using qdox-1.11 gives false line numbers. Using qdox-1.10-20090625.205651-6.jar
the line numbers are ok. I did not test any other version.
----------------------------------------
the simple analyser
-----------------------------------------
{code:title=JavaMethodLinePrinter.java}
package test;
import java.io.FileNotFoundException;
import java.io.FileReader;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaMethod;
public class JavaMethodLinePrinter{
public void printMethods(JavaClass aClass) {
JavaMethod methods[] = aClass.getMethods();
for (JavaMethod method : methods) {
System.out.println(method.getName() + " starts at line:
"+method.getLineNumber());
}
}
public void checkJavaFile(String aFileName) throws FileNotFoundException {
JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new FileReader(aFileName));
JavaClass classes[] = builder.getClasses();
for (JavaClass javaClass : classes) {
printMethods(javaClass);
}
}
public static void main(String[] args) throws FileNotFoundException {
String fileName = "./src/test/SomeVeryStupidExampleCodeToBeParsed.java";
JavaMethodLinePrinter p = new JavaMethodLinePrinter();
p.checkJavaFile(fileName);
}
}
{code}
---------------------------------------
the rubbish code to be analysed
--------------------------------------
{code:title=SomeVeryStupidExampleCodeToBeParsed.java}
package test;
import java.util.Collection;
import java.util.Set;
import org.apache.log4j.Logger;
/**
* Some stupid nonsense code only provided to be analysed
*/
public abstract class SomeVeryStupidExampleCodeToBeParsed {
/**
* Slave event queue name. Input queue for slave ExternalEventManager.
*/
public static final String EVENT_QUEUE_NAME =
"EventQueue";
public static final String RUNNABLE_QUEUE_NAME =
"RunnableQueue";
private static final Logger ourLogger =
Logger.getLogger(SomeVeryStupidExampleCodeToBeParsed.class);
private static final String EVENTCONSUMER_PROVIDER_ID =
"PLUGIN_IDxyz";
private static SomeVeryStupidExampleCodeToBeParsed ourInstance;
protected long mySequenceNbr;
/**
* some comment in here
*/
protected SomeVeryStupidExampleCodeToBeParsed() {
// some code comes here
}
/**
* some comment in here
*/
public void reset() {
//some code in here
}
/**
* some comment in here
*/
public static synchronized SomeVeryStupidExampleCodeToBeParsed getInstance() {
//some code in here;
return ourInstance;
}
public void destroy() {
//some code here;
}
/**
* {...@inheritdoc}
* some comment
*/
public final boolean someBooleanFkt() {
return true;
}
/** {...@inheritdoc}
* some comment
*/
public abstract void someAbstractMethod(String aParameter);
/**
* {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#modifyEventQueuePriority(java.lang.String,
int)
*/
public boolean stillAnotherFkt(String aXyz) throws IllegalArgumentException {
if (aXyz == null) {
throw new IllegalArgumentException("no null param allowed");
}
return true;
}
/* (non-Javadoc)
* some comment
*/
public String getSomething() {
return null;
}
/* (non-Javadoc)
* dkadjkdf
*/
public Collection<Object> getCollection() {
return null;
}
boolean isSomething() {
return false;
}
/** {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#getQueueNames()
*/
public Set<String> getSomeSet() {
return null;
}
/** {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#getNumberOfEventQueues()
*/
public int getNumberOfSomething() {
return 0;
}
/** {...@inheritdoc}
*/
public long getActualSomething() {
return -1L;
}
/**
* {...@inheritdoc}
*/
public abstract long getRemoteSomething();
/**
* {...@inheritdoc}
*/
public Object getActualSomethingElse() {
return null;
}
}
{code}
I hope this helps
Kind regards
Alfred Pfeffer
was (Author: apfeffer):
Sorry i have to agree that i provided much too less information. My only
excuse is that it was in the middle of the night and the onyl thing i wanted
was to go to bed.
I have here some very simple sample code to show the problem. I will just past
it in here. I hope i will not break your conventions in doing so.
There are 2 classes, one simple analyser and some piece of rubbish code to be
analysed.
Using qdox-1.11 gives false line numbers. Using qdox-1.10-20090625.205651-6.jar
the line numbers are ok. I did not test any other version.
----------------------------------------
the simple analyser
-----------------------------------------
package test;
import java.io.FileNotFoundException;
import java.io.FileReader;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaMethod;
public class JavaMethodLinePrinter{
public void printMethods(JavaClass aClass) {
JavaMethod methods[] = aClass.getMethods();
for (JavaMethod method : methods) {
System.out.println(method.getName() + " starts at line:
"+method.getLineNumber());
}
}
public void checkJavaFile(String aFileName) throws FileNotFoundException {
JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new FileReader(aFileName));
JavaClass classes[] = builder.getClasses();
for (JavaClass javaClass : classes) {
printMethods(javaClass);
}
}
public static void main(String[] args) throws FileNotFoundException {
String fileName = "./src/test/SomeVeryStupidExampleCodeToBeParsed.java";
JavaMethodLinePrinter p = new JavaMethodLinePrinter();
p.checkJavaFile(fileName);
}
}
---------------------------------------
the rubbish code to be analysed
--------------------------------------
package test;
import java.util.Collection;
import java.util.Set;
import org.apache.log4j.Logger;
/**
* Some stupid nonsense code only provided to be analysed
*/
public abstract class SomeVeryStupidExampleCodeToBeParsed {
/**
* Slave event queue name. Input queue for slave ExternalEventManager.
*/
public static final String EVENT_QUEUE_NAME =
"EventQueue";
public static final String RUNNABLE_QUEUE_NAME =
"RunnableQueue";
private static final Logger ourLogger =
Logger.getLogger(SomeVeryStupidExampleCodeToBeParsed.class);
private static final String EVENTCONSUMER_PROVIDER_ID =
"PLUGIN_IDxyz";
private static SomeVeryStupidExampleCodeToBeParsed ourInstance;
protected long mySequenceNbr;
/**
* some comment in here
*/
protected SomeVeryStupidExampleCodeToBeParsed() {
// some code comes here
}
/**
* some comment in here
*/
public void reset() {
//some code in here
}
/**
* some comment in here
*/
public static synchronized SomeVeryStupidExampleCodeToBeParsed getInstance() {
//some code in here;
return ourInstance;
}
public void destroy() {
//some code here;
}
/**
* {...@inheritdoc}
* some comment
*/
public final boolean someBooleanFkt() {
return true;
}
/** {...@inheritdoc}
* some comment
*/
public abstract void someAbstractMethod(String aParameter);
/**
* {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#modifyEventQueuePriority(java.lang.String,
int)
*/
public boolean stillAnotherFkt(String aXyz) throws IllegalArgumentException {
if (aXyz == null) {
throw new IllegalArgumentException("no null param allowed");
}
return true;
}
/* (non-Javadoc)
* some comment
*/
public String getSomething() {
return null;
}
/* (non-Javadoc)
* dkadjkdf
*/
public Collection<Object> getCollection() {
return null;
}
boolean isSomething() {
return false;
}
/** {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#getQueueNames()
*/
public Set<String> getSomeSet() {
return null;
}
/** {...@inheritdoc}
* @see
com.alcatel.tas.hmi.externaleventmanager.IExternalEventManager#getNumberOfEventQueues()
*/
public int getNumberOfSomething() {
return 0;
}
/** {...@inheritdoc}
*/
public long getActualSomething() {
return -1L;
}
/**
* {...@inheritdoc}
*/
public abstract long getRemoteSomething();
/**
* {...@inheritdoc}
*/
public Object getActualSomethingElse() {
return null;
}
}
I hope this helps
Kind regards
Alfred Pfeffer
> method.getLineNumber broken in 1.11
> -----------------------------------
>
> Key: QDOX-208
> URL: http://jira.codehaus.org/browse/QDOX-208
> Project: QDox
> Issue Type: Bug
> Affects Versions: 1.11
> Environment: WindowsXP, Linux
> Reporter: Alfred Pfeffer
> Priority: Minor
>
> JavaMethod.getLineNumber worked in 1.10 but is broken in 1.11
> Always delivers too high line numbers when parsing java code and getting line
> information.
> Worked perfectly in 1.10
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email