Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7157671

compiler tree API: incorrectly detects start/end positions under JDK6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 6
    • 6
    • tools
    • None
    • generic
    • generic

      I use compiler tree API to find start/end positions of the import constructs.

             SourcePositions sourcePositions = Trees.instance(task).getSourcePositions();
             long s = sourcePositions.getStartPosition(untiTree, impTree);
             long e = sourcePositions.getEndPosition(untiTree, impTree);

      It seems to me that under jdk6 the end position of the import constructs is not detected correctly. A small class demonstrating the problem (Javac.java) is attached. Being run under jdk6/jdk7 it reports different results:

      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode)
      File: Javac.java
      import: 0:0
      import: 48:48
      import: 87:87
      import: 125:125
      import: 169:169
      import: 203:203
      import: 224:224
      import: 252:252
      import: 280:280
      import: 303:303
      import: 336:336
      import: 371:371
      import: 415:415
      -----
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)
      File: Javac.java
      import: 0:47
      import: 48:86
      import: 87:124
      import: 125:168
      import: 169:202
      import: 203:223
      import: 224:251
      import: 252:279
      import: 280:302
      import: 303:335
      import: 336:370
      import: 371:414
      import: 415:447

      Trivial run.sh script is attached as well.

            robm Robert Mckenna
            dfazunen Dmitry Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: