test/jdk/com/sun/jdi/ConstantPoolInfo.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 44423 jdk/test/com/sun/jdi/ConstantPoolInfo.java@306c020eb154
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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: 24973
diff changeset
     2
 * Copyright (c) 2005, 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: 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
/**
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    25
 * @test
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    26
 * @bug 5024104
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    27
 * @summary Test ReferenceType.majorVersion(), minorVersion, constantPoolCount and ConstantPool apis.
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    28
 * @author Swamy Venkataramanappa
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    30
 * @run build TestScaffold VMConnection
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    31
 * @run compile -g ConstantPoolInfo.java
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    32
 * @run driver ConstantPoolInfo
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /********** target program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class ConstantPoolTarg {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    public static void main(String[] args){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        System.out.println("Howdy!"); // don't change the string value "Howdy!" it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                      // used to test the constant pool entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /********** test program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public class ConstantPoolInfo extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    ThreadReference mainThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    int cpool_count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    byte[] cpbytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static int expectedMajorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static int expectedMinorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static int expectedCpoolCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /* Class File Constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public static final int JAVA_MAGIC                   = 0xcafebabe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /* Constant table :  copied from sun/javap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final int CONSTANT_UTF8                = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public static final int CONSTANT_UNICODE             = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public static final int CONSTANT_INTEGER             = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public static final int CONSTANT_FLOAT               = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static final int CONSTANT_LONG                = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final int CONSTANT_DOUBLE              = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static final int CONSTANT_CLASS               = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public static final int CONSTANT_STRING              = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final int CONSTANT_FIELD               = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static final int CONSTANT_METHOD              = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public static final int CONSTANT_INTERFACEMETHOD     = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public static final int CONSTANT_NAMEANDTYPE         = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    ConstantPoolInfo (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static void main(String[] args)      throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        new ConstantPoolInfo(args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    protected void runTests() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * Get to the top of main()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         * to determine targetClass and mainThread
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        BreakpointEvent bpe = startToMain("ConstantPoolTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        mainThread = bpe.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        String targPathname = System.getProperty("test.classes") + File.separator + "ConstantPoolTarg.class";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        readClassData(new FileInputStream(targPathname));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        /* Test constant pool apis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (vm().canGetClassFileVersion()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (expectedMajorVersion != targetClass.majorVersion()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                failure("unexpected major version: actual value: " + targetClass.majorVersion()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                        + "expected value :" + expectedMajorVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            if (expectedMinorVersion != targetClass.minorVersion()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                failure("unexpected minor version: actual value: " + targetClass.minorVersion()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                        + "expected value :" + expectedMinorVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            System.out.println("can get class version not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (vm().canGetConstantPool()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            cpool_count = targetClass.constantPoolCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            cpbytes = targetClass.constantPool();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                printcp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            } catch (IOException x){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                System.out.println("IOexception reading cpool bytes " + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            if (expectedCpoolCount != cpool_count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                failure("unexpected constant pool count: actual value: " + cpool_count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                        + "expected value :" + expectedCpoolCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            System.out.println("can get constant pool version not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
         * resume until end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        listenUntilVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
         * deal with results of test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         * if anything has called failure("foo") testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            println("ConstantPoolInfo: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            throw new Exception("ConstantPoolInfo: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void printcp() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        ByteArrayInputStream bytesStream = new ByteArrayInputStream(cpbytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        DataInputStream in = new DataInputStream(bytesStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        for (int i = 1; i < cpool_count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            int tag = in.readByte();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            System.out.print("const #" + i + ":   ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            switch(tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    case CONSTANT_UTF8:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    String str=in.readUTF();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    System.out.println("Asciz " + str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    // "Howdy!" is an expected constant pool entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    // of test program. It should exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    if (str.compareTo("Howdy!") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                        found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                case CONSTANT_INTEGER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    System.out.println("int " + in.readInt());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                case CONSTANT_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                    System.out.println("Float " + in.readFloat());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                case CONSTANT_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    System.out.println("Long " + in.readLong());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                case CONSTANT_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    System.out.println("Double " + in.readDouble());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                case CONSTANT_CLASS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    System.out.println("Class " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                case CONSTANT_STRING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    System.out.println("String " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                case CONSTANT_FIELD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    System.out.println("Field " + in.readUnsignedShort() + " " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                case CONSTANT_METHOD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    System.out.println("Method " + in.readUnsignedShort() + " " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                case CONSTANT_INTERFACEMETHOD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    System.out.println("InterfaceMethod " + in.readUnsignedShort() + " " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                case CONSTANT_NAMEANDTYPE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    System.out.println("NameAndType " + in.readUnsignedShort() + " " + in.readUnsignedShort());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    System.out.println("class format error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            failure("expected string \"Howdy!\" not found in constant pool");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Read classfile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    void readClassData(InputStream infile){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        try{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            this.read(new DataInputStream(infile));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }catch (FileNotFoundException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            failure("cant read file");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }catch (Error ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            ee.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            failure("fatal error");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        } catch (Exception ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            ee.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            failure("fatal exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
         * Read major, minor and cp count.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public void read(DataInputStream in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        int magic = in.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (magic != JAVA_MAGIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            failure("fatal bad class file format");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        expectedMinorVersion = in.readShort();;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        expectedMajorVersion = in.readShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        expectedCpoolCount = in.readUnsignedShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    } // end read()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}