1/*
2 * Copyright (c) 2011, 2015, 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.
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 */
23package jdk.vm.ci.hotspot;
24
25import jdk.vm.ci.meta.Assumptions.AssumptionResult;
26import jdk.vm.ci.meta.Constant;
27import jdk.vm.ci.meta.ConstantPool;
28import jdk.vm.ci.meta.JavaConstant;
29import jdk.vm.ci.meta.JavaKind;
30import jdk.vm.ci.meta.JavaType;
31import jdk.vm.ci.meta.ResolvedJavaMethod;
32import jdk.vm.ci.meta.ResolvedJavaType;
33
34/**
35 * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes.
36 */
37public interface HotSpotResolvedObjectType extends ResolvedJavaType {
38
39    /**
40     * Gets the JVMCI mirror for a {@link Class} object.
41     *
42     * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass}
43     */
44    static HotSpotResolvedObjectType fromObjectClass(Class<?> javaClass) {
45        return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaClass);
46    }
47
48    HotSpotResolvedObjectType getArrayClass();
49
50    ResolvedJavaType getComponentType();
51
52    AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype();
53
54    HotSpotResolvedObjectType getSuperclass();
55
56    HotSpotResolvedObjectType[] getInterfaces();
57
58    HotSpotResolvedObjectType getSupertype();
59
60    HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType);
61
62    default boolean isPrimitive() {
63        return false;
64    }
65
66    default JavaKind getJavaKind() {
67        return JavaKind.Object;
68    }
69
70    ConstantPool getConstantPool();
71
72    /**
73     * Gets the instance size of this type. If an instance of this type cannot be fast path
74     * allocated, then the returned value is negative (its absolute value gives the size). Must not
75     * be called if this is an array or interface type.
76     */
77    int instanceSize();
78
79    int getVtableLength();
80
81    @Override
82    AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method);
83
84    /**
85     * Performs a fast-path check that this type is resolved in the context of a given accessing
86     * class. A negative result does not mean this type is not resolved with respect to
87     * {@code accessingClass}. That can only be determined by
88     * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean)
89     * re-resolving} the type.
90     */
91    boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass);
92
93    /**
94     * Gets the metaspace Klass boxed in a {@link JavaConstant}.
95     */
96    Constant klass();
97
98    boolean isPrimaryType();
99
100    int superCheckOffset();
101
102    long prototypeMarkWord();
103
104    int layoutHelper();
105
106    long getFingerprint();
107
108    HotSpotResolvedObjectType getEnclosingType();
109
110    ResolvedJavaMethod getClassInitializer();
111}
112