4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * ident "%Z%%M% %I% %E% SMI"
29 import org.opensolaris.os.dtrace.*;
32 * Regression for 6506495 -DJAVA_DTRACE_MAX_CONSUMERS=N for any N < 8
33 * is treated as if it were 8.
35 public class TestMaxConsumers {
36 static final String MAX_CONSUMERS_PROPERTY_NAME =
37 "JAVA_DTRACE_MAX_CONSUMERS";
40 getIntegerProperty(String name)
43 String property = System.getProperty(name);
44 if (property != null && property.length() != 0) {
46 value = Integer.parseInt(property);
47 } catch (NumberFormatException e) {
57 Integer property = getIntegerProperty(MAX_CONSUMERS_PROPERTY_NAME);
58 int max = (property == null ? 0 : property);
59 int n = (property == null ? 11 : (max < 1 ? 1 : max));
61 Consumer[] consumers = new Consumer[n];
63 for (int i = 0; i < n; ++i) {
64 consumers[i] = new LocalConsumer();
67 for (int i = 0; i < n; ++i) {
70 for (int i = 0; i < n; ++i) {
71 consumers[i] = new LocalConsumer();
74 } catch (Exception e) {
80 Consumer consumer = new LocalConsumer();
83 System.out.println("Error: " + (max + 1) + " > " +
84 MAX_CONSUMERS_PROPERTY_NAME);
86 System.out.println("Success");
89 } catch (Exception e) {
90 System.out.println("Success");
92 for (int i = 0; i < n; ++i) {