< prev index next >
src/java.base/share/classes/java/lang/Class.java
Print this page
rev 55117 : 8223350: [lworld] Use inline classes instead of value classes
*** 195,207 ****
* this method returns "class " followed by {@code getName}.
*
* @return a string representation of this class object.
*/
public String toString() {
! return (isValue() ? "value " : "")
+ (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
! + getName() + (isValue() && isBoxType() ? "/box" : "");
}
/**
* Returns a string describing this {@code Class}, including
* information about modifiers and type parameters.
--- 195,207 ----
* this method returns "class " followed by {@code getName}.
*
* @return a string representation of this class object.
*/
public String toString() {
! return (isValue() ? "inline " : "")
+ (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
! + getName() + (isValue() && isBoxType() ? "?" : "");
}
/**
* Returns a string describing this {@code Class}, including
* information about modifiers and type parameters.
*** 518,531 ****
*/
public boolean isValue() {
int mods = this.getModifiers();
if ((mods & VALUE_TYPE) != 0) {
if ((mods & (Modifier.INTERFACE | Modifier.ABSTRACT)) != 0) {
! throw new InternalError("value class can't have ACC_INTERFACE or ACC_ABSTRACT set");
}
if (getSuperclass() != Object.class) {
! throw new InternalError("Super class of a value class must be java.lang.Object");
}
return true;
}
return false;
}
--- 518,531 ----
*/
public boolean isValue() {
int mods = this.getModifiers();
if ((mods & VALUE_TYPE) != 0) {
if ((mods & (Modifier.INTERFACE | Modifier.ABSTRACT)) != 0) {
! throw new InternalError("inline class can't have ACC_INTERFACE or ACC_ABSTRACT set");
}
if (getSuperclass() != Object.class) {
! throw new InternalError("Super class of an inline class must be java.lang.Object");
}
return true;
}
return false;
}
*** 635,645 ****
public T newInstance()
throws InstantiationException, IllegalAccessException
{
if (this.isValue()) {
throw new IllegalAccessException(
! "cannot create new instance of value class " + this.getName());
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
--- 635,645 ----
public T newInstance()
throws InstantiationException, IllegalAccessException
{
if (this.isValue()) {
throw new IllegalAccessException(
! "cannot create new instance of an inline class " + this.getName());
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
< prev index next >