1 /* 2 * Copyright (c) 1998, 2003, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.jdi; 27 28 import com.sun.jdi.*; 29 30 import java.util.List; 31 32 abstract public class TypeComponentImpl extends MirrorImpl 33 implements TypeComponent 34 { 35 protected final long ref; 36 protected final String name; 37 protected final String signature; 38 protected final String genericSignature; 39 protected final ReferenceTypeImpl declaringType; 40 private final int modifiers; 41 TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, long ref, String name, String signature, String genericSignature, int modifiers)42 TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, 43 long ref, 44 String name, String signature, 45 String genericSignature, int modifiers) { 46 // The generic signature is set when this is created. 47 super(vm); 48 this.declaringType = declaringType; 49 this.ref = ref; 50 this.name = name; 51 this.signature = signature; 52 if (genericSignature != null && genericSignature.length() != 0) { 53 this.genericSignature = genericSignature; 54 } else { 55 this.genericSignature = null; 56 } 57 this.modifiers = modifiers; 58 } 59 name()60 public String name() { 61 return name; 62 } 63 signature()64 public String signature() { 65 return signature; 66 } genericSignature()67 public String genericSignature() { 68 return genericSignature; 69 } 70 modifiers()71 public int modifiers() { 72 return modifiers; 73 } 74 declaringType()75 public ReferenceType declaringType() { 76 return declaringType; 77 } 78 isStatic()79 public boolean isStatic() { 80 return isModifierSet(VMModifiers.STATIC); 81 } 82 isFinal()83 public boolean isFinal() { 84 return isModifierSet(VMModifiers.FINAL); 85 } 86 isPrivate()87 public boolean isPrivate() { 88 return isModifierSet(VMModifiers.PRIVATE); 89 } 90 isPackagePrivate()91 public boolean isPackagePrivate() { 92 return !isModifierSet(VMModifiers.PRIVATE 93 | VMModifiers.PROTECTED 94 | VMModifiers.PUBLIC); 95 } 96 isProtected()97 public boolean isProtected() { 98 return isModifierSet(VMModifiers.PROTECTED); 99 } 100 isPublic()101 public boolean isPublic() { 102 return isModifierSet(VMModifiers.PUBLIC); 103 } 104 isSynthetic()105 public boolean isSynthetic() { 106 return isModifierSet(VMModifiers.SYNTHETIC); 107 } 108 ref()109 long ref() { 110 return ref; 111 } 112 isModifierSet(int compareBits)113 boolean isModifierSet(int compareBits) { 114 return (modifiers & compareBits) != 0; 115 } 116 } 117