test/jdk/javax/management/ObjectName/SerialCompatTest.java
author jwilhelm
Thu, 24 Jan 2019 21:24:29 +0100
changeset 53479 31e5c82f59e9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8217580: Remove tests from problemList as bugs has been closed Reviewed-by: iignatyev, mseledtsov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 25164
diff changeset
     2
 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    26
 * @bug 6211220 6616825
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Test that jmx.serial.form=1.0 works for ObjectName
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    28
 * @author Eamonn McManus, Daniel Fuchs
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    29
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @run clean SerialCompatTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @run build SerialCompatTest
25164
06c6cc3a5930 8047073: Some javax/management/ fails with JFR
jbachorik
parents: 5506
diff changeset
    32
 * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class SerialCompatTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    41
    public static void check6211220() throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        ObjectName on = new ObjectName("a:b=c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        ObjectOutputStream oos = new ObjectOutputStream(bos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        oos.writeObject(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        oos.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        byte[] bytes = bos.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        ObjectInputStream ois = new ObjectInputStream(bis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        ObjectName on1 = (ObjectName) ois.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        // if the bug is present, these will get NullPointerException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        for (int i = 0; i <= 11; i++) {
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    55
            String msg = "6211220 case(" + i + ")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                switch (i) {
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    58
                    case 0:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    59
                        check(msg, on1.getDomain().equals("a"));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    60
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    61
                    case 1:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    62
                        check(msg, on1.getCanonicalName().equals("a:b=c"));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    63
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    64
                    case 2:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    65
                        check(msg, on1.getKeyPropertyListString()
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    66
                                .equals("b=c"));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    67
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    68
                    case 3:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    69
                        check(msg, on1.getCanonicalKeyPropertyListString()
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    70
                                .equals("b=c"));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    71
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    72
                    case 4:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    73
                        check(msg, on1.getKeyProperty("b").equals("c"));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    74
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    75
                    case 5:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    76
                        check(msg, on1.getKeyPropertyList()
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    77
                                .equals(Collections.singletonMap("b", "c")));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    78
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    79
                    case 6:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    80
                        check(msg, !on1.isDomainPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    81
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    82
                    case 7:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    83
                        check(msg, !on1.isPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    84
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    85
                    case 8:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    86
                        check(msg, !on1.isPropertyPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    87
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    88
                    case 9:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    89
                        check(msg, on1.equals(on));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    90
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    91
                    case 10:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    92
                        check(msg, on.equals(on1));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    93
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    94
                    case 11:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    95
                        check(msg, on1.apply(on));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    96
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    97
                    default:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
    98
                        throw new Exception(msg + ": Test incorrect");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            } catch (Exception e) {
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   101
                System.out.println(msg + ": Test failed with exception:");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                e.printStackTrace(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                failed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   107
        if (failed) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   108
            throw new Exception("Some tests for 6211220 failed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   109
        } else {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   110
            System.out.println("All tests for 6211220 passed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   111
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   114
    static void checkName(String testname, ObjectName on)
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   115
            throws Exception {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   116
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   117
        ObjectOutputStream oos = new ObjectOutputStream(bos);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   118
        oos.writeObject(on);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   119
        oos.close();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   120
        byte[] bytes = bos.toByteArray();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   121
        ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   122
        ObjectInputStream ois = new ObjectInputStream(bis);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   123
        ObjectName on1 = (ObjectName) ois.readObject();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   124
        // if the bug is present, these will get NullPointerException
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   125
        for (int i = 0; i <= 11; i++) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   126
            String msg = testname + " case(" + i + ")";
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   127
            try {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   128
                switch (i) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   129
                    case 0:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   130
                        check(msg, on1.getDomain().equals(on.getDomain()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   131
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   132
                    case 1:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   133
                        check(msg, on1.getCanonicalName().
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   134
                                equals(on.getCanonicalName()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   135
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   136
                    case 2:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   137
                        check(msg, on1.getKeyPropertyListString().
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   138
                                equals(on.getKeyPropertyListString()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   139
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   140
                    case 3:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   141
                        check(msg, on1.getCanonicalKeyPropertyListString().
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   142
                                equals(on.getCanonicalKeyPropertyListString()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   143
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   144
                    case 4:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   145
                        for (Object ko : on1.getKeyPropertyList().keySet()) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   146
                            final String key = (String) ko;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   147
                            check(msg, on1.getKeyProperty(key).
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   148
                                    equals(on.getKeyProperty(key)));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   149
                        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   150
                        for (Object ko : on.getKeyPropertyList().keySet()) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   151
                            final String key = (String) ko;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   152
                            check(msg, on1.getKeyProperty(key).
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   153
                                    equals(on.getKeyProperty(key)));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   154
                        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   155
                    case 5:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   156
                        check(msg, on1.getKeyPropertyList()
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   157
                                .equals(on.getKeyPropertyList()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   158
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   159
                    case 6:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   160
                        check(msg, on1.isDomainPattern()==on.isDomainPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   161
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   162
                    case 7:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   163
                        check(msg, on1.isPattern() == on.isPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   164
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   165
                    case 8:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   166
                        check(msg,
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   167
                              on1.isPropertyPattern()==on.isPropertyPattern());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   168
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   169
                    case 9:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   170
                        check(msg, on1.equals(on));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   171
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   172
                    case 10:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   173
                        check(msg, on.equals(on1));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   174
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   175
                    case 11:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   176
                        if (!on.isPattern()) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   177
                            check(msg, on1.apply(on));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   178
                        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   179
                        break;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   180
                    default:
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   181
                        throw new Exception("Test incorrect: case: " + i);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   182
                }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   183
            } catch (Exception e) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   184
                System.out.println("Test (" + i + ") failed with exception:");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   185
                e.printStackTrace(System.out);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   186
                failed = true;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   187
            }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   188
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   189
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   190
    }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   191
    private static String[] names6616825 = {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   192
        "a:b=c", "a:b=c,*", "*:*", ":*", ":b=c", ":b=c,*",
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   193
        "a:*,b=c", ":*", ":*,b=c", "*x?:k=\"x\\*z\"", "*x?:k=\"x\\*z\",*",
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   194
        "*x?:*,k=\"x\\*z\"", "*x?:k=\"x\\*z\",*,b=c"
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   195
    };
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   196
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   197
    static void check6616825() throws Exception {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   198
        System.out.println("Testing 616825");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   199
        for (String n : names6616825) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   200
            final ObjectName on;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   201
            try {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   202
                on = new ObjectName(n);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   203
            } catch (Exception x) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   204
                failed = true;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   205
                System.out.println("Unexpected failure for 6616825 [" + n +
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   206
                        "]: " + x);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   207
                x.printStackTrace(System.out);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   208
                continue;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   209
            }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   210
            try {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   211
                checkName("616825 " + n, on);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   212
            } catch (Exception x) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   213
                failed = true;
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   214
                System.out.println("6616825 failed for [" + n + "]: " + x);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   215
                x.printStackTrace(System.out);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   216
            }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   217
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   218
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   219
        if (failed) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   220
            throw new Exception("Some tests for 6616825 failed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   221
        } else {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   222
            System.out.println("All tests for 6616825 passed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   223
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   224
    }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   225
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   226
    public static void main(String[] args) throws Exception {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   227
        /* Check that we really are in jmx.serial.form=1.0 mode.
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   228
        The property is frozen the first time the ObjectName class
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   229
        is referenced so checking that it is set to the correct
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   230
        value now is not enough.  */
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   231
        ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectName.class);
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   232
        if (osc.getFields().length != 6) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   233
            throw new Exception("Not using old serial form: fields: " +
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   234
                    Arrays.asList(osc.getFields()));
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   235
        // new serial form has no fields, uses writeObject
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   236
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   237
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   238
        try {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   239
            check6211220();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   240
        } catch (Exception x) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   241
            System.err.println(x.getMessage());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   242
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   243
        try {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   244
            check6616825();
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   245
        } catch (Exception x) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   246
            System.err.println(x.getMessage());
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   247
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   248
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   249
        if (failed) {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   250
            throw new Exception("Some tests failed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   251
        } else {
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   252
            System.out.println("All tests passed");
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   253
        }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   254
    }
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   255
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   256
    private static void check(String msg, boolean condition) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if (!condition) {
1005
1a39b4e3f2fc 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject()
dfuchs
parents: 2
diff changeset
   258
            new Throwable("Test failed " + msg).printStackTrace(System.out);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            failed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    private static boolean failed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}