< prev index next >

test/compiler/oracle/MethodMatcherTest.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


   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  * @test MethodMatcherTest
  26  * @modules java.base/jdk.internal.misc

  27  * @library /testlibrary /test/lib

  28  * @build sun.hotspot.WhiteBox
  29  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  30  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  31  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI MethodMatcherTest
  32  * @summary Testing of compiler/MethodMatcher
  33  * @bug 8135068
  34  */
  35 
  36 import java.lang.reflect.Method;
  37 import java.util.ArrayList;
  38 
  39 import sun.hotspot.WhiteBox;
  40 



  41 public class MethodMatcherTest {
  42 
  43     /** Instance of WhiteBox */
  44     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  45 
  46     Method helper;
  47     Method getDate;
  48     Method inner;
  49     Method toString;
  50 
  51     static final int MATCH = 1;
  52     static final int NO_MATCH = 0;
  53     static final int PARSING_FAILURE = -1;
  54 
  55     public MethodMatcherTest() {
  56     }
  57 
  58     public void test() throws Exception {
  59         // instantiate before calling getMethod on innerHelper
  60         TestCases testCases = new TestCases();


  66 
  67         testCases.add(helper, "pool/sub/Klass.method(I[Ljava/lang/String;Ljava/lang/Integer;[B[[D)V", NO_MATCH);
  68 
  69         // These should be improved to parsing failed in the future
  70         testCases.add(helper, "*Klass*,*$method*::", NO_MATCH);
  71         testCases.add(helper, "*Klass *+*", NO_MATCH);
  72         testCases.add(helper, "*Klass*::*method*", NO_MATCH);
  73 
  74         testCases.add(helper, "*,**", PARSING_FAILURE);
  75         testCases.add(helper, "*,*(I[Ljava/lang/String;Lj]ava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  76         testCases.add(helper, "*,*)method*.", PARSING_FAILURE);
  77         testCases.add(helper, "{pool.subpack.Klass}* *", PARSING_FAILURE);
  78         testCases.add(helper, "*Klass met]hod/", PARSING_FAILURE);
  79         testCases.add(helper, "pool::su@%b::Klass* *)method.", PARSING_FAILURE);
  80         testCases.add(helper, "0pool/sub/Klass,*{method}*.(I[Ljava/lang/String;Lj]ava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  81         testCases.add(helper, "*Klass nonexistent::)(I[Ljava/lang/String;Ljava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  82         testCases.add(helper, "pool,su]b,Klass*,*)method*/", PARSING_FAILURE);
  83         testCases.add(helper, "_pool,sub,Klass*,met@%hod,(0)V", PARSING_FAILURE);
  84 
  85         testCases.add(helper, "*.*", MATCH);
  86         testCases.add(helper, "MethodMatcherTest.*", MATCH);
  87         testCases.add(helper, "MethodMatcherTest.helper", MATCH);
  88         testCases.add(helper, "MethodMatcherTest.helper()", MATCH);
  89         testCases.add(helper, "MethodMatcherTest.helper()V", MATCH);
  90         testCases.add(helper, "MethodMatcherTest.helper()V;", NO_MATCH);
  91         testCases.add(helper, "MethodMatcherTest.helper()I", NO_MATCH);
  92         testCases.add(helper, "MethodMatcherTest.helperX", NO_MATCH);
  93         testCases.add(helper, "MethodMatcherTestX.helper;", NO_MATCH);
  94         testCases.add(helper, "abc.*", NO_MATCH);
  95         testCases.add(helper, "*.abc", NO_MATCH);
  96 
  97         testCases.add(getDate, "*.*", MATCH);
  98         testCases.add(getDate, "*.getDate", MATCH);
  99         testCases.add(getDate, "java/util/Date.getDate", MATCH);
 100         testCases.add(getDate, "java/util/Date.*", MATCH);
 101 
 102         testCases.add(inner, "*.*", MATCH);
 103         testCases.add(inner, "MethodMatcherTest$TestCases.innerHelper", MATCH);
 104         testCases.add(inner, "MethodMatcherTest*.innerHelper", MATCH);
 105         testCases.add(inner, "MethodMatcherTest$*.innerHelper", MATCH);
 106         testCases.add(inner, "*$TestCases.innerHelper", MATCH);
 107         testCases.add(inner, "*TestCases.innerHelper", MATCH);
 108         testCases.add(inner, "TestCases.innerHelper", NO_MATCH);
 109         testCases.add(inner, "MethodMatcherTest.innerHelper", NO_MATCH);
 110 
 111         testCases.add(toString, "*.*", MATCH);
 112         testCases.add(toString, "java/lang/String.toString", MATCH);
 113         testCases.add(toString, "java.lang.String::toString", MATCH);
 114 
 115         testCases.add(toString, "java/lang/String::toString", PARSING_FAILURE);
 116         testCases.add(toString, "java.lang/String::toString", PARSING_FAILURE);
 117         testCases.add(toString, "java.lang/String.toString", PARSING_FAILURE);
 118         testCases.add(toString, "java::lang::String::toString", PARSING_FAILURE);
 119 
 120         testCases.add(toString, "java/lang/String.toString(*)", PARSING_FAILURE);
 121         testCases.add(toString, "java/lang/String.toString(L*", PARSING_FAILURE);
 122         testCases.add(toString, "java/lang/String.toString*(lsd)l", NO_MATCH);
 123         testCases.add(toString, "java/lang/String.toString(lsd)l", NO_MATCH);
 124         testCases.add(toString, "java/lang/String.toString (", MATCH);
 125         testCases.add(toString, "java/lang/String.toString ()", MATCH);
 126         testCases.add(toString, "java/lang/String.toString ()L", MATCH);
 127         testCases.add(toString, "java/lang/String.toString ()Lj", MATCH);
 128         testCases.add(toString, "java/lang/String.toString ()Ls", NO_MATCH);
 129         testCases.add(toString, "java/lang/String.toString*(", MATCH);




   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  * @test MethodMatcherTest
  26  * @summary Testing of compiler/MethodMatcher
  27  * @bug 8135068
  28  * @library /testlibrary /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  * @build sun.hotspot.WhiteBox
  31  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  32  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  33  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  34  *                   compiler.oracle.MethodMatcherTest

  35  */
  36 
  37 package compiler.oracle;

  38 
  39 import sun.hotspot.WhiteBox;
  40 
  41 import java.lang.reflect.Method;
  42 import java.util.ArrayList;
  43 
  44 public class MethodMatcherTest {
  45 
  46     /** Instance of WhiteBox */
  47     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  48 
  49     Method helper;
  50     Method getDate;
  51     Method inner;
  52     Method toString;
  53 
  54     static final int MATCH = 1;
  55     static final int NO_MATCH = 0;
  56     static final int PARSING_FAILURE = -1;
  57 
  58     public MethodMatcherTest() {
  59     }
  60 
  61     public void test() throws Exception {
  62         // instantiate before calling getMethod on innerHelper
  63         TestCases testCases = new TestCases();


  69 
  70         testCases.add(helper, "pool/sub/Klass.method(I[Ljava/lang/String;Ljava/lang/Integer;[B[[D)V", NO_MATCH);
  71 
  72         // These should be improved to parsing failed in the future
  73         testCases.add(helper, "*Klass*,*$method*::", NO_MATCH);
  74         testCases.add(helper, "*Klass *+*", NO_MATCH);
  75         testCases.add(helper, "*Klass*::*method*", NO_MATCH);
  76 
  77         testCases.add(helper, "*,**", PARSING_FAILURE);
  78         testCases.add(helper, "*,*(I[Ljava/lang/String;Lj]ava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  79         testCases.add(helper, "*,*)method*.", PARSING_FAILURE);
  80         testCases.add(helper, "{pool.subpack.Klass}* *", PARSING_FAILURE);
  81         testCases.add(helper, "*Klass met]hod/", PARSING_FAILURE);
  82         testCases.add(helper, "pool::su@%b::Klass* *)method.", PARSING_FAILURE);
  83         testCases.add(helper, "0pool/sub/Klass,*{method}*.(I[Ljava/lang/String;Lj]ava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  84         testCases.add(helper, "*Klass nonexistent::)(I[Ljava/lang/String;Ljava/lang/Integer;[B[[D)V", PARSING_FAILURE);
  85         testCases.add(helper, "pool,su]b,Klass*,*)method*/", PARSING_FAILURE);
  86         testCases.add(helper, "_pool,sub,Klass*,met@%hod,(0)V", PARSING_FAILURE);
  87 
  88         testCases.add(helper, "*.*", MATCH);
  89         testCases.add(helper, "compiler/oracle/MethodMatcherTest.*", MATCH);
  90         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper", MATCH);
  91         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper()", MATCH);
  92         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper()V", MATCH);
  93         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper()V;", NO_MATCH);
  94         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper()I", NO_MATCH);
  95         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helperX", NO_MATCH);
  96         testCases.add(helper, "compiler/oracle/MethodMatcherTest.helper;", NO_MATCH);
  97         testCases.add(helper, "abc.*", NO_MATCH);
  98         testCases.add(helper, "*.abc", NO_MATCH);
  99 
 100         testCases.add(getDate, "*.*", MATCH);
 101         testCases.add(getDate, "*.getDate", MATCH);
 102         testCases.add(getDate, "java/util/Date.getDate", MATCH);
 103         testCases.add(getDate, "java/util/Date.*", MATCH);
 104 
 105         testCases.add(inner, "*.*", MATCH);
 106         testCases.add(inner, "compiler/oracle/MethodMatcherTest$TestCases.innerHelper", MATCH);
 107         testCases.add(inner, "compiler/oracle/MethodMatcherTest*.innerHelper", MATCH);
 108         testCases.add(inner, "compiler/oracle/MethodMatcherTest$*.innerHelper", MATCH);
 109         testCases.add(inner, "*$TestCases.innerHelper", MATCH);
 110         testCases.add(inner, "*TestCases.innerHelper", MATCH);
 111         testCases.add(inner, "TestCases.innerHelper", NO_MATCH);
 112         testCases.add(inner, "compiler/oracle/MethodMatcherTest.innerHelper", NO_MATCH);
 113 
 114         testCases.add(toString, "*.*", MATCH);
 115         testCases.add(toString, "java/lang/String.toString", MATCH);
 116         testCases.add(toString, "java.lang.String::toString", MATCH);
 117 
 118         testCases.add(toString, "java/lang/String::toString", PARSING_FAILURE);
 119         testCases.add(toString, "java.lang/String::toString", PARSING_FAILURE);
 120         testCases.add(toString, "java.lang/String.toString", PARSING_FAILURE);
 121         testCases.add(toString, "java::lang::String::toString", PARSING_FAILURE);
 122 
 123         testCases.add(toString, "java/lang/String.toString(*)", PARSING_FAILURE);
 124         testCases.add(toString, "java/lang/String.toString(L*", PARSING_FAILURE);
 125         testCases.add(toString, "java/lang/String.toString*(lsd)l", NO_MATCH);
 126         testCases.add(toString, "java/lang/String.toString(lsd)l", NO_MATCH);
 127         testCases.add(toString, "java/lang/String.toString (", MATCH);
 128         testCases.add(toString, "java/lang/String.toString ()", MATCH);
 129         testCases.add(toString, "java/lang/String.toString ()L", MATCH);
 130         testCases.add(toString, "java/lang/String.toString ()Lj", MATCH);
 131         testCases.add(toString, "java/lang/String.toString ()Ls", NO_MATCH);
 132         testCases.add(toString, "java/lang/String.toString*(", MATCH);


< prev index next >