JDK 10 RFR JDK-8177153: LambdaMetafactory has default constructor
Hi. Please review this trivial fix: ------- diff -r 83d37efcd2a5 src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java --- a/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Thu Apr 13 20:35:17 2017 +0000 +++ b/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Fri Apr 28 17:51:42 2017 +0000 @@ -213,7 +213,8 @@ * methods. * @since 1.8 */ -public class LambdaMetafactory { +public final class LambdaMetafactory { + private LambdaMetafactory() {} /** Flag for alternate metafactories indicating the lambda object * must be serializable */ ------- Ron
Hi, This will require that we submit a CSR, when this opens up. (Sorry, i should of realised when suggesting easy bugs.) Still, i think this change is ok, grepcode.com <http://grepcode.com/> shows no subtypes, and there are only static methods. So i think we can pursue this once the CSR is ready. Paul.
On 28 Apr 2017, at 12:28, Ron Pressler <ron.pressler@oracle.com> wrote:
Hi. Please review this trivial fix:
------- diff -r 83d37efcd2a5 src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java --- a/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Thu Apr 13 20:35:17 2017 +0000 +++ b/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Fri Apr 28 17:51:42 2017 +0000 @@ -213,7 +213,8 @@ * methods. * @since 1.8 */ -public class LambdaMetafactory { +public final class LambdaMetafactory { + private LambdaMetafactory() {}
/** Flag for alternate metafactories indicating the lambda object * must be serializable */ -------
Ron
Hello, As this is a binary incompatible change, effectively removing a public constructor, I'd prefer if this change got into JDK 9 instead, pending the review process of course. (I've thought it would be worthwhile to audit the JDK for default constructors and/or add a javac lint warning for that situation, but I haven't done that, yet.) Thanks, -Joe On 4/28/2017 12:53 PM, Paul Sandoz wrote:
Hi,
This will require that we submit a CSR, when this opens up. (Sorry, i should of realised when suggesting easy bugs.)
Still, i think this change is ok, grepcode.com <http://grepcode.com/> shows no subtypes, and there are only static methods.
So i think we can pursue this once the CSR is ready.
Paul.
On 28 Apr 2017, at 12:28, Ron Pressler <ron.pressler@oracle.com> wrote:
Hi. Please review this trivial fix:
------- diff -r 83d37efcd2a5 src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java --- a/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Thu Apr 13 20:35:17 2017 +0000 +++ b/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java Fri Apr 28 17:51:42 2017 +0000 @@ -213,7 +213,8 @@ * methods. * @since 1.8 */ -public class LambdaMetafactory { +public final class LambdaMetafactory { + private LambdaMetafactory() {}
/** Flag for alternate metafactories indicating the lambda object * must be serializable */ -------
Ron
On 28 Apr 2017, at 14:10, joe darcy <joe.darcy@oracle.com> wrote:
Hello,
As this is a binary incompatible change, effectively removing a public constructor, I'd prefer if this change got into JDK 9 instead, pending the review process of course.
Fair point, the earlier the better in that regard.
(I've thought it would be worthwhile to audit the JDK for default constructors and/or add a javac lint warning for that situation, but I haven't done that, yet.)
If we used something like error prone (perhaps with integration into javac) i presume this would be rather easy to do. Paul.
http://errorprone.info/bugpattern/PrivateConstructorForUtilityClass On Fri, Apr 28, 2017 at 2:19 PM, Paul Sandoz <paul.sandoz@oracle.com> wrote:
On 28 Apr 2017, at 14:10, joe darcy <joe.darcy@oracle.com> wrote:
Hello,
As this is a binary incompatible change, effectively removing a public constructor, I'd prefer if this change got into JDK 9 instead, pending the review process of course.
Fair point, the earlier the better in that regard.
(I've thought it would be worthwhile to audit the JDK for default constructors and/or add a javac lint warning for that situation, but I haven't done that, yet.)
If we used something like error prone (perhaps with integration into javac) i presume this would be rather easy to do.
Paul.
[cc'ing some errorprone folk ...] On Fri, Apr 28, 2017 at 2:22 PM, Martin Buchholz <martinrb@google.com> wrote:
http://errorprone.info/bugpattern/PrivateConstructorForUtilityClass
It's highly non-obvious how to run errorprone against recent jdk sources. You need a prerelease of errorprone, add a module to get javax.annotation, and add a bunch of flags to allow access to javac internals. The script below finds 430 PrivateConstructorForUtilityClass warnings in openjdk10: #!/bin/bash declare -r JDK9="$HOME/jdk/jdk9" declare -r JDK_SRC="$HOME/ws/jdk10" declare -r BUG_PATTERN="PrivateConstructorForUtilityClass" declare -r ERRORPRONE_JAR_URL=" https://oss.sonatype.org/content/repositories/snapshots/com/google/errorpron... " set -eu declare -r ERRORPRONE_JAR="/tmp/${0##*/}.jar" declare -r LOGFILE="/tmp/${0##*/}.log" declare -ar JAVA_FLAGS_JAVAC=( -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 --add-modules=java.xml.ws.annotation --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED ) declare -ar JAVAC_WARNINGS=( -Xmaxwarns 999999 -processorpath "$ERRORPRONE_JAR" "'-Xplugin:ErrorProne -XepDisableAllChecks -Xep:${BUG_PATTERN}:WARN'" ) ( cd "$JDK_SRC" wget -qO"$ERRORPRONE_JAR" "$ERRORPRONE_JAR_URL" bash ./configure --with-boot-jdk="$JDK9" --disable-sjavac --disable-javac-server make clean make \ JAVA_FLAGS_JAVAC="${JAVA_FLAGS_JAVAC[*]}" \ JAVAC_WARNINGS="${JAVAC_WARNINGS[*]}" \ images ) |& tee "$LOGFILE" | grep -A1 "warning:..${BUG_PATTERN}"
participants (4)
-
joe darcy
-
Martin Buchholz
-
Paul Sandoz
-
Ron Pressler