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

[lworld] Bogus error message: incompatible types while using separate compilation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Reported by Maurizio.

      Given:

      $ cat Pointer.java
      public class Pointer<X> {
          final long addr;

          public Pointer(long addr) {
              this.addr = addr;
          }
      }
      $ cat Point.java
      public inline class Point {
          final int x;
          final int y;

          public Point(int x, int y) {
              this.x = x;
              this.y = y;
          }

          public static ForeignType<Point.ref> TYPE = new ForeignType<>() { };
      }
      $ cat ForeignType.java
      public class ForeignType<X> {
          public Pointer<X> allocate() { return null; }
      }
      $ cat X.java
      class X {
          public static void main(String[] args) {
              Pointer<Point.ref> p_ref = Point.TYPE.allocate();
          }
      }

      Compiling everything in one shot works fine:

      $ javac -g X.java Point.java Pointer.java ForeignType.java
      $

      Now recompile X.java alone picking up binary class files of others:
      $ ~/gitreps/valhalla/build/linux-x86_64-server-release/images/jdk/bin/javac -g X.java
      X.java:3: error: incompatible types: Pointer<Point$ref> cannot be converted to Pointer<Point$ref>
              Pointer<Point.ref> p_ref = Point.TYPE.allocate();
                                                            ^
      1 error
      $

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sadayapalam Srikanth Adayapalam
                Reporter:
                sadayapalam Srikanth Adayapalam
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: