src/java.xml/share/classes/javax/xml/transform/TransformerException.java
author thartmann
Fri, 24 Aug 2018 08:17:23 +0200
changeset 51514 1e332d63bd96
parent 47216 71c04702a3d5
permissions -rw-r--r--
8209833: C2 compilation fails with "assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place" Summary: Deoptimize if exception is thrown in _clone intrinsic. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
     2
 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    10
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * accompanied this code).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
 * questions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
package javax.xml.transform;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    28
import java.lang.reflect.Method;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    29
import java.lang.reflect.InvocationTargetException;
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    30
import java.security.AccessControlContext;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    31
import java.security.AccessController;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    32
import java.security.CodeSigner;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    33
import java.security.CodeSource;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    34
import java.security.PermissionCollection;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    35
import java.security.Permissions;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    36
import java.security.PrivilegedAction;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    37
import java.security.ProtectionDomain;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    38
import java.util.Objects;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
/**
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    41
 * This class specifies an exceptional condition that occurred
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
 * during the transformation process.
25262
1fe892ba017a 8047723: @since tag cleanup in jaxp
henryjen
parents: 12457
diff changeset
    43
 *
1fe892ba017a 8047723: @since tag cleanup in jaxp
henryjen
parents: 12457
diff changeset
    44
 * @since 1.4
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
public class TransformerException extends Exception {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
46006
20a06a196ed5 8176731: JCK tests in api/javax_xml/transform/ spec conformance started failing after 8172469
aefimov
parents: 46005
diff changeset
    48
    private static final long serialVersionUID = 975798773772956428L;
20a06a196ed5 8176731: JCK tests in api/javax_xml/transform/ spec conformance started failing after 8172469
aefimov
parents: 46005
diff changeset
    49
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    50
    /** Field locator specifies where the error occurred */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
    SourceLocator locator;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    54
     * Method getLocator retrieves an instance of a SourceLocator
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    55
     * object that specifies where an error occurred.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
     * @return A SourceLocator object, or null if none was specified.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    58
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
    public SourceLocator getLocator() {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    60
        return this.locator;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    63
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
     * Method setLocator sets an instance of a SourceLocator
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    65
     * object that specifies where an error occurred.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    66
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
     * @param location A SourceLocator object, or null to clear the location.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
    public void setLocator(SourceLocator location) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    70
        this.locator = location;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
    /** Field containedException specifies a wrapped exception.  May be null. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
    Throwable containedException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    75
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
     * This method retrieves an exception that this exception wraps.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
     * @return An Throwable object, or null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
     * @see #getCause
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
    public Throwable getException() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
        return containedException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
     * Returns the cause of this throwable or <code>null</code> if the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
     * cause is nonexistent or unknown.  (The cause is the throwable that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
     * caused this throwable to get thrown.)
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    90
     * @return the cause, or null if unknown
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    91
     */
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
    92
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
    public Throwable getCause() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
        return ((containedException == this)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    96
                ? null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    97
                : containedException);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
     * Initializes the <i>cause</i> of this throwable to the specified value.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
     * (The cause is the throwable that caused this throwable to get thrown.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
     * <p>This method can be called at most once.  It is generally called from
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
     * within the constructor, or immediately after creating the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
     * throwable.  If this throwable was created
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
     * with {@link #TransformerException(Throwable)} or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   108
     * {@link #TransformerException(String,Throwable)}, this method cannot be called
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   109
     * even once.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   110
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
     * @param  cause the cause (which is saved for later retrieval by the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
     *         {@link #getCause()} method).  (A <code>null</code> value is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
     *         permitted, and indicates that the cause is nonexistent or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
     *         unknown.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
     * @return  a reference to this <code>Throwable</code> instance.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
     * @throws IllegalArgumentException if <code>cause</code> is this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
     *         throwable.  (A throwable cannot
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
     *         be its own cause.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
     * @throws IllegalStateException if this throwable was
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
     *         created with {@link #TransformerException(Throwable)} or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
     *         {@link #TransformerException(String,Throwable)}, or this method has already
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
     *         been called on this throwable.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
     */
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   124
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
    public synchronized Throwable initCause(Throwable cause) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   127
        // TransformerException doesn't set its cause (probably
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   128
        // because it predates initCause()) - and we may not want
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   129
        // to change this since Exceptions are serializable...
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   130
        // But this also leads to the broken code in printStackTrace
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   131
        // below...
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   132
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
        if (this.containedException != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   134
            throw new IllegalStateException("Can't overwrite cause");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   135
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   136
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
        if (cause == this) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
            throw new IllegalArgumentException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
                "Self-causation not permitted");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
        this.containedException = cause;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   143
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
        return this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   146
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
     * Create a new TransformerException.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
     * @param message The error or warning message.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
    public TransformerException(String message) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   153
        this(message, null, null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
     * Create a new TransformerException wrapping an existing exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     * @param e The exception to be wrapped.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
    public TransformerException(Throwable e) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   162
        this(null, null, e);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   164
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
     * Wrap an existing exception in a TransformerException.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
     * <p>This is used for throwing processor exceptions before
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
     * the processing has started.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
     * @param message The error or warning message, or null to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
     *                use the message from the embedded exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
     * @param e Any exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
    public TransformerException(String message, Throwable e) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   176
        this(message, null, e);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
     * Create a new TransformerException from a message and a Locator.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
     * <p>This constructor is especially useful when an application is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
     * creating its own exception from within a DocumentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
     * callback.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
     * @param message The error or warning message.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
     * @param locator The locator object for the error or warning.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
    public TransformerException(String message, SourceLocator locator) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   190
        this(message, locator, null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
     * Wrap an existing exception in a TransformerException.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
     * @param message The error or warning message, or null to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
     *                use the message from the embedded exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
     * @param locator The locator object for the error or warning.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
     * @param e Any exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   201
    public TransformerException(String message, SourceLocator locator,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
                                Throwable e) {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   203
        super(((message == null) || (message.length() == 0))
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   204
              ? ((e == null) ? "" : e.toString())
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   205
              : message);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
        this.containedException = e;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
        this.locator            = locator;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
     * Get the error message with location information
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
     * appended.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
     * @return A <code>String</code> representing the error message with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
     *         location information appended.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   217
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
    public String getMessageAndLocation() {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   219
        StringBuilder sbuffer = new StringBuilder();
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   220
        sbuffer.append(Objects.toString(super.getMessage(), ""));
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   221
        sbuffer.append(Objects.toString(getLocationAsString(), ""));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
        return sbuffer.toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   225
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   226
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   227
     * Get the location information as a string.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   228
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   229
     * @return A string with location info, or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
     * if there is no location information.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
    public String getLocationAsString() {
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   233
        if (locator == null) {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   234
            return null;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   235
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   236
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   237
        if (System.getSecurityManager() == null) {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   238
            return getLocationString();
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   239
        } else {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   240
            return AccessController.doPrivileged((PrivilegedAction<String>) () ->
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   241
                getLocationString(),
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   242
                new AccessControlContext(new ProtectionDomain[] {getNonPrivDomain()}));
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   243
        }
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   244
    }
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   245
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   246
    /**
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   247
     * Constructs the location string.
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   248
     * @return the location string
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   249
     */
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   250
    private String getLocationString() {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   251
        if (locator == null) {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   252
            return null;
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   253
        }
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   254
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   255
        StringBuilder sbuffer  = new StringBuilder();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   256
            String       systemID = locator.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   257
            int          line     = locator.getLineNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   258
            int          column   = locator.getColumnNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   259
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   260
            if (null != systemID) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   261
                sbuffer.append("; SystemID: ");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   262
                sbuffer.append(systemID);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   263
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   264
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   265
            if (0 != line) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   266
                sbuffer.append("; Line#: ");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   267
                sbuffer.append(line);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   268
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   269
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   270
            if (0 != column) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   271
                sbuffer.append("; Column#: ");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   272
                sbuffer.append(column);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   273
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   274
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   275
            return sbuffer.toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   276
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   277
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   278
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   279
     * Print the the trace of methods from where the error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   280
     * originated.  This will trace all nested exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   281
     * objects, as well as this object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   282
     */
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   283
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   284
    public void printStackTrace() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   285
        printStackTrace(new java.io.PrintWriter(System.err, true));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   286
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   287
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
     * Print the the trace of methods from where the error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   290
     * originated.  This will trace all nested exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
     * objects, as well as this object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
     * @param s The stream where the dump will be sent to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
     */
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   294
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
    public void printStackTrace(java.io.PrintStream s) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
        printStackTrace(new java.io.PrintWriter(s));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   298
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   300
     * Print the the trace of methods from where the error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   301
     * originated.  This will trace all nested exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
     * objects, as well as this object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
     * @param s The writer where the dump will be sent to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
     */
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   305
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
    public void printStackTrace(java.io.PrintWriter s) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   307
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
        if (s == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   309
            s = new java.io.PrintWriter(System.err, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   311
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   312
        try {
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   313
            try {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   314
                String locInfo = getLocationAsString();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   316
                if (null != locInfo) {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   317
                    s.println(locInfo);
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   318
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   320
                super.printStackTrace(s);
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   321
            } catch (Throwable e) {}
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   323
            Throwable exception = getException();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   325
            for (int i = 0; (i < 10) && (null != exception); i++) {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   326
                s.println("---------");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   327
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   328
                try {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   329
                    exception.printStackTrace(s);
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   330
                    // if exception is a TransformerException it will print
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   331
                    // its contained exception, so we don't need to redo it here,
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   332
                    // and we can exit the loop now.
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   333
                    if (exception instanceof TransformerException) break;
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   334
                } catch (Throwable e) {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   335
                    s.println("Could not print stack trace...");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   336
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   337
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   338
                try {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   339
                    // Is this still needed?
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   340
                    Method meth = exception.getClass().getMethod("getException");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   341
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   342
                    if (null != meth) {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   343
                        Throwable prev = exception;
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   344
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   345
                        exception = (Throwable) meth.invoke(exception, (Object[]) null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   346
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   347
                        if (prev == exception) {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   348
                            break;
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   349
                        }
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   350
                    } else {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   351
                        exception = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   352
                    }
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   353
                } catch (InvocationTargetException | IllegalAccessException
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   354
                        | NoSuchMethodException e) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   355
                    exception = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   356
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   357
            }
31497
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   358
        } finally {
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   359
            // ensure output is written
4a6b2e733c0d 8130051: Cleanup usage of reflection in jaxp
dfuchs
parents: 25868
diff changeset
   360
            s.flush();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   361
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   362
    }
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   363
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   364
    /**
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   365
     * Creates a ProtectionDomain that has no permission.
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   366
     * @return a ProtectionDomain
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   367
     */
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   368
    private ProtectionDomain getNonPrivDomain() {
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   369
        CodeSource nullSource = new CodeSource(null, (CodeSigner[]) null);
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   370
        PermissionCollection noPermission = new Permissions();
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   371
        return new ProtectionDomain(nullSource, noPermission);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   372
}
46005
49e2e73f90f6 8172469: Transform Transformer Exceptions
joehw
parents: 31497
diff changeset
   373
}