-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8254271: Development to deprecate wrapper class constructors for removal #221
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,8 +438,8 @@ private static void initialize() | |
private static void defineEntity( String name, char value ) | ||
{ | ||
if ( _byName.get( name ) == null ) { | ||
_byName.put( name, new Integer( value ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure @JoeWang-Java reviews the XML changes; there are complications in some areas where the master code is upstream of the code in the JDK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JAXP was subsumed by JSR 379 in Java SE 9. |
||
_byChar.put( new Integer( value ), name ); | ||
_byName.put( name, Integer.valueOf( value ) ); | ||
_byChar.put( Integer.valueOf( value ), name ); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have historically not found it necessary to write tests to verify this kind of change and have instead relied on signature testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. FWIW. You have also verified when you get the warnings from JDK build and needs to suppressed it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test can be removed but was a double check that all of the constructors of the named classes had been modified. |
||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
|
||
import org.testng.annotations.Test; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.util.List; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
/* | ||
* @test | ||
* @bug 8252180 | ||
* @summary Test the primitive wrappers constructors are deprecated for removal | ||
* @run testng WrappersTest | ||
*/ | ||
|
||
@Test | ||
public class WrappersTest { | ||
|
||
@Test | ||
void checkForDeprecated() { | ||
List<Class<?>> classes = | ||
List.of(Byte.class, | ||
Short.class, | ||
Integer.class, | ||
Long.class, | ||
Float.class, | ||
Double.class, | ||
Character.class, | ||
Boolean.class); | ||
for (Class<?> cl : classes) { | ||
for (Constructor<?> cons : cl.getConstructors()) { | ||
Deprecated dep = cons.getAnnotation(Deprecated.class); | ||
assertNotNull(dep, "Missing @Deprecated annotation"); | ||
System.out.println(cons + ": " + dep); | ||
assertTrue(dep.forRemoval(), cl.toString() + " deprecated for removal: "); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going to happen to these warning suppressions when we actually remove (make private) the constructors? Is the intent to just defer that problem until it happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the code is changed to not use the constructors, the warning (deprecation and remove) should be removed.
Some of the code is upstream and requires more changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change
MemberName
to call the factory methodByte::valueof
(that's JDK code).For the Graal change, you are touching the code anyway -- I think changing them to use the factory methods would be better than adding "removal" to the suppression. But it may be better to check if these tests intentionally test with the public constructors to test for JIT optimization before applying the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, Mandy replied to the question I should have asked: for all the suppressed "removal" points, what is the plan to fix the offending code? If not now, when? ("Later" may be a reasonable answer, but fleshing out the followup tasks would be helpful.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment in MemberName makes it clear that
hashCode
method may be called before the cache is setup andvalueOf
uses the cache.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its up to the Graal folks to replace their code. In some cases, they are depending on Identity semantics of new Integer().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. Can you file a JBS issue to Graal to make change in its upstream project?