JDK 9 RFR of JDK-8071959: java.lang.Object uses implicit default constructor

Peter Levart peter.levart at gmail.com
Fri Jan 30 14:52:13 UTC 2015


On 01/30/2015 01:02 AM, joe darcy wrote:
> Hello,
>
> Please review the patch below to fix
>
>     JDK-8071959: java.lang.Object uses implicit default constructor
>
> diff -r 458adf31ad5b src/java.base/share/classes/java/lang/Object.java
> --- a/src/java.base/share/classes/java/lang/Object.java    Thu Jan 29 
> 15:14:44 2015 -0800
> +++ b/src/java.base/share/classes/java/lang/Object.java    Thu Jan 29 
> 16:00:03 2015 -0800
> @@ -42,6 +42,11 @@
>      }
>
>      /**
> +     * Constructs a new object.
> +     */
> +    public Object() {}
> +
> +    /**
>       * Returns the runtime class of this {@code Object}. The returned
>       * {@code Class} object is the object that is locked by {@code
>       * static synchronized} methods of the represented class.
>
> At present, java.lang.Object relies on the default constructor 
> generated by javac; how embarrassing!
>
> Thanks,
>
> -Joe

Is javac able to compile it correctly? It never had to do that before 
(it inserted an implicit one instead). I guess the constructor in Object 
is special, since it does not call a super constructor.

Peter




More information about the core-libs-dev mailing list