< prev index next >

test/compiler/compilercontrol/share/pool/subpack/KlassDup.java

Print this page
rev 9948 : imported patch 8145800
rev 9006 : 8066157: JEP-JDK-8046155: Test task: method matcher
Summary: MethodMatcher test and framework
Reviewed-by: iignatyev, neliasso


   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 pool.subpack;
  25 
  26 import jdk.test.lib.Pair;
  27 import pool.MethodHolder;
  28 
  29 import java.lang.reflect.Executable;
  30 import java.util.ArrayList;
  31 import java.util.List;
  32 import java.util.concurrent.Callable;
  33 
  34 /**
  35  * 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)
  37  */
  38 public class KlassDup extends MethodHolder {
  39     public void method(int a, String[] ss, Integer i, byte[] bb, double[][] dd) { }
  40 
  41     public void method() { }
  42 
  43     public static String smethod() {
  44         return "ABC";
  45     }
  46 
  47     public static String smethod(int iarg, int[] aarg) {
  48         return "ABC";
  49     }
  50 
  51     public static Integer smethod(Integer arg) {
  52         Integer var = 1024;
  53         return arg + var;
  54     }
  55 
  56     // Internal class and constructor
  57     public static class Internal extends MethodHolder {
  58         public Internal() { }
  59 
  60         public Double method(Float fl) { return Double.valueOf(fl); }
  61 
  62         public Double methodDup() {
  63             return Math.exp(1.0);
  64         }
  65 
  66         public static Integer smethod(Integer arg) {
  67             Integer var = 1024;
  68             return arg + var;
  69         }
  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     }
  93 }


   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 pool.subpack;
  25 

  26 import pool.MethodHolder;
  27 import pool.SubMethodHolder;




  28 
  29 /**
  30  * This is a clone of the pool.sub.Klass used to test pattern matching
  31  * Full class name contains both suffix (Dup) and prefix (pool.subpack)
  32  */
  33 public class KlassDup extends MethodHolder {
  34     public void method(int a, String[] ss, Integer i, byte[] bb, double[][] dd) { }
  35 
  36     public void method() { }
  37 
  38     public static String smethod() {
  39         return "ABC";
  40     }
  41 
  42     public static String smethod(int iarg, int[] aarg) {
  43         return "ABC";
  44     }
  45 
  46     public static Integer smethod(Integer arg) {
  47         Integer var = 1024;
  48         return arg + var;
  49     }
  50 
  51     // Internal class and constructor
  52     public static class Internal extends SubMethodHolder {
  53         public Internal() { }
  54 
  55         public Double method(Float fl) { return Double.valueOf(fl); }
  56 
  57         public Double methodDup() {
  58             return Math.exp(1.0);
  59         }
  60 
  61         public static Integer smethod(Integer arg) {
  62             Integer var = 1024;
  63             return arg + var;
  64         }






















  65     }
  66 }
< prev index next >