jdk/test/com/sun/jdi/NativeInstanceFilterTarg.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7978 120267233d5e
child 29498 fe656bc7c3f5
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7978
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7978
diff changeset
     2
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
7978
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     4
 *
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     8
 *
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    13
 * accompanied this code).
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    14
 *
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    18
 *
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    21
 * questions.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    22
 */
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    23
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    24
import sun.misc.Version;
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    25
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    26
public class NativeInstanceFilterTarg {
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    27
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    28
    public static void main(String args[]) {
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    29
        boolean runTest = jvmSupportsJVMTI_12x();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    30
        String s1 = "abc";
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    31
        String s2 = "def";
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    32
        latch(s1);
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    33
        s1.intern();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    34
        if (runTest) {
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    35
            s2.intern(); // this is the call that generates events that ought
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    36
                         // to be filtered out.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    37
        } else {
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    38
            System.out.println("Neutering test since JVMTI 1.2 not supported");
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    39
        }
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    40
    }
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    41
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    42
    // Used by debugger to get an instance to filter with
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    43
    public static String latch(String s) { return s; }
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    44
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    45
    public static boolean jvmSupportsJVMTI_12x() {
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    46
        // This fix requires the JVM to support JVMTI 1.2, which doesn't
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    47
        // happen until HSX 20.0, build 05.
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    48
        int major = Version.jvmMajorVersion();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    49
        int minor = Version.jvmMinorVersion();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    50
        int micro = Version.jvmMicroVersion();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    51
        int build = Version.jvmBuildNumber();
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    52
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    53
        return (major > 20 || major == 20 &&
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    54
                   (minor > 0 || micro > 0 || build >= 5));
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    55
    }
120267233d5e 6436034: Instance filter doesn't filter event if it occurs in native method
kamg
parents:
diff changeset
    56
}