hotspot/test/runtime/SelectionResolution/classes/selectionresolution/MethodData.java
changeset 37196 f3f7367e8c53
child 41705 332239c052cc
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 
       
    25 package selectionresolution;
       
    26 
       
    27 /**
       
    28  * A representation of a method definition.
       
    29  */
       
    30 public class MethodData {
       
    31 
       
    32     public enum Access {
       
    33         PUBLIC(1),
       
    34         PACKAGE(0),
       
    35         PROTECTED(4),
       
    36         PRIVATE(2),
       
    37         /**
       
    38          * Placeholder, used solely for printing out the effects of
       
    39          * templates.  Don't use.
       
    40          */
       
    41         PLACEHOLDER(-1);
       
    42 
       
    43         public final int flag;
       
    44 
       
    45         Access(int flag) {
       
    46             this.flag = flag;
       
    47         }
       
    48     }
       
    49 
       
    50     public enum Context {
       
    51         ABSTRACT,
       
    52         INSTANCE,
       
    53         STATIC,
       
    54         /**
       
    55          * Placeholder, used solely for printing out the effects of
       
    56          * templates.  Don't use.
       
    57          */
       
    58         PLACEHOLDER;
       
    59     };
       
    60 
       
    61     /**
       
    62      * Access for the method.
       
    63      */
       
    64     public final Access access;
       
    65 
       
    66     /**
       
    67      * Context (static, instance, abstract) for the method.
       
    68      */
       
    69     public final Context context;
       
    70 
       
    71     /**
       
    72      * Create method data.
       
    73      */
       
    74     public MethodData(final Access access,
       
    75                       final Context context) {
       
    76 
       
    77         this.access = access;
       
    78         this.context = context;
       
    79     }
       
    80 
       
    81     public String toString() {
       
    82         StringBuilder sb = new StringBuilder();
       
    83         switch (access) {
       
    84         case PUBLIC: sb.append("public"); break;
       
    85         case PACKAGE: sb.append("package"); break;
       
    86         case PROTECTED: sb.append("protected"); break;
       
    87         case PRIVATE: sb.append("private"); break;
       
    88         case PLACEHOLDER: sb.append(" _"); break;
       
    89         default: throw new RuntimeException("Impossible case");
       
    90         }
       
    91 
       
    92         switch (context) {
       
    93         case STATIC: sb.append(" static"); break;
       
    94         case INSTANCE: sb.append(" instance"); break;
       
    95         case ABSTRACT: sb.append("  abstract"); break;
       
    96         case PLACEHOLDER: sb.append(" _"); break;
       
    97         default: throw new RuntimeException("Impossible case");
       
    98         }
       
    99         sb.append(" Integer m();");
       
   100 
       
   101         return sb.toString();
       
   102     }
       
   103 
       
   104 }