test/jdk/javax/management/mxbean/MerlinMXBean.java
author lfoltan
Tue, 20 Feb 2018 07:46:40 -0500
changeset 49026 844bf1deff1a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8196884: VS2017 Multiple Type Cast Conversion Compilation Errors Summary: Change the type of symbolic constant badAddressVal and introduce specific casts to fix multiple type cast conversion compilation errors. Reviewed-by: coleenp, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2005, 2006, 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: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
import javax.management.openmbean.ArrayType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.management.openmbean.CompositeDataSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.management.openmbean.CompositeDataView;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.management.openmbean.CompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.management.openmbean.OpenDataException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.management.openmbean.OpenType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.management.openmbean.SimpleType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
public interface MerlinMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    int PInt = 59;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    SimpleType PIntType = SimpleType.INTEGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    int getPInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    void setPInt(int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    int opPInt(int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    long PLong = Long.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    SimpleType PLongType = SimpleType.LONG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    long getPLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    void setPLong(long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    long opPLong(long x, long y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    short PShort = 55;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    SimpleType PShortType = SimpleType.SHORT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    short getPShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    void setPShort(short x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    short opPShort(short x, short y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    byte PByte = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    SimpleType PByteType = SimpleType.BYTE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    byte getPByte();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    void setPByte(byte x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    byte opPByte(byte x, byte y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    char PChar = 'x';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    SimpleType PCharType = SimpleType.CHARACTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    char getPChar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    void setPChar(char x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    char opPChar(char x, char y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    float PFloat = 1.3f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    SimpleType PFloatType = SimpleType.FLOAT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    float getPFloat();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    void setPFloat(float x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    float opPFloat(float x, float y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    double PDouble = Double.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    SimpleType PDoubleType = SimpleType.DOUBLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    double getPDouble();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    void setPDouble(double x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    double opPDouble(double x, double y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    boolean PBoolean = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    SimpleType PBooleanType = SimpleType.BOOLEAN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    boolean getPBoolean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    void setPBoolean(boolean x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    boolean opPBoolean(boolean x, boolean y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    Integer WInteger = new Integer(59);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    SimpleType WIntegerType = SimpleType.INTEGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    Integer getWInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    void setWInteger(Integer x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    Integer opWInteger(Integer x, Integer y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    Long WLong = new Long(Long.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    SimpleType WLongType = SimpleType.LONG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    Long getWLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    void setWLong(Long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    Long opWLong(Long x, Long y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    Short WShort = new Short(Short.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    SimpleType WShortType = SimpleType.SHORT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    Short getWShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    void setWShort(Short x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    Short opWShort(Short x, Short y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    Byte WByte = new Byte(Byte.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    SimpleType WByteType = SimpleType.BYTE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    Byte getWByte();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    void setWByte(Byte x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    Byte opWByte(Byte x, Byte y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    Character WCharacter = new Character('x');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    SimpleType WCharacterType = SimpleType.CHARACTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    Character getWCharacter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    void setWCharacter(Character x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    Character opWCharacter(Character x, Character y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    Float WFloat = new Float(1.3f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    SimpleType WFloatType = SimpleType.FLOAT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    Float getWFloat();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    void setWFloat(Float x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    Float opWFloat(Float x, Float y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    Double WDouble = new Double(Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    SimpleType WDoubleType = SimpleType.DOUBLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    Double getWDouble();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    void setWDouble(Double x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    Double opWDouble(Double x, Double y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    Boolean WBoolean = Boolean.TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    SimpleType WBooleanType = SimpleType.BOOLEAN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    Boolean getWBoolean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    void setWBoolean(Boolean x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    Boolean opWBoolean(Boolean x, Boolean y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    int[] PIntA = {2, 3, 5, 7, 11, 13};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    ArrayType PIntAType = ArrayTypeMaker.make(SimpleType.INTEGER, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    int[] getPIntA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    void setPIntA(int[] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    int[] opPIntA(int[] x, int[] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    int[][] PInt2D = {{1, 2}, {3, 4}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    ArrayType PInt2DType = ArrayTypeMaker.make(1, PIntAType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    int[][] getPInt2D();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    void setPInt2D(int[][] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    int[][] opPInt2D(int[][] x, int[][] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    Integer[] WIntA = {new Integer(3), new Integer(5)};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    ArrayType WIntAType = ArrayTypeMaker.make(1, SimpleType.INTEGER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    Integer[] getWIntA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    void setWIntA(Integer[] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    Integer[] opWIntA(Integer[] x, Integer[] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    Integer[][] WInt2D = {{new Integer(3)}, {new Integer(5)}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    ArrayType WInt2DType = ArrayTypeMaker.make(2, SimpleType.INTEGER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    Integer[][] getWInt2D();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    void setWInt2D(Integer[][] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    Integer[][] opWInt2D(Integer[][] x, Integer[][] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    String XString = "yo!";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    SimpleType XStringType = SimpleType.STRING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    String getXString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    void setXString(String x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    String opXString(String x, String y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    String[] XStringA = {"hello", "world"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    ArrayType XStringAType = ArrayTypeMaker.make(1, SimpleType.STRING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    String[] getXStringA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    void setXStringA(String[] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    String[] opXStringA(String[] x, String[] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    int[] NoInts = {};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    ArrayType NoIntsType = ArrayTypeMaker.make(SimpleType.INTEGER, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    int[] getNoInts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    void setNoInts(int[] x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    int[] opNoInts(int[] x, int[] y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    GetSetBean GetSet = GetSetBean.make(5, "x", new String[] {"a", "b"});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    CompositeType GetSetType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        CompositeTypeMaker.make(GetSetBean.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                GetSetBean.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                                new String[] {"int", "string", "stringArray"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                new String[] {"int", "string", "stringArray"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                new OpenType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                                    SimpleType.INTEGER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                                    SimpleType.STRING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                                    ArrayTypeMaker.make(1, SimpleType.STRING),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    GetSetBean getGetSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    void setGetSet(GetSetBean bean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    GetSetBean opGetSet(GetSetBean x, GetSetBean y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    GetterInterface Interface = new GetterInterface() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        public boolean isWhatsit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        public int[] getInts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return new int[] {1};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        public String[] getStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            return new String[] {"x"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        public GetSetBean getGetSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            return GetSetBean.make(3, "a", new String[] {"b"});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (!(o instanceof GetterInterface))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            GetterInterface i = (GetterInterface) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return isWhatsit() == i.isWhatsit() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                   Arrays.equals(getInts(), i.getInts()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                   Arrays.equals(getStrings(), i.getStrings()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                   getGetSet().equals(i.getGetSet());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     CompositeType InterfaceType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        CompositeTypeMaker.make(GetterInterface.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                GetterInterface.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                    "ints", "getSet", "strings", "whatsit",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                    "ints", "getSet", "strings", "whatsit",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                new OpenType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                    ArrayTypeMaker.make(SimpleType.INTEGER, true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                    GetSetType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                    ArrayTypeMaker.make(1, SimpleType.STRING),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                                    SimpleType.BOOLEAN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     GetterInterface getInterface();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     void setInterface(GetterInterface i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     GetterInterface opInterface(GetterInterface x, GetterInterface y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /* Testing that we can use a public no-arg constructor plus a setter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * for every getter to reconstruct this object.  Note that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * constructor-guessing logic is no longer valid for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * so if we can reconstruct it it must be because of the setters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public static class GetSetBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        public GetSetBean() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            this(0, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        private GetSetBean(int Int, String string, String[] stringArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            this.Int = Int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            this.string = string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            this.stringArray = stringArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        public static GetSetBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                make(int Int, String string, String[] stringArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            GetSetBean b = new GetSetBean(Int, string, stringArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        public int getInt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            return Int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        public String getString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            return this.string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        public String[] getStringArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            return this.stringArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        public void setInt(int x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            this.Int = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        public void setString(String string) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            this.string = string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        public void setStringArray(String[] stringArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            this.stringArray = stringArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            if (!(o instanceof GetSetBean))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            GetSetBean b = (GetSetBean) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return (b.Int == Int &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    b.string.equals(string) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    Arrays.equals(b.stringArray, stringArray));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        String string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        String[] stringArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        int Int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public static interface GetterInterface {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        public String[] getStrings();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        public int[] getInts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        public boolean isWhatsit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        public GetSetBean getGetSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        // We uselessly mention the public methods inherited from Object because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        // they should not prevent the interface from being translatable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        // We could consider encoding the result of hashCode() and toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        // on the original object that implements this interface into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        // generated CompositeData and referencing that in the proxy, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        // that seems ambitious for now.  Doing it only if hashCode() and/or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        // toString() are mentioned in the interface is a possibility but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        // a rather abstruse one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        public boolean equals(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        public int hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        public String toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public static class ArrayTypeMaker {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        static ArrayType make(int dims, OpenType baseType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                return new ArrayType(dims, baseType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                throw new Error(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        static ArrayType make(SimpleType baseType, boolean primitiveArray) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                return new ArrayType(baseType, primitiveArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                throw new Error(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    public static class CompositeTypeMaker {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        static CompositeType make(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                  String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                                  String[] itemNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                                  String[] itemDescriptions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                                  OpenType[] itemTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                return new CompositeType(className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                         description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                         itemNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                         itemDescriptions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                         itemTypes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                throw new Error(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public static interface GraphMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        public NodeMXBean[] getNodes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public static class Graph implements GraphMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        public Graph(Node... nodes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            for (Node node : nodes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                node.setGraph(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            this.nodes = nodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        public NodeMXBean[] getNodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            return nodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        private final Node[] nodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public static interface NodeMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        public String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        public GraphMXBean getGraph();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public static class Node implements NodeMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        public Node(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        public GraphMXBean getGraph() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            return graph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        public void setGraph(Graph graph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            this.graph = graph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        private final String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        private Graph graph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    SimpleType GraphType = SimpleType.OBJECTNAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    GraphMXBean getGraph();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    void setGraph(GraphMXBean g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    GraphMXBean opGraph(GraphMXBean x, GraphMXBean y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    String GraphObjectName = "test:type=GraphMXBean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    String NodeAObjectName = "test:type=NodeMXBean,name=a";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    String NodeBObjectName = "test:type=NodeMXBean,name=b";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    Node NodeA = new Node("a");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    Node NodeB = new Node("b");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    GraphMXBean Graph = new Graph(NodeA, NodeB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public static class ExoticCompositeData implements CompositeDataView {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        private ExoticCompositeData(String whatsit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            this.whatsit = whatsit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        public static ExoticCompositeData from(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            String whatsit = (String) cd.get("whatsit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            if (!whatsit.startsWith("!"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                throw new IllegalArgumentException(whatsit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            return new ExoticCompositeData(whatsit.substring(1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        public CompositeData toCompositeData(CompositeType ct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                return new CompositeDataSupport(ct, new String[] {"whatsit"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                                new String[] {"!" + whatsit});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                throw new RuntimeException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        public String getWhatsit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            return whatsit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            return ((o instanceof ExoticCompositeData) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    ((ExoticCompositeData) o).whatsit.equals(whatsit));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        private final String whatsit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        public static final CompositeType type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                type =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    new CompositeType(ExoticCompositeData.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                      ExoticCompositeData.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                      new String[] {"whatsit"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                      new String[] {"whatsit"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                      new OpenType[] {SimpleType.STRING});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                throw new RuntimeException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    CompositeType ExoticType = ExoticCompositeData.type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    ExoticCompositeData getExotic();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    void setExotic(ExoticCompositeData ecd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    ExoticCompositeData opExotic(ExoticCompositeData ecd1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                 ExoticCompositeData ecd2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    ExoticCompositeData Exotic = new ExoticCompositeData("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
}