8342865: Use type parameter for Class::getPrimitiveClass
Reviewed-by: darcy
This commit is contained in:
parent
9e451aa365
commit
40e07a7ea3
src/java.base/share/classes/java/lang
@ -78,8 +78,7 @@ public final class Boolean implements java.io.Serializable,
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Boolean> TYPE = (Class<Boolean>) Class.getPrimitiveClass("boolean");
|
||||
public static final Class<Boolean> TYPE = Class.getPrimitiveClass("boolean");
|
||||
|
||||
/**
|
||||
* The value of the Boolean.
|
||||
|
@ -79,8 +79,7 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
|
||||
* The {@code Class} instance representing the primitive type
|
||||
* {@code byte}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Byte> TYPE = (Class<Byte>) Class.getPrimitiveClass("byte");
|
||||
public static final Class<Byte> TYPE = Class.getPrimitiveClass("byte");
|
||||
|
||||
/**
|
||||
* Returns a new {@code String} object representing the
|
||||
|
@ -232,8 +232,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Character> TYPE = (Class<Character>) Class.getPrimitiveClass("char");
|
||||
public static final Class<Character> TYPE = Class.getPrimitiveClass("char");
|
||||
|
||||
/*
|
||||
* Normative general types
|
||||
|
@ -3278,10 +3278,10 @@ public final class Class<T> implements java.io.Serializable,
|
||||
private native ProtectionDomain getProtectionDomain0();
|
||||
|
||||
/*
|
||||
* Return the Virtual Machine's Class object for the named
|
||||
* primitive type.
|
||||
* Returns the Class object for the named primitive type. Type parameter T
|
||||
* avoids redundant casts for trusted code.
|
||||
*/
|
||||
static native Class<?> getPrimitiveClass(String name);
|
||||
static native <T> Class<T> getPrimitiveClass(String name);
|
||||
|
||||
/*
|
||||
* Check if client is allowed to access members. If access is denied,
|
||||
|
@ -459,8 +459,7 @@ public final class Double extends Number
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
|
||||
public static final Class<Double> TYPE = Class.getPrimitiveClass("double");
|
||||
|
||||
/**
|
||||
* Returns a string representation of the {@code double}
|
||||
|
@ -175,8 +175,7 @@ public final class Float extends Number
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Float> TYPE = (Class<Float>) Class.getPrimitiveClass("float");
|
||||
public static final Class<Float> TYPE = Class.getPrimitiveClass("float");
|
||||
|
||||
/**
|
||||
* Returns a string representation of the {@code float}
|
||||
|
@ -95,8 +95,7 @@ public final class Integer extends Number
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");
|
||||
public static final Class<Integer> TYPE = Class.getPrimitiveClass("int");
|
||||
|
||||
/**
|
||||
* All possible chars for representing a number as a String
|
||||
|
@ -95,8 +95,7 @@ public final class Long extends Number
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Long> TYPE = (Class<Long>) Class.getPrimitiveClass("long");
|
||||
public static final Class<Long> TYPE = Class.getPrimitiveClass("long");
|
||||
|
||||
/**
|
||||
* Returns a string representation of the first argument in the
|
||||
|
@ -79,8 +79,7 @@ public final class Short extends Number implements Comparable<Short>, Constable
|
||||
* The {@code Class} instance representing the primitive type
|
||||
* {@code short}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Short> TYPE = (Class<Short>) Class.getPrimitiveClass("short");
|
||||
public static final Class<Short> TYPE = Class.getPrimitiveClass("short");
|
||||
|
||||
/**
|
||||
* Returns a new {@code String} object representing the
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2024, 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
|
||||
@ -39,8 +39,7 @@ class Void {
|
||||
* The {@code Class} object representing the pseudo-type corresponding to
|
||||
* the keyword {@code void}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final Class<Void> TYPE = (Class<Void>) Class.getPrimitiveClass("void");
|
||||
public static final Class<Void> TYPE = Class.getPrimitiveClass("void");
|
||||
|
||||
/*
|
||||
* The Void class cannot be instantiated.
|
||||
|
Loading…
x
Reference in New Issue
Block a user