hotspot/test/compiler/compilercontrol/share/pool/subpack/KlassDup.java
changeset 35587 173b2da63cc3
parent 33081 71794b149055
child 40059 c2304140ed64
equal deleted inserted replaced
35580:1225225bd34e 35587:173b2da63cc3
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 package pool.subpack;
    24 package pool.subpack;
    25 
    25 
    26 import jdk.test.lib.Pair;
       
    27 import pool.MethodHolder;
    26 import pool.MethodHolder;
    28 
    27 import pool.SubMethodHolder;
    29 import java.lang.reflect.Executable;
       
    30 import java.util.ArrayList;
       
    31 import java.util.List;
       
    32 import java.util.concurrent.Callable;
       
    33 
    28 
    34 /**
    29 /**
    35  * This is a clone of the pool.sub.Klass used to test pattern matching
    30  * This is a clone of the pool.sub.Klass used to test pattern matching
    36  * Full class name contains both suffix (Dup) and prefix (pool.subpack)
    31  * Full class name contains both suffix (Dup) and prefix (pool.subpack)
    37  */
    32  */
    52         Integer var = 1024;
    47         Integer var = 1024;
    53         return arg + var;
    48         return arg + var;
    54     }
    49     }
    55 
    50 
    56     // Internal class and constructor
    51     // Internal class and constructor
    57     public static class Internal extends MethodHolder {
    52     public static class Internal extends SubMethodHolder {
    58         public Internal() { }
    53         public Internal() { }
    59 
    54 
    60         public Double method(Float fl) { return Double.valueOf(fl); }
    55         public Double method(Float fl) { return Double.valueOf(fl); }
    61 
    56 
    62         public Double methodDup() {
    57         public Double methodDup() {
    65 
    60 
    66         public static Integer smethod(Integer arg) {
    61         public static Integer smethod(Integer arg) {
    67             Integer var = 1024;
    62             Integer var = 1024;
    68             return arg + var;
    63             return arg + var;
    69         }
    64         }
    70 
       
    71         @Override
       
    72         public List<Pair<Executable, Callable<?>>> getAllMethods() {
       
    73             List<Pair<Executable, Callable<?>>> pairs = new ArrayList<>();
       
    74             Pair<Executable, Callable<?>> pair = new Pair<>
       
    75                     (getMethod(this, "method", Float.class),
       
    76                             () -> this.method(3.141592f));
       
    77             pairs.add(pair);
       
    78             pair = new Pair<>(getMethod(this, "methodDup"), this::methodDup);
       
    79             pairs.add(pair);
       
    80             pair = new Pair<>(getMethod(this, "smethod", Integer.class),
       
    81                     () -> smethod(1024));
       
    82             pairs.add(pair);
       
    83             try {
       
    84                 pair = new Pair<>(this.getClass().getConstructor(),
       
    85                         Internal::new);
       
    86                 pairs.add(pair);
       
    87             } catch (NoSuchMethodException e) {
       
    88                 throw new Error("TESTBUG: unable to get constructor");
       
    89             }
       
    90             return pairs;
       
    91         }
       
    92     }
    65     }
    93 }
    66 }