Recommended strategy

Let's wrap up by outlining the recommended strategy for compiling and running your legacy code in Java 9. Here are the steps you'd ideally follow:

  1. Run jdeps --jdk-internals to verify if your code has any internal API access. If there are no errors, just try compiling and running your code in Java 9. For the vast majority of cases, where there are no accesses to internal JDK APIs, the code should simply just work.
  2. If there are errors and they are caused by your application code that you can change, follow the jdeps recommendation and fix those errors.
  3. If the errors are caused by libraries that are not in your control, check if there are updates published by the library authors and get the latest versions. Many libraries that use internal APIs are being updated to work with Java 9, and the fix for your libraries might have already been done and published.
  4. If none of the previous steps work, consider using the override options  --add-exports or  --add-opens to the platform APIs that you need internal access to. This is a short-term stop-gap arrangement until the offending code or library is fixed.
  1. If none of these work, as a last resort, turn off all modularity features with the --permit-illegal-access kill switch. While it is not recommended (and you certainly don't want to deploy an app with this switch in production), it's a handy way to get started if you are being overwhelmed with compatibility issues. A cool feature of this switch is that when you run your code that makes any illegal access, it prints out a warning message. It can be very helpful to consolidate this information and plan to fix them later.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.151.45