Skip to content

Commit 858fe8b

Browse files
committed
Deprecate Member magic number for removal
1 parent 4a47011 commit 858fe8b

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,8 @@ public T newInstance()
708708
);
709709
}
710710
try {
711-
Class<?>[] empty = {};
712711
final Constructor<T> c = getReflectionFactory().copyConstructor(
713-
getConstructor0(empty, Member.DECLARED));
712+
getConstructor0(EMPTY_CLASS_ARRAY, false));
714713
// Disable accessibility checks on the constructor
715714
// access check is done with the true caller
716715
c.setAccessible(true);
@@ -2198,7 +2197,7 @@ public Method getMethod(String name, Class<?>... parameterTypes)
21982197
public Constructor<T> getConstructor(Class<?>... parameterTypes)
21992198
throws NoSuchMethodException {
22002199
return getReflectionFactory().copyConstructor(
2201-
getConstructor0(parameterTypes, Member.PUBLIC));
2200+
getConstructor0(parameterTypes, true));
22022201
}
22032202

22042203

@@ -2492,7 +2491,7 @@ Method findMethod(boolean publicOnly, String name, Class<?>... parameterTypes) {
24922491
public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
24932492
throws NoSuchMethodException {
24942493
return getReflectionFactory().copyConstructor(
2495-
getConstructor0(parameterTypes, Member.DECLARED));
2494+
getConstructor0(parameterTypes, false));
24962495
}
24972496

24982497
/**
@@ -3176,10 +3175,10 @@ private PublicMethods.MethodList getMethodsRecursive(String name,
31763175
// be propagated to the outside world, but must instead be copied
31773176
// via ReflectionFactory.copyConstructor.
31783177
private Constructor<T> getConstructor0(Class<?>[] parameterTypes,
3179-
int which) throws NoSuchMethodException
3178+
boolean publicOnly) throws NoSuchMethodException
31803179
{
31813180
ReflectionFactory fact = getReflectionFactory();
3182-
Constructor<T>[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
3181+
Constructor<T>[] constructors = privateGetDeclaredConstructors(publicOnly);
31833182
for (Constructor<T> constructor : constructors) {
31843183
if (arrayContentsEq(parameterTypes,
31853184
fact.getExecutableSharedParameterTypes(constructor))) {

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2026, 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
@@ -44,13 +44,27 @@ public interface Member {
4444
/**
4545
* Identifies the set of all public members of a class or interface,
4646
* including inherited members.
47+
*
48+
* @deprecated
49+
* {@code SecurityManager} originally specified a "{@code checkMemberAccess}"
50+
* method that takes this constant. That method was deprecated in Java SE 8
51+
* and removed in Java SE 11. With no other use, this constant is
52+
* deprecated, for removal.
4753
*/
54+
@Deprecated(forRemoval = true, since = "27")
4855
public static final int PUBLIC = 0;
4956

5057
/**
5158
* Identifies the set of declared members of a class or interface.
5259
* Inherited members are not included.
60+
*
61+
* @deprecated
62+
* {@code SecurityManager} originally specified a "{@code checkMemberAccess}"
63+
* method that takes this constant. That method was deprecated in Java SE 8
64+
* and removed in Java SE 11. With no other use, this constant is
65+
* deprecated, for removal.
5366
*/
67+
@Deprecated(forRemoval = true, since = "27")
5468
public static final int DECLARED = 1;
5569

5670
/**

0 commit comments

Comments
 (0)