hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassData.java
changeset 37196 f3f7367e8c53
equal deleted inserted replaced
37195:88b6f1271f64 37196:f3f7367e8c53
       
     1 /*
       
     2  * Copyright (c) 2016, 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  */
       
    23 
       
    24 package selectionresolution;
       
    25 
       
    26 /**
       
    27  * A representation of information about a class.  Note that classes
       
    28  * here define only one method.
       
    29  */
       
    30 public class ClassData {
       
    31 
       
    32     public enum Package {
       
    33         /**
       
    34          * Same package as the callsite.
       
    35          */
       
    36         SAME,
       
    37         /**
       
    38          * Different package from the callsite.
       
    39          */
       
    40         DIFFERENT,
       
    41         /**
       
    42          * Same as DIFFERENT, and also implies that the class access
       
    43          * is package-private.
       
    44          */
       
    45         INACCESSIBLE,
       
    46         /**
       
    47          * Different from everything else.  Used in selection only, to
       
    48          * test skipping package-private definitions.
       
    49          */
       
    50         OTHER,
       
    51         /**
       
    52          * Placeholder, used solely by the template dumper for
       
    53          * printing out the effects of templates.  Don't use for
       
    54          * anything else.
       
    55          */
       
    56         PLACEHOLDER;
       
    57     }
       
    58 
       
    59     /**
       
    60      * The package ID for the class.
       
    61      */
       
    62     public final Package packageId;
       
    63 
       
    64     /**
       
    65      * The method data for the method definition.  If there is no
       
    66      * method definition, this will be null.
       
    67      */
       
    68     public final MethodData methoddata;
       
    69 
       
    70     /**
       
    71      * The class access.  Note that this is controlled by the packageId.
       
    72      */
       
    73     public final MethodData.Access access;
       
    74 
       
    75     // This is a hardwired value necessary for ClassBuilder
       
    76     public final MethodData.Context abstraction = MethodData.Context.INSTANCE;
       
    77 
       
    78     public ClassData(final Package packageId,
       
    79                      final MethodData methoddata) {
       
    80         this.packageId = packageId;
       
    81         this.methoddata = methoddata;
       
    82 
       
    83         if (packageId == Package.INACCESSIBLE)
       
    84             access = MethodData.Access.PACKAGE;
       
    85         else
       
    86             access = MethodData.Access.PUBLIC;
       
    87     }
       
    88 
       
    89     public String toString() {
       
    90         StringBuilder sb = new StringBuilder();
       
    91         sb.append(" { ");
       
    92 
       
    93         if (methoddata != null) {
       
    94             sb.append(methoddata);
       
    95         }
       
    96 
       
    97         sb.append(" }\n\n");
       
    98 
       
    99         return sb.toString();
       
   100     }
       
   101 
       
   102 }