src/share/classes/java/lang/reflect/Modifier.java
Print this page
*** 24,33 ****
--- 24,34 ----
*/
package java.lang.reflect;
import java.security.AccessController;
+ import java.util.StringJoiner;
import sun.reflect.LangReflectAccess;
import sun.reflect.ReflectionFactory;
/**
* The Modifier class provides {@code static} methods and
*** 230,260 ****
* @param mod a set of modifiers
* @return a string representation of the set of modifiers
* represented by {@code mod}
*/
public static String toString(int mod) {
! StringBuilder sb = new StringBuilder();
! int len;
! if ((mod & PUBLIC) != 0) sb.append("public ");
! if ((mod & PROTECTED) != 0) sb.append("protected ");
! if ((mod & PRIVATE) != 0) sb.append("private ");
/* Canonical order */
! if ((mod & ABSTRACT) != 0) sb.append("abstract ");
! if ((mod & STATIC) != 0) sb.append("static ");
! if ((mod & FINAL) != 0) sb.append("final ");
! if ((mod & TRANSIENT) != 0) sb.append("transient ");
! if ((mod & VOLATILE) != 0) sb.append("volatile ");
! if ((mod & SYNCHRONIZED) != 0) sb.append("synchronized ");
! if ((mod & NATIVE) != 0) sb.append("native ");
! if ((mod & STRICT) != 0) sb.append("strictfp ");
! if ((mod & INTERFACE) != 0) sb.append("interface ");
!
! if ((len = sb.length()) > 0) /* trim trailing space */
! return sb.toString().substring(0, len-1);
! return "";
}
/*
* Access modifier flag constants from tables 4.1, 4.4, 4.5, and 4.7 of
* <cite>The Java™ Virtual Machine Specification</cite>
--- 231,258 ----
* @param mod a set of modifiers
* @return a string representation of the set of modifiers
* represented by {@code mod}
*/
public static String toString(int mod) {
! StringJoiner sj = new StringJoiner(" ");
! if ((mod & PUBLIC) != 0) sj.add("public");
! if ((mod & PROTECTED) != 0) sj.add("protected");
! if ((mod & PRIVATE) != 0) sj.add("private");
/* Canonical order */
! if ((mod & ABSTRACT) != 0) sj.add("abstract");
! if ((mod & STATIC) != 0) sj.add("static");
! if ((mod & FINAL) != 0) sj.add("final");
! if ((mod & TRANSIENT) != 0) sj.add("transient");
! if ((mod & VOLATILE) != 0) sj.add("volatile");
! if ((mod & SYNCHRONIZED) != 0) sj.add("synchronized");
! if ((mod & NATIVE) != 0) sj.add("native");
! if ((mod & STRICT) != 0) sj.add("strictfp");
! if ((mod & INTERFACE) != 0) sj.add("interface");
!
! return sj.toString();
}
/*
* Access modifier flag constants from tables 4.1, 4.4, 4.5, and 4.7 of
* <cite>The Java™ Virtual Machine Specification</cite>