jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java
author joehw
Sun, 13 Aug 2017 21:10:40 -0700
changeset 46174 5611d2529b49
parent 44797 8b3b3b911b8a
permissions -rw-r--r--
8163121: BCEL: update to the latest 6.0 release Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     4
/*
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     5
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * the License.  You may obtain a copy of the License at
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    17
 * See the License for the specific language governing permissions and
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    18
 * limitations under the License.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    19
 */
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    20
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.bcel.internal.classfile;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    23
import java.io.DataInput;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    24
import java.io.DataOutputStream;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    25
import java.io.IOException;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    27
import com.sun.org.apache.bcel.internal.Const;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 * This class represents an entry in the exception table of the <em>Code</em>
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * attribute and is used only there. It contains a range in which a
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * particular exception handler is active.
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 *
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    34
 * @version $Id: CodeException.java 1749603 2016-06-21 20:50:19Z ggregory $
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * @see     Code
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 */
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    37
public final class CodeException implements Cloneable, Node {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    38
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    39
    private int start_pc; // Range in the code the exception handler is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    40
    private int end_pc; // active. start_pc is inclusive, end_pc exclusive
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    41
    private int handler_pc; /* Starting address of exception handler, i.e.,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    42
     * an offset from start of code.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    43
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    44
    private int catch_type; /* If this is zero the handler catches any
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    45
     * exception, otherwise it points to the
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    46
     * exception class which is to be caught.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    47
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    48
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    50
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    51
     * Initialize from another object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    52
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    53
    public CodeException(final CodeException c) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    54
        this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    55
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    56
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    57
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    58
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    59
     * Construct object from file stream.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    60
     * @param file Input stream
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    61
     * @throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    62
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    63
    CodeException(final DataInput file) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    64
        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    65
                .readUnsignedShort());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    66
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    67
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    69
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    70
     * @param start_pc Range in the code the exception handler is active,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    71
     * start_pc is inclusive while
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    72
     * @param end_pc is exclusive
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    73
     * @param handler_pc Starting address of exception handler, i.e.,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    74
     * an offset from start of code.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    75
     * @param catch_type If zero the handler catches any
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    76
     * exception, otherwise it points to the exception class which is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    77
     * to be caught.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    78
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    79
    public CodeException(final int start_pc, final int end_pc, final int handler_pc, final int catch_type) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    80
        this.start_pc = start_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    81
        this.end_pc = end_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    82
        this.handler_pc = handler_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    83
        this.catch_type = catch_type;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    84
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    85
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    87
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    88
     * Called by objects that are traversing the nodes of the tree implicitely
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    89
     * defined by the contents of a Java class. I.e., the hierarchy of methods,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    90
     * fields, attributes, etc. spawns a tree of objects.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    91
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    92
     * @param v Visitor object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    93
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    94
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    95
    public void accept( final Visitor v ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    96
        v.visitCodeException(this);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    97
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    98
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   100
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   101
     * Dump code exception to file stream in binary format.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   102
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   103
     * @param file Output file stream
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   104
     * @throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   105
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   106
    public final void dump( final DataOutputStream file ) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   107
        file.writeShort(start_pc);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   108
        file.writeShort(end_pc);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   109
        file.writeShort(handler_pc);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   110
        file.writeShort(catch_type);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   111
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   112
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   113
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   114
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   115
     * @return 0, if the handler catches any exception, otherwise it points to
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   116
     * the exception class which is to be caught.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   117
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   118
    public final int getCatchType() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   119
        return catch_type;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   120
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   121
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   123
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   124
     * @return Exclusive end index of the region where the handler is active.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   125
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   126
    public final int getEndPC() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   127
        return end_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   128
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   129
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   131
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   132
     * @return Starting address of exception handler, relative to the code.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   133
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   134
    public final int getHandlerPC() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   135
        return handler_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   136
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   137
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   139
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   140
     * @return Inclusive start index of the region where the handler is active.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   141
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   142
    public final int getStartPC() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   143
        return start_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   144
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   145
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   147
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   148
     * @param catch_type the type of exception that is caught
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   149
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   150
    public final void setCatchType( final int catch_type ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   151
        this.catch_type = catch_type;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   152
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   153
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   155
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   156
     * @param end_pc end of handled block
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   157
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   158
    public final void setEndPC( final int end_pc ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   159
        this.end_pc = end_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   160
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   161
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   163
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   164
     * @param handler_pc where the actual code is
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   165
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   166
    public final void setHandlerPC( final int handler_pc ) { // TODO unused
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   167
        this.handler_pc = handler_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   168
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   169
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   171
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   172
     * @param start_pc start of handled block
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   173
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   174
    public final void setStartPC( final int start_pc ) { // TODO unused
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   175
        this.start_pc = start_pc;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   176
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   177
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   179
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   180
     * @return String representation.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   181
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   182
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   183
    public final String toString() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   184
        return "CodeException(start_pc = " + start_pc + ", end_pc = " + end_pc + ", handler_pc = "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   185
                + handler_pc + ", catch_type = " + catch_type + ")";
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   186
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   189
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   190
     * @return String representation.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   191
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   192
    public final String toString( final ConstantPool cp, final boolean verbose ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   193
        String str;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   194
        if (catch_type == 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   195
            str = "<Any exception>(0)";
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   196
        } else {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   197
            str = Utility.compactClassName(cp.getConstantString(catch_type, Const.CONSTANT_Class), false)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   198
                    + (verbose ? "(" + catch_type + ")" : "");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   199
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   200
        return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   201
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   204
    public final String toString( final ConstantPool cp ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   205
        return toString(cp, true);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   206
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   207
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   209
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   210
     * @return deep copy of this object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   211
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   212
    public CodeException copy() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   213
        try {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   214
            return (CodeException) clone();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   215
        } catch (final CloneNotSupportedException e) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   216
            // TODO should this throw?
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   217
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   218
        return null;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   219
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
}