Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ClassExclusionFilterTest.java
42283 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package nsk.share.jdi;2324import nsk.share.Consts;25import nsk.share.TestBug;2627import java.io.PrintStream;28import java.util.ArrayList;2930/*31* Class for testing class exclusion filter, this filter is added by32* request's method addClassExclusionFilter(String classPattern) Expected33* command line parameter:34* - class patterns which should be passed to adding filter method (e.g. -classPatterns java.*:*.Foo)35*/36public class ClassExclusionFilterTest extends EventFilterTest {37protected String[] classPatterns;3839public static void main(String[] argv) {40System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);41}4243public static int run(String[] argv, PrintStream out) {44return new ClassExclusionFilterTest().runIt(argv, out);45}4647protected String[] doInit(String[] args, PrintStream out) {48args = super.doInit(args, out);4950ArrayList<String> standardArgs = new ArrayList<>();5152for (int i = 0; i < args.length; i++) {53if (args[i].equals("-classPatterns") && (i < args.length - 1)) {54classPatterns = args[i + 1].split(":");55i++;56} else {57standardArgs.add(args[i]);58}59}6061if (classPatterns == null || classPatterns.length == 0) {62throw new TestBug("Test requires at least one class name pattern");63}6465return standardArgs.toArray(new String[]{});66}6768protected int getTestFiltersNumber() {69return classPatterns.length;70}7172protected EventFilters.DebugEventFilter[] createTestFilters(int testedFilterIndex) {73if (testedFilterIndex < 0 || testedFilterIndex >= classPatterns.length) {74throw new TestBug("Invalid testedFilterIndex: " + testedFilterIndex);75}7677return new EventFilters.DebugEventFilter[]{new EventFilters.ClassExclusionFilter(classPatterns[testedFilterIndex])};78}79}808182