Skip to content

Commit 10f1f10

Browse files
committed
8230723: Remove default constructors from java.lang and java.io
Reviewed-by: bpb, rriggs
1 parent c84e19f commit 10f1f10

File tree

10 files changed

+54
-4
lines changed

10 files changed

+54
-4
lines changed

src/java.base/share/classes/java/io/InputStream.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public abstract class InputStream implements Closeable {
5555

5656
private static final int DEFAULT_BUFFER_SIZE = 8192;
5757

58+
/**
59+
* Constructor for subclasses to call.
60+
*/
61+
public InputStream() {}
62+
5863
/**
5964
* Returns a new {@code InputStream} that reads no bytes. The returned
6065
* stream is initially open. The stream is closed by calling the

src/java.base/share/classes/java/io/ObjectInputStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,10 @@ private void checkArray(Class<?> arrayType, int arrayLength) throws InvalidClass
13211321
* Provide access to the persistent fields read from the input stream.
13221322
*/
13231323
public abstract static class GetField {
1324+
/**
1325+
* Constructor for subclasses to call.
1326+
*/
1327+
public GetField() {}
13241328

13251329
/**
13261330
* Get the ObjectStreamClass that describes the fields in the stream.

src/java.base/share/classes/java/io/ObjectOutputStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ public void writeUTF(String str) throws IOException {
879879
* @since 1.2
880880
*/
881881
public abstract static class PutField {
882+
/**
883+
* Constructor for subclasses to call.
884+
*/
885+
public PutField() {}
882886

883887
/**
884888
* Put the value of the named boolean field into the persistent field.

src/java.base/share/classes/java/io/OutputStream.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,11 @@
4646
* @since 1.0
4747
*/
4848
public abstract class OutputStream implements Closeable, Flushable {
49+
/**
50+
* Constructor for subclasses to call.
51+
*/
52+
public OutputStream() {}
53+
4954
/**
5055
* Returns a new {@code OutputStream} which discards all bytes. The
5156
* returned stream is initially open. The stream is closed by calling

src/java.base/share/classes/java/lang/InheritableThreadLocal.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,11 @@
5151
*/
5252

5353
public class InheritableThreadLocal<T> extends ThreadLocal<T> {
54+
/**
55+
* Creates an inheritable thread local variable.
56+
*/
57+
public InheritableThreadLocal() {}
58+
5459
/**
5560
* Computes the child's initial value for this inheritable thread-local
5661
* variable as a function of the parent's value at the time the child

src/java.base/share/classes/java/lang/LiveStackFrame.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ interface LiveStackFrame extends StackFrame {
115115
* of primitive type.
116116
*/
117117
public abstract class PrimitiveSlot {
118+
/**
119+
* Constructor.
120+
*/
121+
PrimitiveSlot() {}
122+
118123
/**
119124
* Returns the size, in bytes, of the slot.
120125
*/

src/java.base/share/classes/java/lang/ThreadDeath.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@
4949
public class ThreadDeath extends Error {
5050
@java.io.Serial
5151
private static final long serialVersionUID = -4417128565033088268L;
52+
53+
/**
54+
* Constructs a {@code ThreadDeath}.
55+
*/
56+
public ThreadDeath() {}
5257
}

src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -458,6 +458,11 @@ protected K topSpeciesKey() {
458458
* Subclasses can modify the behavior.
459459
*/
460460
public class Factory {
461+
/**
462+
* Constructs a factory.
463+
*/
464+
Factory() {}
465+
461466
/**
462467
* Get a concrete subclass of the top class for a given combination of bound types.
463468
*

src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,12 @@
4040
* @since 11
4141
*/
4242
public final class ConstantBootstraps {
43+
/**
44+
* Do not call.
45+
*/
46+
@Deprecated(forRemoval=true, since="14")
47+
public ConstantBootstraps() {}
48+
4349
// implements the upcall from the JVM, MethodHandleNatives.linkDynamicConstant:
4450
/*non-public*/
4551
static Object makeConstant(MethodHandle bootstrapMethod,

src/java.base/share/classes/java/lang/reflect/Modifier.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
* @since 1.1
4444
*/
4545
public class Modifier {
46+
/**
47+
* Do not call.
48+
*/
49+
@Deprecated(forRemoval=true, since="14")
50+
public Modifier() {}
51+
4652

4753
/**
4854
* Return {@code true} if the integer argument includes the

0 commit comments

Comments
 (0)