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

javac to check Profile attribute on jars on classpath

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • None
    • tools
    • None
    • 8

      A developer targeting a compact profile, (e.g. compact1), as the minimal JRE for an application would compile classes with the "-profile compact1" option. If the source code references any classes not in compact1, an error is generated, even if the code is written in such a way that the class may not need to be loaded at runtime. If the reference is not made by mistake, but perhaps under reflection guard to provide optional functionality depending on the runtime environment, the developer must compile code containing such references without the -profile option (or specifying a higher profile).

      However, if the developer references a class from a jar file on the classpath, having a Profile attribute requiring a higher profile, then no errors/warnings are generated. As in the case of referencing an API class outside the target profile, this is either an error, or the developer needs to use similar techniques (reflection guard), to avoid opening the jar-file at runtime, unless the actual runtime environment meets the jar-file's profile requirement.

      It's the SQE opinion that the situations are similar enough, that they should be handled the same. That is, it's suggested that the compiler should verify the Profile attributes of jar files on the classpath against the value of the -profile option.



            jjg Jonathan Gibbons
            strarup Peter Jensen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: