[
https://issues.apache.org/jira/browse/DERBY-6856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15990011#comment-15990011
]
Rick Hillegas commented on DERBY-6856:
--------------------------------------
When I compile Derby using JDK 9 build 167, I see several instances of the
following warning:
warning: [deprecation] finalize() in Object has been deprecated
on
java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
java/drda/org/apache/derby/impl/drda/ReEncodedInputStream.java
java/client/org/apache/derby/client/ClientPooledConnection.java
java/client/org/apache/derby/client/am/ClientConnection.java
java/client/org/apache/derby/client/am/LogicalConnection.java
java/client/org/apache/derby/client/am/ClientStatement.java
java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
The following deprecation summary now appears in the javadoc for
java.lang.Object.finalize():
"Deprecated. The finalization mechanism is inherently problematic. Finalization
can lead to performance issues, deadlocks, and hangs. Errors in finalizers can
lead to resource leaks; there is no way to cancel finalization if it is no
longer necessary; and no ordering is specified among calls to finalize methods
of different objects. Furthermore, there are no guarantees regarding the timing
of finalization. The finalize method might be called on a finalizable object
only after an indefinite delay, if at all. Classes whose instances hold
non-heap resources should provide a method to enable explicit release of those
resources, and they should also implement AutoCloseable if appropriate. The
Cleaner and PhantomReference provide more flexible and efficient ways to
release resources when an object becomes unreachable."
Most of these classes do implement AutoCloseable. We should investigate hooking
these classes up to the new Cleaner-based mechanism for object rundown. I will
need advice from the experts about how to proceed. I would be grateful for any
advice from the community about how to use this new Cleaner class.
I am worried that migrating this delicate logic may give rise to heisenbugs
which our release processes will not discover. We may want to merely suppress
this warning for our first JDK9-built release. We can always migrate to
Cleaner-based finalization after the wider Java eco-system has developed best
practices around using the Cleaner class.
> Make it possible to build Derby using JDK 9
> -------------------------------------------
>
> Key: DERBY-6856
> URL: https://issues.apache.org/jira/browse/DERBY-6856
> Project: Derby
> Issue Type: Improvement
> Components: Build tools
> Affects Versions: 10.12.1.1
> Reporter: Rick Hillegas
> Attachments: derby-6856-01-ab-addShardingKey.diff,
> derby-6856-01-ac-cleanup.diff, derby-6856-02-aa-addShardingKey.diff,
> derby-6856-03-aa-autoboxingDeprecationWarnings.diff,
> derby-6856-03-ab-autoboxingDeprecationWarnings.diff,
> derby-6856-04-aa-autoboxingDeprecationWarnings-part2.diff,
> derby-6856-04-ab-autoboxingDeprecationWarnings-part2.diff,
> derby-6856-05-ac-roundingMode-Class.newInstance.diff,
> derby-6856-05-af-roundingMode-Class.getDeclaredConstructor.diff,
> derby-6856-05-ag-roundingMode-Class.newInstance.diff,
> derby-6856-06-aa-observable.diff, derby-6856-07-aa-oneMoreNewInstance.diff,
> derby-6856-08-aa-cleanupJavadoc.diff, derby-6856-09-aa-javadocEntities.diff,
> derby-6856-10-aa-disable-permissions-subverting-test.diff,
> derby-6856-11-aa-jigsawResourceLocation.diff, derby-6856-XX-ab-base.diff,
> derby-6856-XX-ac-base.diff, derby-6856-XX-ad-base.diff,
> derby-6856-XX-ae-base.diff, PTest.java, ptestScript
>
>
> Derby can't be built with JDK 9. Java 9 introduces new JDBC classes like
> java.sql.ShardingKey and methods which refer to these new classes.
> In addition, project Jigsaw has created a new way to name classes (see
> http://openjdk.java.net/jeps/220). This breaks the PropertySetter build tool
> which we use so that old JVMs can compile Derby and so that Derby can be
> compiled to run on old JVMs.
> It is likely that we will need to leave this issue open throughout the
> development cycle of Java 9.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)