< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java

Print this page




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.hotspot;
  24 

  25 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
  26 
  27 import java.lang.annotation.Annotation;
  28 import java.lang.reflect.Field;
  29 
  30 import jdk.internal.vm.annotation.Stable;
  31 import jdk.vm.ci.meta.JavaType;
  32 import jdk.vm.ci.meta.ModifiersProvider;
  33 import jdk.vm.ci.meta.ResolvedJavaType;
  34 
  35 /**
  36  * Represents a field in a HotSpot type.
  37  */
  38 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
  39 
  40     private final HotSpotResolvedObjectTypeImpl holder;
  41     private final String name;
  42     private JavaType type;
  43     private final int offset;
  44 
  45     /**
  46      * This value contains all flags as stored in the VM including internal ones.
  47      */
  48     private final int modifiers;
  49 
  50     HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
  51         this.holder = holder;
  52         this.name = name;


  64         }
  65         if (obj instanceof HotSpotResolvedJavaField) {
  66             HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
  67             if (that.offset != this.offset || that.isStatic() != this.isStatic()) {
  68                 return false;
  69             } else if (this.holder.equals(that.holder)) {
  70                 assert this.name.equals(that.name) && this.type.equals(that.type);
  71                 return true;
  72             }
  73         }
  74         return false;
  75     }
  76 
  77     @Override
  78     public int hashCode() {
  79         return name.hashCode();
  80     }
  81 
  82     @Override
  83     public int getModifiers() {
  84         return modifiers & ModifiersProvider.jvmFieldModifiers();
  85     }
  86 
  87     @Override
  88     public boolean isInternal() {
  89         return (modifiers & config().jvmAccFieldInternal) != 0;
  90     }
  91 
  92     /**
  93      * Determines if a given object contains this field.
  94      *
  95      * @return true iff this is a non-static field and its declaring class is assignable from
  96      *         {@code object}'s class
  97      */
  98     public boolean isInObject(Object object) {
  99         if (isStatic()) {
 100             return false;
 101         }
 102         return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass()));
 103     }
 104 




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers;
  26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
  27 
  28 import java.lang.annotation.Annotation;
  29 import java.lang.reflect.Field;
  30 
  31 import jdk.internal.vm.annotation.Stable;
  32 import jdk.vm.ci.meta.JavaType;

  33 import jdk.vm.ci.meta.ResolvedJavaType;
  34 
  35 /**
  36  * Represents a field in a HotSpot type.
  37  */
  38 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
  39 
  40     private final HotSpotResolvedObjectTypeImpl holder;
  41     private final String name;
  42     private JavaType type;
  43     private final int offset;
  44 
  45     /**
  46      * This value contains all flags as stored in the VM including internal ones.
  47      */
  48     private final int modifiers;
  49 
  50     HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
  51         this.holder = holder;
  52         this.name = name;


  64         }
  65         if (obj instanceof HotSpotResolvedJavaField) {
  66             HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
  67             if (that.offset != this.offset || that.isStatic() != this.isStatic()) {
  68                 return false;
  69             } else if (this.holder.equals(that.holder)) {
  70                 assert this.name.equals(that.name) && this.type.equals(that.type);
  71                 return true;
  72             }
  73         }
  74         return false;
  75     }
  76 
  77     @Override
  78     public int hashCode() {
  79         return name.hashCode();
  80     }
  81 
  82     @Override
  83     public int getModifiers() {
  84         return modifiers & jvmFieldModifiers();
  85     }
  86 
  87     @Override
  88     public boolean isInternal() {
  89         return (modifiers & config().jvmAccFieldInternal) != 0;
  90     }
  91 
  92     /**
  93      * Determines if a given object contains this field.
  94      *
  95      * @return true iff this is a non-static field and its declaring class is assignable from
  96      *         {@code object}'s class
  97      */
  98     public boolean isInObject(Object object) {
  99         if (isStatic()) {
 100             return false;
 101         }
 102         return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass()));
 103     }
 104 


< prev index next >