1/* 2 * Copyright (c) 1998, 2017, 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 26package com.sun.tools.jdi; 27 28import com.sun.jdi.ReferenceType; 29import com.sun.jdi.TypeComponent; 30import com.sun.jdi.VirtualMachine; 31 32abstract 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 42 TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, 43 long ref, String name, String signature, 44 String genericSignature, int modifiers) { 45 // The generic signature is set when this is created. 46 super(vm); 47 this.declaringType = declaringType; 48 this.ref = ref; 49 this.name = name; 50 this.signature = signature; 51 if (genericSignature != null && genericSignature.length() != 0) { 52 this.genericSignature = genericSignature; 53 } else { 54 this.genericSignature = null; 55 } 56 this.modifiers = modifiers; 57 } 58 59 public String name() { 60 return name; 61 } 62 63 public String signature() { 64 return signature; 65 } 66 public String genericSignature() { 67 return genericSignature; 68 } 69 70 public int modifiers() { 71 return modifiers; 72 } 73 74 public ReferenceType declaringType() { 75 return declaringType; 76 } 77 78 public boolean isStatic() { 79 return isModifierSet(VMModifiers.STATIC); 80 } 81 82 public boolean isFinal() { 83 return isModifierSet(VMModifiers.FINAL); 84 } 85 86 public boolean isPrivate() { 87 return isModifierSet(VMModifiers.PRIVATE); 88 } 89 90 public boolean isPackagePrivate() { 91 return !isModifierSet(VMModifiers.PRIVATE | 92 VMModifiers.PROTECTED | 93 VMModifiers.PUBLIC); 94 } 95 96 public boolean isProtected() { 97 return isModifierSet(VMModifiers.PROTECTED); 98 } 99 100 public boolean isPublic() { 101 return isModifierSet(VMModifiers.PUBLIC); 102 } 103 104 public boolean isSynthetic() { 105 return isModifierSet(VMModifiers.SYNTHETIC); 106 } 107 108 long ref() { 109 return ref; 110 } 111 112 boolean isModifierSet(int compareBits) { 113 return (modifiers & compareBits) != 0; 114 } 115} 116