0
|
1 /*
|
|
2 * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 package sun.jvm.hotspot.oops;
|
|
26
|
|
27 import sun.jvm.hotspot.runtime.ClassConstants;
|
|
28 import java.io.*;
|
|
29
|
|
30 public class AccessFlags implements /* imports */ ClassConstants {
|
|
31 public AccessFlags(long flags) {
|
|
32 this.flags = flags;
|
|
33 }
|
|
34
|
|
35 private long flags;
|
|
36
|
|
37 // Java access flags
|
|
38 public boolean isPublic () { return (flags & JVM_ACC_PUBLIC ) != 0; }
|
|
39 public boolean isPrivate () { return (flags & JVM_ACC_PRIVATE ) != 0; }
|
|
40 public boolean isProtected () { return (flags & JVM_ACC_PROTECTED ) != 0; }
|
|
41 public boolean isStatic () { return (flags & JVM_ACC_STATIC ) != 0; }
|
|
42 public boolean isFinal () { return (flags & JVM_ACC_FINAL ) != 0; }
|
|
43 public boolean isSynchronized() { return (flags & JVM_ACC_SYNCHRONIZED) != 0; }
|
|
44 public boolean isSuper () { return (flags & JVM_ACC_SUPER ) != 0; }
|
|
45 public boolean isVolatile () { return (flags & JVM_ACC_VOLATILE ) != 0; }
|
|
46 public boolean isBridge () { return (flags & JVM_ACC_BRIDGE ) != 0; }
|
|
47 public boolean isTransient () { return (flags & JVM_ACC_TRANSIENT ) != 0; }
|
|
48 public boolean isVarArgs () { return (flags & JVM_ACC_VARARGS ) != 0; }
|
|
49 public boolean isNative () { return (flags & JVM_ACC_NATIVE ) != 0; }
|
|
50 public boolean isEnum () { return (flags & JVM_ACC_ENUM ) != 0; }
|
|
51 public boolean isAnnotation () { return (flags & JVM_ACC_ANNOTATION ) != 0; }
|
|
52 public boolean isInterface () { return (flags & JVM_ACC_INTERFACE ) != 0; }
|
|
53 public boolean isAbstract () { return (flags & JVM_ACC_ABSTRACT ) != 0; }
|
|
54 public boolean isStrict () { return (flags & JVM_ACC_STRICT ) != 0; }
|
|
55 public boolean isSynthetic () { return (flags & JVM_ACC_SYNTHETIC ) != 0; }
|
|
56
|
|
57 public long getValue () { return flags; }
|
|
58
|
|
59 // Hotspot internal flags
|
|
60 // methodOop flags
|
|
61 public boolean isMonitorMatching () { return (flags & JVM_ACC_MONITOR_MATCH ) != 0; }
|
|
62 public boolean hasMonitorBytecodes () { return (flags & JVM_ACC_HAS_MONITOR_BYTECODES ) != 0; }
|
|
63 public boolean hasLoops () { return (flags & JVM_ACC_HAS_LOOPS ) != 0; }
|
|
64 public boolean loopsFlagInit () { return (flags & JVM_ACC_LOOPS_FLAG_INIT ) != 0; }
|
|
65 public boolean queuedForCompilation() { return (flags & JVM_ACC_QUEUED ) != 0; }
|
|
66 public boolean isNotOsrCompilable () { return (flags & JVM_ACC_NOT_OSR_COMPILABLE ) != 0; }
|
|
67 public boolean hasLineNumberTable () { return (flags & JVM_ACC_HAS_LINE_NUMBER_TABLE ) != 0; }
|
|
68 public boolean hasCheckedExceptions() { return (flags & JVM_ACC_HAS_CHECKED_EXCEPTIONS ) != 0; }
|
|
69 public boolean hasJsrs () { return (flags & JVM_ACC_HAS_JSRS ) != 0; }
|
|
70 public boolean isObsolete () { return (flags & JVM_ACC_IS_OBSOLETE ) != 0; }
|
|
71
|
|
72 // klassOop flags
|
|
73 public boolean hasMirandaMethods () { return (flags & JVM_ACC_HAS_MIRANDA_METHODS ) != 0; }
|
|
74 public boolean hasVanillaConstructor() { return (flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; }
|
|
75 public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 0; }
|
|
76 public boolean isCloneable () { return (flags & JVM_ACC_IS_CLONEABLE ) != 0; }
|
|
77
|
|
78 // klassOop and methodOop flags
|
|
79 public boolean hasLocalVariableTable() { return (flags & JVM_ACC_HAS_LOCAL_VARIABLE_TABLE ) != 0; }
|
|
80
|
|
81 // field flags
|
|
82 public boolean fieldAccessWatched () { return (flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }
|
|
83 public boolean fieldModificationWatched() { return (flags & JVM_ACC_FIELD_MODIFICATION_WATCHED) != 0; }
|
|
84
|
|
85 public void printOn(PrintStream tty) {
|
|
86 // prints only .class flags and not the hotspot internal flags
|
|
87 if (isPublic ()) tty.print("public " );
|
|
88 if (isPrivate ()) tty.print("private " );
|
|
89 if (isProtected ()) tty.print("protected " );
|
|
90 if (isStatic ()) tty.print("static " );
|
|
91 if (isFinal ()) tty.print("final " );
|
|
92 if (isSynchronized()) tty.print("synchronized ");
|
|
93 if (isVolatile ()) tty.print("volatile " );
|
|
94 if (isBridge ()) tty.print("bridge " );
|
|
95 if (isTransient ()) tty.print("transient " );
|
|
96 if (isVarArgs ()) tty.print("varargs " );
|
|
97 if (isNative ()) tty.print("native " );
|
|
98 if (isEnum ()) tty.print("enum " );
|
|
99 if (isInterface ()) tty.print("interface " );
|
|
100 if (isAbstract ()) tty.print("abstract " );
|
|
101 if (isStrict ()) tty.print("strict " );
|
|
102 if (isSynthetic ()) tty.print("synthetic " );
|
|
103 }
|
|
104
|
|
105 // get flags written to .class files
|
|
106 public int getStandardFlags() {
|
|
107 return (int) (flags & JVM_ACC_WRITTEN_FLAGS);
|
|
108 }
|
|
109 }
|