QDox
  1. QDox
  2. QDOX-208

method.getLineNumber broken in 1.11

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.10, 1.10.1, 1.11
    • Fix Version/s: 1.12
    • Component/s: None
    • Labels:
      None
    • Environment:
      WindowsXP, Linux
    • Number of attachments :
      0

      Description

      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

        Activity

        Hide
        Robert Scholte added a comment -

        We have some unittests which check the linenumbers, so this is just much too general. Does it affect qdox-1.10.1 as well?
        The only issue where I had to touch the linenumbers was QDOX-168, but this was part of the 1.10 release.
        So first of all provide the smallest test, asserting the rownumbers. Otherwise it's just that needle in the haystack.

        Show
        Robert Scholte added a comment - We have some unittests which check the linenumbers, so this is just much too general. Does it affect qdox-1.10.1 as well? The only issue where I had to touch the linenumbers was QDOX-168 , but this was part of the 1.10 release. So first of all provide the smallest test, asserting the rownumbers. Otherwise it's just that needle in the haystack.
        Hide
        Alfred Pfeffer added a comment - - edited

        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
        -----------------------------------------

        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);
          }
        }
        

        ---------------------------------------
        the rubbish code to be analysed
        --------------------------------------

        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;
        
          }
        
          
        
        
        
          
        
        }
        

        I hope this helps

        Kind regards
        Alfred Pfeffer

        Show
        Alfred Pfeffer added a comment - - edited 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 ----------------------------------------- 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); } } --------------------------------------- the rubbish code to be analysed -------------------------------------- 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 ; } } I hope this helps Kind regards Alfred Pfeffer
        Hide
        Robert Scholte added a comment -

        We're getting closer
        Since your qdox-1.10 has a timestamp it's just a SNAPSHOT-version, not the final qdox-1.10
        It looks like QDOX-168 is responsible for the number shifting. Without javadocs there's no problem, but once they're added the linenumbers are not in sync anymore.
        I have to dive a bit deeper into this issue.

        Show
        Robert Scholte added a comment - We're getting closer Since your qdox-1.10 has a timestamp it's just a SNAPSHOT-version, not the final qdox-1.10 It looks like QDOX-168 is responsible for the number shifting. Without javadocs there's no problem, but once they're added the linenumbers are not in sync anymore. I have to dive a bit deeper into this issue.
        Hide
        Robert Scholte added a comment -

        Fixed in rev. 729

        Show
        Robert Scholte added a comment - Fixed in rev. 729
        Robert Scholte made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Robert Scholte [ rfscholte ]
        Fix Version/s 1.12 [ 16282 ]
        Resolution Fixed [ 1 ]
        Robert Scholte made changes -
        Affects Version/s 1.10.1 [ 15653 ]
        Affects Version/s 1.10 [ 15020 ]

          People

          • Assignee:
            Robert Scholte
            Reporter:
            Alfred Pfeffer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: