## Description

https://bugs.openjdk.org/browse/JDK-8353840 

### Existing behavior
Log the error message and terminate in case of missing system class

### New behavior
Still log the error message about the missing system class, but continue the 
analysis

## Design choices

Propagate `err` all the way to `NativeMethodFinder` which can log the error to 
it, but continue with the analysis

### Alternatives considered

- Instead of propagating `err` downstream, adapt the outer try-catch in 
`com.sun.tools.jnativescan.Main#run`.
    - Con: This would require complicated error recovery synchronization 
between Main and `JNativeScanTask` to resume the scanning after the exception 
- Instead of adapting the catch block in 
`com.sun.tools.jnativescan.NativeMethodFinder#findAll`, don't even surface the 
exception from 
`com.sun.tools.jnativescan.ClassResolver.SystemModuleClassResolver#lookup` 
rather log it right in `ClassResolver`
    - Con: We don't have access to `MethodRef`/`MethodModel` in 
ClassResolver#lookup which will make the error message less detailed/useful

### stdout vs stderr 

One could argue that since this is a non-terminal error, perhaps it should be 
logged to stdout. However, my thinking was that while it may be non-terminal, 
it is still an "error", and thus should be logged to stderr. I am happy to 
revisit this decision, if needed.

## Testing

The existing test `TestMissingSystemClass#testSingleJarClassPath` has been 
adapted to test for successful execution, as well as verify the stdout output. 
I considered briefly to update the test setup in a way that we see some 
restricted methods on the stdout instead of just `<no restricted methods>`, but 
it was unclear if that would really add any additional value since the main 
purpose of this test is just to ascertain the missing system class (with 
successful execution from now onward).

-------------

Commit messages:
 - 8353840: jnativescan should not throw error for missing system classes

Changes: https://git.openjdk.org/jdk/pull/24499/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24499&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8353840
  Stats: 17 lines in 4 files changed: 6 ins; 1 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/24499.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24499/head:pull/24499

PR: https://git.openjdk.org/jdk/pull/24499

Reply via email to