Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java
41161 views
/*1* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324package sun.jvm.hotspot.oops;2526import sun.jvm.hotspot.runtime.ClassConstants;27import java.io.*;2829public class AccessFlags implements /* imports */ ClassConstants {30public AccessFlags(long flags) {31this.flags = flags;32}3334private long flags;3536// Java access flags37public boolean isPublic () { return (flags & JVM_ACC_PUBLIC ) != 0; }38public boolean isPrivate () { return (flags & JVM_ACC_PRIVATE ) != 0; }39public boolean isProtected () { return (flags & JVM_ACC_PROTECTED ) != 0; }40public boolean isStatic () { return (flags & JVM_ACC_STATIC ) != 0; }41public boolean isFinal () { return (flags & JVM_ACC_FINAL ) != 0; }42public boolean isSynchronized() { return (flags & JVM_ACC_SYNCHRONIZED) != 0; }43public boolean isSuper () { return (flags & JVM_ACC_SUPER ) != 0; }44public boolean isVolatile () { return (flags & JVM_ACC_VOLATILE ) != 0; }45public boolean isBridge () { return (flags & JVM_ACC_BRIDGE ) != 0; }46public boolean isTransient () { return (flags & JVM_ACC_TRANSIENT ) != 0; }47public boolean isVarArgs () { return (flags & JVM_ACC_VARARGS ) != 0; }48public boolean isNative () { return (flags & JVM_ACC_NATIVE ) != 0; }49public boolean isEnum () { return (flags & JVM_ACC_ENUM ) != 0; }50public boolean isAnnotation () { return (flags & JVM_ACC_ANNOTATION ) != 0; }51public boolean isInterface () { return (flags & JVM_ACC_INTERFACE ) != 0; }52public boolean isAbstract () { return (flags & JVM_ACC_ABSTRACT ) != 0; }53public boolean isStrict () { return (flags & JVM_ACC_STRICT ) != 0; }54public boolean isSynthetic () { return (flags & JVM_ACC_SYNTHETIC ) != 0; }5556public long getValue () { return flags; }5758// Hotspot internal flags59// Method* flags60public boolean isMonitorMatching () { return (flags & JVM_ACC_MONITOR_MATCH ) != 0; }61public boolean hasMonitorBytecodes () { return (flags & JVM_ACC_HAS_MONITOR_BYTECODES ) != 0; }62public boolean hasLoops () { return (flags & JVM_ACC_HAS_LOOPS ) != 0; }63public boolean loopsFlagInit () { return (flags & JVM_ACC_LOOPS_FLAG_INIT ) != 0; }64public boolean queuedForCompilation() { return (flags & JVM_ACC_QUEUED ) != 0; }65public boolean isNotOsrCompilable () { return (flags & JVM_ACC_NOT_OSR_COMPILABLE ) != 0; }66public boolean hasLineNumberTable () { return (flags & JVM_ACC_HAS_LINE_NUMBER_TABLE ) != 0; }67public boolean hasCheckedExceptions() { return (flags & JVM_ACC_HAS_CHECKED_EXCEPTIONS ) != 0; }68public boolean hasJsrs () { return (flags & JVM_ACC_HAS_JSRS ) != 0; }69public boolean isObsolete () { return (flags & JVM_ACC_IS_OBSOLETE ) != 0; }7071// Klass* flags72public boolean hasMirandaMethods () { return (flags & JVM_ACC_HAS_MIRANDA_METHODS ) != 0; }73public boolean hasVanillaConstructor() { return (flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; }74public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 0; }75public boolean isCloneable () { return (flags & JVM_ACC_IS_CLONEABLE ) != 0; }7677// Klass* and Method* flags78public boolean hasLocalVariableTable() { return (flags & JVM_ACC_HAS_LOCAL_VARIABLE_TABLE ) != 0; }7980// field flags81public boolean fieldAccessWatched () { return (flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }82public boolean fieldModificationWatched() { return (flags & JVM_ACC_FIELD_MODIFICATION_WATCHED) != 0; }83public boolean fieldHasGenericSignature() { return (flags & JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE)!= 0; }8485public void printOn(PrintStream tty) {86// prints only .class flags and not the hotspot internal flags87if (isPublic ()) tty.print("public " );88if (isPrivate ()) tty.print("private " );89if (isProtected ()) tty.print("protected " );90if (isStatic ()) tty.print("static " );91if (isFinal ()) tty.print("final " );92if (isSynchronized()) tty.print("synchronized ");93if (isVolatile ()) tty.print("volatile " );94if (isBridge ()) tty.print("bridge " );95if (isTransient ()) tty.print("transient " );96if (isVarArgs ()) tty.print("varargs " );97if (isNative ()) tty.print("native " );98if (isEnum ()) tty.print("enum " );99if (isInterface ()) tty.print("interface " );100if (isAbstract ()) tty.print("abstract " );101if (isStrict ()) tty.print("strict " );102if (isSynthetic ()) tty.print("synthetic " );103}104105// get flags written to .class files106public int getStandardFlags() {107return (int) (flags & JVM_ACC_WRITTEN_FLAGS);108}109}110111112