JDK-8242606 : Cannot compile a ContentSigner implementation with "-release 8"
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 15
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2020-04-14
  • Updated: 2020-05-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
com.sun.jarsigner.ContentSigner is a JDK specific API that existed in JDK 8. It used to be in tools.jar. It is currently in the jdk.jartool module (com.sun.jarsigner is an exported package). It's not currently possible to compile code using ContentSigner with --release 8.

How to reproduce:

c $ cat X.java
import com.sun.jarsigner.*;
public class X extends ContentSigner {
    @Override
    public byte[] generateSignedData(ContentSignerParameters parameters,
            boolean omitContent, boolean applyTimestamp) {
        return "1234".getBytes();
    }
}
c $ javac --release 8 X.java
X.java:2: error: cannot find symbol
public class X extends ContentSigner {
                       ^
  symbol: class ContentSigner
X.java:4: error: cannot find symbol
    public byte[] generateSignedData(ContentSignerParameters parameters,
                                     ^
  symbol:   class ContentSignerParameters
  location: class X
X.java:1: error: package com.sun.jarsigner does not exist
import com.sun.jarsigner.*;
^
X.java:3: error: method does not override or implement a method from a supertype
    @Override
    ^
4 errors

Comments
As Joe noted only classes accessible by javac without any special path-based parameters are used. For JDK <= 8, that does not include tools.jar (as that has to be added with -classpath <tools.jar>), for JDK >= 9, that means basically all modules.
20-04-2020

Per JEP 247 (JDK-8058150), " --release N is roughly equivalent to: * for N < 9: -source N -target N -bootclasspath <documented-APIs-from-N>," As tools.jar is not on the bootclasspath of JDK 8, the feature is worked as intended.
14-04-2020