Skip to content

Use ct.sym to isolate sigtest from underlaying JDK #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 13, 2021
Merged

Conversation

jtulach
Copy link
Owner

@jtulach jtulach commented Apr 10, 2021

Many projects observed problems executing SigTest when switching the version of JDK the test is performed on. As soon as the JDK changes, the API of base Java classes changes as well. SigTest may then detect transitive changes even the actual API hasn't changed at all. As #2 PR indicates we need a solution to this problem.

Let's use the ct.sym approach (as pioneered by javac in JDK9). E.g. specify the release of JDK API to compare against. Then it wouldn't matter which JDK is used for running the check. - the JDK API used in the check would always be fixed to the specified release version.

This PR enhances the -BootCP command line argument to understand an optional parameter. Use -BootCp 8 to select JDK8's API as the base. Use -BootCP 15 to select JDK 15's API. Use -BootCp without parameter to select the API of the underlaying JDK SigTest runs on (the original behavior). The PR reuses existing -BootCp functionality and enhances it rather than inventing new option - at the end only one occurence of -BootCp <with or without number> makes sense.

Both Ant and Maven integrations were enhanced to provide new release attribute (trying to mimic the name of attribute of Ant JavacTask and Maven compiler plugin) - if specified, it uses the -BootCp number parameter when calling into the SigTest.

Documentation has been updated and a test verifying addition of CharSequence.isEmpty() in JDK15 is properly detected has been added.

@jtulach
Copy link
Owner Author

jtulach commented Apr 11, 2021

Bits with this change have just been staged at maven.java.net repository. They can be released with a single click.

@scottmarlow
Copy link

scottmarlow commented Apr 12, 2021

Updated: I'm trying this out locally with OpenJDK11-BootCp 8. From the below failure It looks like the test is seeing the JDK 11 java.lang.Deprecated instead of JDK 8.

[javatest.batch] ^[[0m^[[0m10:40:22,717 INFO  [org.jboss.as.server] (Thread-45) WFLYSRV0010: Deployed "JavaEESigTest_appclient_vehicle.ear" (runtime-name : "JavaEESigTest_appclient_vehicle.ear")
[javatest.batch] ^[[0m^[[0m10:40:22,728 INFO  [stdout] (Thread-192) ************************************************************
[javatest.batch] ^[[0m^[[0m10:40:22,728 INFO  [stdout] (Thread-192) * props file set to "/tmp/smarlow-cts-props.txt"
[javatest.batch] ^[[0m^[[0m10:40:22,728 INFO  [stdout] (Thread-192) ************************************************************
[javatest.batch] ^[[0m^[[0m10:40:22,735 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  $$$ SigTestEE.setup() called
[javatest.batch] ^[[0m^[[0m10:40:22,735 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  $$$ SigTestEE.setup() complete
[javatest.batch] ^[[0m^[[0m10:40:22,735 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  $$$ SigTestEE.signatureTest() called
[javatest.batch] ^[[0m^[[0m10:40:22,738 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  Using the following as the sig-Test map file: sig-test_se8.map
[javatest.batch] ^[[0m^[[0m10:40:22,758 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  Using the following as the SigTest Package file: sig-test-pkg-list_se8.txt
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  optionalPkgToIgnore = jakarta.xml.bind
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  ********** BEGIN PACKAGE LEVEL SIGNATURE VALIDATION **********
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  ********** BEGIN VALIDATE PACKAGE 'jakarta.mail.event' **********
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  ********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****
[javatest.batch] ^[[0m^[[0m10:40:22,760 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  Static mode supports checks of static constants values
[javatest.batch] ^[[0m^[[0m10:40:22,947 INFO  [stdout] (Thread-192) null
[javatest.batch] ^[[0m^[[0m10:40:22,947 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  ********** Status Report 'jakarta.mail.event' **********
[javatest.batch] ^[[0m^[[0m10:40:22,947 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) 04-12-2021 10:40:22:  SignatureTest report
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Base version: 1.0
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Tested version: 2.0_se8
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Check mode: src [throws normalized]
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Constant checking: on
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Warning: incorrect classpath parameter:  ( (No such file or directory)). This directory or jar file will be ignored!
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Warning: incorrect classpath parameter: /home/smarlow/jdk-11.0.10+9/lib/rt.jar (/home/smarlow/jdk-11.0.10+9/lib/rt.jar). This directory or jar file will be ignored!
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) Added Annotations
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) -----------------
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192)
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,948 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] ^[[0m^[[0m10:40:22,949 INFO  [stdout] (Thread-192)

I'm debugging in com.sun.tdk.signaturetest.SignatureTest#checkAnnotations and see that base variable value == method protected void java.lang.Object.finalize() throws java.lang.Throwable and test variable value == method protected void java.lang.Object.finalize() throws java.lang.Throwable anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9").

It looks like the test variable classloader is the EE application client container classloader test.getClass().getClassLoader() = ModuleClassLoader for Module "deployment.JavaEESigTest_appclient_vehicle.ear" from Service Module Loaderwhich doesn't seem to be helped by the change to usect sym`.

https://gist.github.com/scottmarlow/ca37ce901129556877215e5c528cb8a1 shows the call stack into com.sun.tdk.signaturetest.SignatureTest#checkAnnotations when the first Added Annotations failure occurs.

@scottmarlow
Copy link

Hmm, I didn't try running with -BootCp 11, will try that as well.

@jtulach
Copy link
Owner Author

jtulach commented Apr 12, 2021

boolean forRemoval=false, java.lang.String since="9" are default values of the enhanced @Deprecated annotation since JDK9. The tool now sees all the changes up to JDK15. The tool also sees that finalize have been deprecated in JDK9. Overall such forward deprecation warnings are helpful, but I understand they may feel a bit unexpected at first sight.

@scottmarlow
Copy link

The warning that I mentioned is followed by a failure about the @deprecated, sorry for leaving that out.

I get the same warnings and error with -BootCP 11:

[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) Added Annotations
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) -----------------
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) java.lang.Object.finalize:              anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9")
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:21,262 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:21,302 INFO  [stdout] (Thread-148) 04-12-2021 15:37:21:  SVR: ********** Package 'jakarta.resource.spi.security' - FAILED (STATIC MODE) **********

I only had included the first one before. I also see other ones that #2 did deal with. like:

[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) Missed Annotations
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) ------------------
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) jakarta.annotation.Resource:            anno 0 java.lang.annotation.Repeatable(java.lang.Class<? extends java.lang.annotation.Annotation> value=class jakarta.annotation.Resources)
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) Added Annotations
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) -----------------
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) jakarta.annotation.Resource:            anno 0 java.lang.annotation.Repeatable(java.lang.Class<? extends java.lang.annotation.Annotation> value=interface jakarta.annotation.Resources)
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 
[javatest.batch] �[0m�[0m15:37:22,443 INFO  [stdout] (Thread-148) 04-12-2021 15:37:22:  SVR: ********** Package 'jakarta.annotation' - FAILED (REFLECTION MODE) **********

@scottmarlow
Copy link

scottmarlow commented Apr 12, 2021

https://github.com/jtulach/netbeans-apitest/pull/2/files#diff-2e7f4c9b2c847f4809b73ae0053643bd23b20990b876f902133ebc08185d2586R1449 shows how #2 dealt with the @deprecated failure. I wonder if any parts of #2 could help with the failures I see with #3

More specifically, if the annotation class can be loaded by Release#findClass(name) then the annotation class is likely a JDK class and if we can detect that condition, then we could ignore the signature for doing comparisons in case the jdk signature is updated in a later JDK.

Or maybe the -IgnoreJDKClass could just be used to complement the #3 change.

@jtulach jtulach force-pushed the CtSym branch 2 times, most recently from 2869360 to 26a4152 Compare April 13, 2021 03:45
@jtulach
Copy link
Owner Author

jtulach commented Apr 13, 2021

New bits staged at 1099 repository.

@jtulach jtulach merged commit e8e3ef8 into master Apr 13, 2021
@scottmarlow
Copy link

👍

@jtulach
Copy link
Owner Author

jtulach commented Apr 13, 2021

Part of 1.4 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants