diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b6985c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..217b724 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("com.android.library") version "8.3.0-alpha05" apply false + id("org.jetbrains.kotlin.android") version "1.9.20-Beta2" apply false +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..09fbdf4 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,5 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +org.gradle.parallel=true +org.gradle.caching=true + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7f93135 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ac72c34 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..0adc8e1 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jaxp/build.gradle.kts b/jaxp/build.gradle.kts new file mode 100644 index 0000000..ce0acf2 --- /dev/null +++ b/jaxp/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * This file is part of Cosmic IDE. + * Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see . + */ + +plugins { + id("java-library") + id("maven-publish") +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +publishing { + publications { + create("maven") { + groupId = "org.cosmic.ide" + artifactId = "jaxp" + version = "jdk17u-a831b7a" + + from(components["java"]) + } + } +} diff --git a/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java new file mode 100644 index 0000000..a390688 --- /dev/null +++ b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Scanner.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java_cup.internal.runtime; + +/** + * Defines the Scanner interface, which CUP uses in the default + * implementation of lr_parser.scan(). Integration + * of scanners implementing Scanner is facilitated. + * + * @author David MacMahon + */ + +/* ************************************************* + Interface Scanner + + Declares the next_token() method that should be + implemented by scanners. This method is typically + called by lr_parser.scan(). + ***************************************************/ +public interface Scanner { + public Symbol next_token() throws java.lang.Exception; +} diff --git a/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java new file mode 100644 index 0000000..73cae31 --- /dev/null +++ b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/Symbol.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java_cup.internal.runtime; + +/** + * Defines the Symbol class, which is used to represent all terminals + * and nonterminals while parsing. The lexer should pass CUP Symbols + * and CUP returns a Symbol. + * + * @author Frank Flannery + */ + +/* **************************************************************** + Class Symbol + what the parser expects to receive from the lexer. + the token is identified as follows: + sym: the symbol type + parse_state: the parse state. + value: is the lexical value of type Object + left : is the left position in the original input file + right: is the right position in the original input file +******************************************************************/ + +public class Symbol { + + /******************************* + Constructor for l,r values + *******************************/ + + public Symbol(int id, int l, int r, Object o) { + this(id); + left = l; + right = r; + value = o; + } + + /******************************* + Constructor for no l,r values + ********************************/ + + public Symbol(int id, Object o) { + this(id); + left = -1; + right = -1; + value = o; + } + + /***************************** + Constructor for no value + ***************************/ + + public Symbol(int sym_num, int l, int r) { + sym = sym_num; + left = l; + right = r; + value = null; + } + + /*********************************** + Constructor for no value or l,r + ***********************************/ + + public Symbol(int sym_num) { + this(sym_num, -1); + left = -1; + right = -1; + value = null; + } + + /*********************************** + Constructor to give a start state + ***********************************/ + public Symbol(int sym_num, int state) { + sym = sym_num; + parse_state = state; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The symbol number of the terminal or non terminal being represented + */ + public int sym; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The parse state to be recorded on the parse stack with this symbol. + * This field is for the convenience of the parser and shouldn't be + * modified except by the parser. + */ + public int parse_state; + /** + * This allows us to catch some errors caused by scanners recycling + * symbols. For the use of the parser only. [CSA, 23-Jul-1999] + */ + boolean used_by_parser = false; + + /******************************* + The data passed to parser + *******************************/ + + public int left, right; + public Object value; + + /***************************** + Printing this token out. (Override for pretty-print). + ****************************/ + public String toString() { + return "#" + sym; + } +} diff --git a/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java new file mode 100644 index 0000000..6b2b1b3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/lr_parser.java @@ -0,0 +1,1352 @@ +/* + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +package com.sun.java_cup.internal.runtime; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.sym; + +import java.util.Arrays; +import java.util.Stack; + +/** + * This class implements a skeleton table driven LR parser. In general, + * LR parsers are a form of bottom up shift-reduce parsers. Shift-reduce + * parsers act by shifting input onto a parse stack until the Symbols + * matching the right hand side of a production appear on the top of the + * stack. Once this occurs, a reduce is performed. This involves removing + * the Symbols corresponding to the right hand side of the production + * (the so called "handle") and replacing them with the non-terminal from + * the left hand side of the production.

+ *

+ * To control the decision of whether to shift or reduce at any given point, + * the parser uses a state machine (the "viable prefix recognition machine" + * built by the parser generator). The current state of the machine is placed + * on top of the parse stack (stored as part of a Symbol object representing + * a terminal or non terminal). The parse action table is consulted + * (using the current state and the current lookahead Symbol as indexes) to + * determine whether to shift or to reduce. When the parser shifts, it + * changes to a new state by pushing a new Symbol (containing a new state) + * onto the stack. When the parser reduces, it pops the handle (right hand + * side of a production) off the stack. This leaves the parser in the state + * it was in before any of those Symbols were matched. Next the reduce-goto + * table is consulted (using the new state and current lookahead Symbol as + * indexes) to determine a new state to go to. The parser then shifts to + * this goto state by pushing the left hand side Symbol of the production + * (also containing the new state) onto the stack.

+ *

+ * This class actually provides four LR parsers. The methods parse() and + * debug_parse() provide two versions of the main parser (the only difference + * being that debug_parse() emits debugging trace messages as it parses). + * In addition to these main parsers, the error recovery mechanism uses two + * more. One of these is used to simulate "parsing ahead" in the input + * without carrying out actions (to verify that a potential error recovery + * has worked), and the other is used to parse through buffered "parse ahead" + * input in order to execute all actions and re-synchronize the actual parser + * configuration.

+ *

+ * This is an abstract class which is normally filled out by a subclass + * generated by the JavaCup parser generator. In addition to supplying + * the actual parse tables, generated code also supplies methods which + * invoke various pieces of user supplied code, provide access to certain + * special Symbols (e.g., EOF and error), etc. Specifically, the following + * abstract methods are normally supplied by generated code: + *

+ *
short[][] production_table() + *
Provides a reference to the production table (indicating the index of + * the left hand side non terminal and the length of the right hand side + * for each production in the grammar). + *
short[][] action_table() + *
Provides a reference to the parse action table. + *
short[][] reduce_table() + *
Provides a reference to the reduce-goto table. + *
int start_state() + *
Indicates the index of the start state. + *
int start_production() + *
Indicates the index of the starting production. + *
int EOF_sym() + *
Indicates the index of the EOF Symbol. + *
int error_sym() + *
Indicates the index of the error Symbol. + *
Symbol do_action() + *
Executes a piece of user supplied action code. This always comes at + * the point of a reduce in the parse, so this code also allocates and + * fills in the left hand side non terminal Symbol object that is to be + * pushed onto the stack for the reduce. + *
void init_actions() + *
Code to initialize a special object that encapsulates user supplied + * actions (this object is used by do_action() to actually carry out the + * actions). + *
+ *

+ * In addition to these routines that must be supplied by the + * generated subclass there are also a series of routines that may + * be supplied. These include: + *

+ *
Symbol scan() + *
Used to get the next input Symbol from the scanner. + *
Scanner getScanner() + *
Used to provide a scanner for the default implementation of + * scan(). + *
int error_sync_size() + *
This determines how many Symbols past the point of an error + * must be parsed without error in order to consider a recovery to + * be valid. This defaults to 3. Values less than 2 are not + * recommended. + *
void report_error(String message, Object info) + *
This method is called to report an error. The default implementation + * simply prints a message to System.err and where the error occurred. + * This method is often replaced in order to provide a more sophisticated + * error reporting mechanism. + *
void report_fatal_error(String message, Object info) + *
This method is called when a fatal error that cannot be recovered from + * is encountered. In the default implementation, it calls + * report_error() to emit a message, then throws an exception. + *
void syntax_error(Symbol cur_token) + *
This method is called as soon as syntax error is detected (but + * before recovery is attempted). In the default implementation it + * invokes: report_error("Syntax error", null); + *
void unrecovered_syntax_error(Symbol cur_token) + *
This method is called if syntax error recovery fails. In the default + * implementation it invokes:
+ * report_fatal_error("Couldn't repair and continue parse", null); + *
+ * + * @author Frank Flannery + * @LastModified: July 2022 + * @see com.sun.java_cup.internal.runtime.Symbol + * @see com.sun.java_cup.internal.runtime.Symbol + * @see com.sun.java_cup.internal.runtime.virtual_parse_stack + */ + +public abstract class lr_parser { + public static final int ID_GROUP = 1; + public static final int ID_OPERATOR = 2; + public static final int ID_TOTAL_OPERATOR = 3; + + private boolean isLiteral = false; + private int grpCount = 0; + private int opCount = 0; + private int totalOpCount = 0; + private int lastSym; + private boolean overLimit = false; + public int grpLimit = 0; + public int opLimit = 0; + public int totalOpLimit = 0; + + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * Simple constructor. + */ + public lr_parser() { + /* nothing to do here */ + } + + /** + * Constructor that sets the default scanner. [CSA/davidm] + */ + public lr_parser(Scanner s) { + this(); /* in case default constructor someday does something */ + setScanner(s); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Static (Class) Variables ------------------*/ + /*-----------------------------------------------------------*/ + + /** + * The default number of Symbols after an error we much match to consider + * it recovered from. + */ + protected final static int _error_sync_size = 3; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The number of Symbols after an error we much match to consider it + * recovered from. + */ + protected int error_sync_size() { + return _error_sync_size; + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * Table of production information (supplied by generated subclass). + * This table contains one entry per production and is indexed by + * the negative-encoded values (reduce actions) in the action_table. + * Each entry has two parts, the index of the non-terminal on the + * left hand side of the production, and the number of Symbols + * on the right hand side. + */ + public abstract short[][] production_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The action table (supplied by generated subclass). This table is + * indexed by state and terminal number indicating what action is to + * be taken when the parser is in the given state (i.e., the given state + * is on top of the stack) and the given terminal is next on the input. + * States are indexed using the first dimension, however, the entries for + * a given state are compacted and stored in adjacent index, value pairs + * which are searched for rather than accessed directly (see get_action()). + * The actions stored in the table will be either shifts, reduces, or + * errors. Shifts are encoded as positive values (one greater than the + * state shifted to). Reduces are encoded as negative values (one less + * than the production reduced by). Error entries are denoted by zero. + * + * @see com.sun.java_cup.internal.runtime.lr_parser#get_action + */ + public abstract short[][] action_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The reduce-goto table (supplied by generated subclass). This + * table is indexed by state and non-terminal number and contains + * state numbers. States are indexed using the first dimension, however, + * the entries for a given state are compacted and stored in adjacent + * index, value pairs which are searched for rather than accessed + * directly (see get_reduce()). When a reduce occurs, the handle + * (corresponding to the RHS of the matched production) is popped off + * the stack. The new top of stack indicates a state. This table is + * then indexed by that state and the LHS of the reducing production to + * indicate where to "shift" to. + * + * @see com.sun.java_cup.internal.runtime.lr_parser#get_reduce + */ + public abstract short[][] reduce_table(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The index of the start state (supplied by generated subclass). + */ + public abstract int start_state(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The index of the start production (supplied by generated subclass). + */ + public abstract int start_production(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The index of the end of file terminal Symbol (supplied by generated + * subclass). + */ + public abstract int EOF_sym(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The index of the special error Symbol (supplied by generated subclass). + */ + public abstract int error_sym(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Internal flag to indicate when parser should quit. + */ + protected boolean _done_parsing = false; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * This method is called to indicate that the parser should quit. This is + * normally called by an accept action, but can be used to cancel parsing + * early in other circumstances if desired. + */ + public void done_parsing() { + _done_parsing = true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + /* Global parse state shared by parse(), error recovery, and + * debugging routines */ + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Indication of the index for top of stack (for use by actions). + */ + protected int tos; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The current lookahead Symbol. + */ + protected Symbol cur_token; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The parse stack itself. + */ + protected Stack stack = new Stack<>(); + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Direct reference to the production table. + */ + protected short[][] production_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Direct reference to the action table. + */ + protected short[][] action_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Direct reference to the reduce-goto table. + */ + protected short[][] reduce_tab; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * This is the scanner object used by the default implementation + * of scan() to get Symbols. To avoid name conflicts with existing + * code, this field is private. [CSA/davidm] + */ + private Scanner _scanner; + + /** + * Simple accessor method to set the default scanner. + */ + public void setScanner(Scanner s) { + _scanner = s; + } + + /** + * Simple accessor method to get the default scanner. + */ + public Scanner getScanner() { + return _scanner; + } + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * Perform a bit of user supplied action code (supplied by generated + * subclass). Actions are indexed by an internal action number assigned + * at parser generation time. + * + * @param act_num the internal index of the action to be performed. + * @param parser the parser object we are acting for. + * @param stack the parse stack of that object. + * @param top the index of the top element of the parse stack. + */ + public abstract Symbol do_action( + int act_num, + lr_parser parser, + Stack stack, + int top) + throws java.lang.Exception; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * User code for initialization inside the parser. Typically this + * initializes the scanner. This is called before the parser requests + * the first Symbol. Here this is just a placeholder for subclasses that + * might need this and we perform no action. This method is normally + * overridden by the generated code using this contents of the "init with" + * clause as its body. + */ + public void user_init() throws java.lang.Exception { + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Initialize the action object. This is called before the parser does + * any parse actions. This is filled in by generated code to create + * an object that encapsulates all action code. + */ + protected abstract void init_actions() throws java.lang.Exception; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Get the next Symbol from the input (supplied by generated subclass). + * Once end of file has been reached, all subsequent calls to scan + * should return an EOF Symbol (which is Symbol number 0). By default + * this method returns getScanner().next_token(); this implementation + * can be overriden by the generated parser using the code declared in + * the "scan with" clause. Do not recycle objects; every call to + * scan() should return a fresh object. + */ + public Symbol scan() throws Exception { + Symbol s = getScanner().next_token(); + + if (s.sym == sym.LPAREN) { + if (!isLiteral) { + grpCount++; + } + opCount++; // function + totalOpCount++; + isLiteral = false; + } else if (contains(sym.OPERATORS, s.sym)) { + // axis nodetest is counted as one step, so not counted if last=DCOLON + if (lastSym != sym.DCOLON) { + opCount++; + totalOpCount++; + } + isLiteral = false; + } + + if (s.sym == sym.Literal || s.sym == sym.QNAME) { + isLiteral = true; + } + lastSym = s.sym; + + /* + * Sets the overLimit status as soon as the count of operators is over the + * limit, which in turn triggers the XPathParser to report an error. + */ + if (grpLimit > 0 && grpCount > grpLimit + || opLimit > 0 && opCount > opLimit + || totalOpLimit > 0 && totalOpCount > totalOpLimit) { + overLimit = true; + } + + return s; + } + + private boolean contains(final int[] arr, final int key) { + return Arrays.stream(arr).anyMatch(i -> i == key); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Report a fatal error. This method takes a message string and an + * additional object (to be used by specializations implemented in + * subclasses). Here in the base class a very simple implementation + * is provided which reports the error then throws an exception. + * + * @param message an error message. + * @param info an extra object reserved for use by specialized subclasses. + */ + public void report_fatal_error( + String message, + Object info) + throws java.lang.Exception { + /* stop parsing (not really necessary since we throw an exception, but) */ + done_parsing(); + + /* use the normal error message reporting to put out the message */ + report_error(message, info); + + /* throw an exception */ + throw new Exception("Can't recover from previous error(s)"); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Report a non fatal error (or warning). This method takes a message + * string and an additional object (to be used by specializations + * implemented in subclasses). Here in the base class a very simple + * implementation is provided which simply prints the message to + * System.err. + * + * @param message an error message. + * @param info an extra object reserved for use by specialized subclasses. + */ + public void report_error(String message, Object info) { + System.err.print(message); + if (info instanceof Symbol) + if (((Symbol) info).left != -1) + System.err.println(" at character " + ((Symbol) info).left + + " of input"); + else System.err.println(""); + else System.err.println(""); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * This method is called when a syntax error has been detected and recovery + * is about to be invoked. Here in the base class we just emit a + * "Syntax error" error message. + * + * @param cur_token the current lookahead Symbol. + */ + public void syntax_error(Symbol cur_token) { + report_error("Syntax error", cur_token); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * This method is called if it is determined that syntax error recovery + * has been unsuccessful. Here in the base class we report a fatal error. + * + * @param cur_token the current lookahead Symbol. + */ + public void unrecovered_syntax_error(Symbol cur_token) + throws java.lang.Exception { + report_fatal_error("Couldn't repair and continue parse", cur_token); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Fetch an action from the action table. The table is broken up into + * rows, one per state (rows are indexed directly by state number). + * Within each row, a list of index, value pairs are given (as sequential + * entries in the table), and the list is terminated by a default entry + * (denoted with a Symbol index of -1). To find the proper entry in a row + * we do a linear or binary search (depending on the size of the row). + * + * @param state the state index of the action being accessed. + * @param sym the Symbol index of the action being accessed. + */ + protected final short get_action(int state, int sym) { + short tag; + int first, last, probe; + short[] row = action_tab[state]; + + /* linear search if we are < 10 entries */ + if (row.length < 20) + for (probe = 0; probe < row.length; probe++) { + /* is this entry labeled with our Symbol or the default? */ + tag = row[probe++]; + if (tag == sym || tag == -1) { + /* return the next entry */ + return row[probe]; + } + } + /* otherwise binary search */ + else { + first = 0; + last = (row.length - 1) / 2 - 1; /* leave out trailing default entry */ + while (first <= last) { + probe = (first + last) / 2; + if (sym == row[probe * 2]) + return row[probe * 2 + 1]; + else if (sym > row[probe * 2]) + first = probe + 1; + else + last = probe - 1; + } + + /* not found, use the default at the end */ + return row[row.length - 1]; + } + + /* shouldn't happened, but if we run off the end we return the + default (error == 0) */ + return 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Fetch a state from the reduce-goto table. The table is broken up into + * rows, one per state (rows are indexed directly by state number). + * Within each row, a list of index, value pairs are given (as sequential + * entries in the table), and the list is terminated by a default entry + * (denoted with a Symbol index of -1). To find the proper entry in a row + * we do a linear search. + * + * @param state the state index of the entry being accessed. + * @param sym the Symbol index of the entry being accessed. + */ + protected final short get_reduce(int state, int sym) { + short tag; + short[] row = reduce_tab[state]; + + /* if we have a null row we go with the default */ + if (row == null) + return -1; + + for (int probe = 0; probe < row.length; probe++) { + /* is this entry labeled with our Symbol or the default? */ + tag = row[probe++]; + if (tag == sym || tag == -1) { + /* return the next entry */ + return row[probe]; + } + } + /* if we run off the end we return the default (error == -1) */ + return -1; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * This method provides the main parsing routine. It returns only when + * done_parsing() has been called (typically because the parser has + * accepted, or a fatal error has been reported). See the header + * documentation for the class regarding how shift/reduce parsers operate + * and how the various tables are used. + */ + public Symbol parse() throws java.lang.Exception { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* set up direct reference to tables to drive the parser */ + + production_tab = production_table(); + action_tab = action_table(); + reduce_tab = reduce_table(); + + /* initialize the action encapsulation object */ + init_actions(); + + /* do user initialization */ + user_init(); + isLiteral = false; + overLimit = false; + grpCount = 0; + opCount = 0; + lastSym = -1; + + /* get the first token */ + cur_token = scan(); + if (overLimit) return null; + + /* push dummy Symbol with start state to get us underway */ + stack.removeAllElements(); + stack.push(new Symbol(0, start_state())); + tos = 0; + + /* continue until we are told to stop */ + for (_done_parsing = false; !_done_parsing; ) { + /* Check current token for freshness. */ + if (cur_token.used_by_parser) + throw new Error("Symbol recycling detected (fix your scanner)."); + + /* current state is always on the top of the stack */ + + /* look up action out of the current state with the current input */ + act = get_action((stack.peek()).parse_state, cur_token.sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) { + /* shift to the encoded state by pushing it on the stack */ + cur_token.parse_state = act - 1; + cur_token.used_by_parser = true; + stack.push(cur_token); + tos++; + + /* advance to the next Symbol */ + cur_token = scan(); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) { + /* perform the action for the reduce */ + lhs_sym = do_action((-act) - 1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act) - 1][0]; + handle_size = production_tab[(-act) - 1][1]; + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + } + /* finally if the entry is zero, we have an error */ + else if (act == 0) { + /* call user syntax error reporting routine */ + syntax_error(cur_token); + + /* try to error recover */ + if (!error_recovery(false)) { + /* if that fails give up with a fatal syntax error */ + unrecovered_syntax_error(cur_token); + + /* just in case that wasn't fatal enough, end parse */ + done_parsing(); + } else { + lhs_sym = stack.peek(); + } + } + if (overLimit) return null; + } + + return lhs_sym; + } + + public boolean isOverLimit() { + return overLimit; + } + + /** + * Returns the count of operators in XPath expressions. + * + * @param id the ID of the count + * @return the count associated with the ID + */ + public int getCount(int id) { + switch (id) { + case ID_GROUP: + return grpCount; + case ID_OPERATOR: + return opCount; + case ID_TOTAL_OPERATOR: + return totalOpCount; + } + return 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Write a debugging message to System.err for the debugging version + * of the parser. + * + * @param mess the text of the debugging message. + */ + public void debug_message(String mess) { + System.err.println(mess); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Dump the parse stack for debugging purposes. + */ + public void dump_stack() { + if (stack == null) { + debug_message("# Stack dump requested, but stack is null"); + return; + } + + debug_message("============ Parse Stack Dump ============"); + + /* dump the stack */ + for (int i = 0; i < stack.size(); i++) { + debug_message("Symbol: " + (stack.get(i)).sym + + " State: " + (stack.get(i)).parse_state); + } + debug_message("=========================================="); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Do debug output for a reduce. + * + * @param prod_num the production we are reducing with. + * @param nt_num the index of the LHS non terminal. + * @param rhs_size the size of the RHS. + */ + public void debug_reduce(int prod_num, int nt_num, int rhs_size) { + debug_message("# Reduce with prod #" + prod_num + " [NT=" + nt_num + + ", " + "SZ=" + rhs_size + "]"); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Do debug output for shift. + * + * @param shift_tkn the Symbol being shifted onto the stack. + */ + public void debug_shift(Symbol shift_tkn) { + debug_message("# Shift under term #" + shift_tkn.sym + + " to state #" + shift_tkn.parse_state); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Do debug output for stack state. [CSA] + */ + public void debug_stack() { + StringBuilder sb = new StringBuilder("## STACK:"); + for (int i = 0; i < stack.size(); i++) { + Symbol s = stack.get(i); + sb.append(" "); + if ((i % 3) == 2 || (i == (stack.size() - 1))) { + debug_message(sb.toString()); + sb = new StringBuilder(" "); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Perform a parse with debugging output. This does exactly the + * same things as parse(), except that it calls debug_shift() and + * debug_reduce() when shift and reduce moves are taken by the parser + * and produces various other debugging messages. + */ + public Symbol debug_parse() + throws java.lang.Exception { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* set up direct reference to tables to drive the parser */ + production_tab = production_table(); + action_tab = action_table(); + reduce_tab = reduce_table(); + + debug_message("# Initializing parser"); + + /* initialize the action encapsulation object */ + init_actions(); + + /* do user initialization */ + user_init(); + + /* the current Symbol */ + cur_token = scan(); + + debug_message("# Current Symbol is #" + cur_token.sym); + + /* push dummy Symbol with start state to get us underway */ + stack.removeAllElements(); + stack.push(new Symbol(0, start_state())); + tos = 0; + + /* continue until we are told to stop */ + for (_done_parsing = false; !_done_parsing; ) { + /* Check current token for freshness. */ + if (cur_token.used_by_parser) + throw new Error("Symbol recycling detected (fix your scanner)."); + + /* current state is always on the top of the stack */ + //debug_stack(); + + /* look up action out of the current state with the current input */ + act = get_action((stack.peek()).parse_state, cur_token.sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) { + /* shift to the encoded state by pushing it on the stack */ + cur_token.parse_state = act - 1; + cur_token.used_by_parser = true; + debug_shift(cur_token); + stack.push(cur_token); + tos++; + + /* advance to the next Symbol */ + cur_token = scan(); + debug_message("# Current token is " + cur_token); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) { + /* perform the action for the reduce */ + lhs_sym = do_action((-act) - 1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act) - 1][0]; + handle_size = production_tab[(-act) - 1][1]; + + debug_reduce((-act) - 1, lhs_sym_num, handle_size); + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + debug_message("# Reduce rule: top state " + + (stack.peek()).parse_state + + ", lhs sym " + lhs_sym_num + " -> state " + act); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + + debug_message("# Goto state #" + act); + } + /* finally if the entry is zero, we have an error */ + else if (act == 0) { + /* call user syntax error reporting routine */ + syntax_error(cur_token); + + /* try to error recover */ + if (!error_recovery(true)) { + /* if that fails give up with a fatal syntax error */ + unrecovered_syntax_error(cur_token); + + /* just in case that wasn't fatal enough, end parse */ + done_parsing(); + } else { + lhs_sym = stack.peek(); + } + } + } + return lhs_sym; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + /* Error recovery code */ + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Attempt to recover from a syntax error. This returns false if recovery + * fails, true if it succeeds. Recovery happens in 4 steps. First we + * pop the parse stack down to a point at which we have a shift out + * of the top-most state on the error Symbol. This represents the + * initial error recovery configuration. If no such configuration is + * found, then we fail. Next a small number of "lookahead" or "parse + * ahead" Symbols are read into a buffer. The size of this buffer is + * determined by error_sync_size() and determines how many Symbols beyond + * the error must be matched to consider the recovery a success. Next, + * we begin to discard Symbols in attempt to get past the point of error + * to a point where we can continue parsing. After each Symbol, we attempt + * to "parse ahead" though the buffered lookahead Symbols. The "parse ahead" + * process simulates that actual parse, but does not modify the real + * parser's configuration, nor execute any actions. If we can parse all + * the stored Symbols without error, then the recovery is considered a + * success. Once a successful recovery point is determined, we do an + * actual parse over the stored input -- modifying the real parse + * configuration and executing all actions. Finally, we return the the + * normal parser to continue with the overall parse. + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean error_recovery(boolean debug) + throws java.lang.Exception { + if (debug) debug_message("# Attempting error recovery"); + + /* first pop the stack back into a state that can shift on error and + do that shift (if that fails, we fail) */ + if (!find_recovery_config(debug)) { + if (debug) debug_message("# Error recovery fails"); + return false; + } + + /* read ahead to create lookahead we can parse multiple times */ + read_lookahead(); + + /* repeatedly try to parse forward until we make it the required dist */ + for (; ; ) { + /* try to parse forward, if it makes it, bail out of loop */ + if (debug) debug_message("# Trying to parse ahead"); + if (try_parse_ahead(debug)) { + break; + } + + /* if we are now at EOF, we have failed */ + if (lookahead[0].sym == EOF_sym()) { + if (debug) debug_message("# Error recovery fails at EOF"); + return false; + } + + /* otherwise, we consume another Symbol and try again */ + if (debug) + debug_message("# Consuming Symbol #" + cur_err_token().sym); + restart_lookahead(); + } + + /* we have consumed to a point where we can parse forward */ + if (debug) debug_message("# Parse-ahead ok, going back to normal parse"); + + /* do the real parse (including actions) across the lookahead */ + parse_lookahead(debug); + + /* we have success */ + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Determine if we can shift under the special error Symbol out of the + * state currently on the top of the (real) parse stack. + */ + protected boolean shift_under_error() { + /* is there a shift under error Symbol */ + return get_action((stack.peek()).parse_state, error_sym()) > 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Put the (real) parse stack into error recovery configuration by + * popping the stack down to a state that can shift on the special + * error Symbol, then doing the shift. If no suitable state exists on + * the stack we return false + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean find_recovery_config(boolean debug) { + Symbol error_token; + int act; + + if (debug) debug_message("# Finding recovery state on stack"); + + /* Remember the right-position of the top symbol on the stack */ + int right_pos = (stack.peek()).right; + int left_pos = (stack.peek()).left; + + /* pop down until we can shift under error Symbol */ + while (!shift_under_error()) { + /* pop the stack */ + if (debug) + debug_message("# Pop stack by one, state was # " + + (stack.peek()).parse_state); + left_pos = stack.pop().left; + tos--; + + /* if we have hit bottom, we fail */ + if (stack.empty()) { + if (debug) debug_message("# No recovery state found on stack"); + return false; + } + } + + /* state on top of the stack can shift under error, find the shift */ + act = get_action((stack.peek()).parse_state, error_sym()); + if (debug) { + debug_message("# Recover state found (#" + + (stack.peek()).parse_state + ")"); + debug_message("# Shifting on error to state #" + (act - 1)); + } + + /* build and shift a special error Symbol */ + error_token = new Symbol(error_sym(), left_pos, right_pos); + error_token.parse_state = act - 1; + error_token.used_by_parser = true; + stack.push(error_token); + tos++; + + return true; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Lookahead Symbols used for attempting error recovery "parse aheads". + */ + protected Symbol lookahead[]; + + /** + * Position in lookahead input buffer used for "parse ahead". + */ + protected int lookahead_pos; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Read from input to establish our buffer of "parse ahead" lookahead + * Symbols. + */ + protected void read_lookahead() throws java.lang.Exception { + /* create the lookahead array */ + lookahead = new Symbol[error_sync_size()]; + + /* fill in the array */ + for (int i = 0; i < error_sync_size(); i++) { + lookahead[i] = cur_token; + cur_token = scan(); + } + + /* start at the beginning */ + lookahead_pos = 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Return the current lookahead in our error "parse ahead" buffer. + */ + protected Symbol cur_err_token() { + return lookahead[lookahead_pos]; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Advance to next "parse ahead" input Symbol. Return true if we have + * input to advance to, false otherwise. + */ + protected boolean advance_lookahead() { + /* advance the input location */ + lookahead_pos++; + + /* return true if we didn't go off the end */ + return lookahead_pos < error_sync_size(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Reset the parse ahead input to one Symbol past where we started error + * recovery (this consumes one new Symbol from the real input). + */ + protected void restart_lookahead() throws java.lang.Exception { + /* move all the existing input over */ + for (int i = 1; i < error_sync_size(); i++) + lookahead[i - 1] = lookahead[i]; + + /* read a new Symbol into the last spot */ + cur_token = scan(); + lookahead[error_sync_size() - 1] = cur_token; + + /* reset our internal position marker */ + lookahead_pos = 0; + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Do a simulated parse forward (a "parse ahead") from the current + * stack configuration using stored lookahead input and a virtual parse + * stack. Return true if we make it all the way through the stored + * lookahead input without error. This basically simulates the action of + * parse() using only our saved "parse ahead" input, and not executing any + * actions. + * + * @param debug should we produce debugging messages as we parse. + */ + protected boolean try_parse_ahead(boolean debug) + throws java.lang.Exception { + int act; + short lhs, rhs_size; + + /* create a virtual stack from the real parse stack */ + virtual_parse_stack vstack = new virtual_parse_stack(stack); + + /* parse until we fail or get past the lookahead input */ + for (; ; ) { + /* look up the action from the current state (on top of stack) */ + act = get_action(vstack.top(), cur_err_token().sym); + + /* if its an error, we fail */ + if (act == 0) return false; + + /* > 0 encodes a shift */ + if (act > 0) { + /* push the new state on the stack */ + vstack.push(act - 1); + + if (debug) debug_message("# Parse-ahead shifts Symbol #" + + cur_err_token().sym + " into state #" + (act - 1)); + + /* advance simulated input, if we run off the end, we are done */ + if (!advance_lookahead()) return true; + } + /* < 0 encodes a reduce */ + else { + /* if this is a reduce with the start production we are done */ + if ((-act) - 1 == start_production()) { + if (debug) debug_message("# Parse-ahead accepts"); + return true; + } + + /* get the lhs Symbol and the rhs size */ + lhs = production_tab[(-act) - 1][0]; + rhs_size = production_tab[(-act) - 1][1]; + + /* pop handle off the stack */ + for (int i = 0; i < rhs_size; i++) + vstack.pop(); + + if (debug) + debug_message("# Parse-ahead reduces: handle size = " + + rhs_size + " lhs = #" + lhs + " from state #" + vstack.top()); + + /* look up goto and push it onto the stack */ + vstack.push(get_reduce(vstack.top(), lhs)); + if (debug) + debug_message("# Goto state #" + vstack.top()); + } + } + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Parse forward using stored lookahead Symbols. In this case we have + * already verified that parsing will make it through the stored lookahead + * Symbols and we are now getting back to the point at which we can hand + * control back to the normal parser. Consequently, this version of the + * parser performs all actions and modifies the real parse configuration. + * This returns once we have consumed all the stored input or we accept. + * + * @param debug should we produce debugging messages as we parse. + */ + protected void parse_lookahead(boolean debug) + throws java.lang.Exception { + /* the current action code */ + int act; + + /* the Symbol/stack element returned by a reduce */ + Symbol lhs_sym = null; + + /* information about production being reduced with */ + short handle_size, lhs_sym_num; + + /* restart the saved input at the beginning */ + lookahead_pos = 0; + + if (debug) { + debug_message("# Reparsing saved input with actions"); + debug_message("# Current Symbol is #" + cur_err_token().sym); + debug_message("# Current state is #" + + (stack.peek()).parse_state); + } + + /* continue until we accept or have read all lookahead input */ + while (!_done_parsing) { + /* current state is always on the top of the stack */ + + /* look up action out of the current state with the current input */ + act = + get_action((stack.peek()).parse_state, cur_err_token().sym); + + /* decode the action -- > 0 encodes shift */ + if (act > 0) { + /* shift to the encoded state by pushing it on the stack */ + cur_err_token().parse_state = act - 1; + cur_err_token().used_by_parser = true; + if (debug) debug_shift(cur_err_token()); + stack.push(cur_err_token()); + tos++; + + /* advance to the next Symbol, if there is none, we are done */ + if (!advance_lookahead()) { + if (debug) debug_message("# Completed reparse"); + + /* scan next Symbol so we can continue parse */ + // BUGFIX by Chris Harris : + // correct a one-off error by commenting out + // this next line. + /*cur_token = scan();*/ + + /* go back to normal parser */ + return; + } + + if (debug) + debug_message("# Current Symbol is #" + cur_err_token().sym); + } + /* if its less than zero, then it encodes a reduce action */ + else if (act < 0) { + /* perform the action for the reduce */ + lhs_sym = do_action((-act) - 1, this, stack, tos); + + /* look up information about the production */ + lhs_sym_num = production_tab[(-act) - 1][0]; + handle_size = production_tab[(-act) - 1][1]; + + if (debug) debug_reduce((-act) - 1, lhs_sym_num, handle_size); + + /* pop the handle off the stack */ + for (int i = 0; i < handle_size; i++) { + stack.pop(); + tos--; + } + + /* look up the state to go to from the one popped back to */ + act = get_reduce((stack.peek()).parse_state, lhs_sym_num); + + /* shift to that state */ + lhs_sym.parse_state = act; + lhs_sym.used_by_parser = true; + stack.push(lhs_sym); + tos++; + + if (debug) debug_message("# Goto state #" + act); + + } + /* finally if the entry is zero, we have an error + (shouldn't happen here, but...)*/ + else if (act == 0) { + report_fatal_error("Syntax error", lhs_sym); + return; + } + } + + + } + + /*-----------------------------------------------------------*/ + + /** + * Utility function: unpacks parse tables from strings + */ + protected static short[][] unpackFromStrings(String[] sa) { + // Concatanate initialization strings. + StringBuilder sb = new StringBuilder(sa[0]); + for (int i = 1; i < sa.length; i++) + sb.append(sa[i]); + int n = 0; // location in initialization string + int size1 = (((int) sb.charAt(n)) << 16) | ((int) sb.charAt(n + 1)); + n += 2; + short[][] result = new short[size1][]; + for (int i = 0; i < size1; i++) { + int size2 = (((int) sb.charAt(n)) << 16) | ((int) sb.charAt(n + 1)); + n += 2; + result[i] = new short[size2]; + for (int j = 0; j < size2; j++) + result[i][j] = (short) (sb.charAt(n++) - 2); + } + return result; + } +} diff --git a/jaxp/src/main/java/com/sun/java_cup/internal/runtime/virtual_parse_stack.java b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/virtual_parse_stack.java new file mode 100644 index 0000000..3d3353a --- /dev/null +++ b/jaxp/src/main/java/com/sun/java_cup/internal/runtime/virtual_parse_stack.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +package com.sun.java_cup.internal.runtime; + +import java.util.Stack; + +/** + * This class implements a temporary or "virtual" parse stack that + * replaces the top portion of the actual parse stack (the part that + * has been changed by some set of operations) while maintaining its + * original contents. This data structure is used when the parse needs + * to "parse ahead" to determine if a given error recovery attempt will + * allow the parse to continue far enough to consider it successful. Once + * success or failure of parse ahead is determined the system then + * reverts to the original parse stack (which has not actually been + * modified). Since parse ahead does not execute actions, only parse + * state is maintained on the virtual stack, not full Symbol objects. + * + * @author Frank Flannery + * @see com.sun.java_cup.internal.runtime.lr_parser + */ + +public class virtual_parse_stack { + /*-----------------------------------------------------------*/ + /*--- Constructor(s) ----------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * Constructor to build a virtual stack out of a real stack. + */ + public virtual_parse_stack(Stack shadowing_stack) throws java.lang.Exception { + /* sanity check */ + if (shadowing_stack == null) + throw new Exception( + "Internal parser error: attempt to create null virtual stack"); + + /* set up our internals */ + real_stack = shadowing_stack; + vstack = new Stack<>(); + real_next = 0; + + /* get one element onto the virtual portion of the stack */ + get_from_real(); + } + + /*-----------------------------------------------------------*/ + /*--- (Access to) Instance Variables ------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * The real stack that we shadow. This is accessed when we move off + * the bottom of the virtual portion of the stack, but is always left + * unmodified. + */ + protected Stack real_stack; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Top of stack indicator for where we leave off in the real stack. + * This is measured from top of stack, so 0 would indicate that no + * elements have been "moved" from the real to virtual stack. + */ + protected int real_next; + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * The virtual top portion of the stack. This stack contains Integer + * objects with state numbers. This stack shadows the top portion + * of the real stack within the area that has been modified (via operations + * on the virtual stack). When this portion of the stack becomes empty we + * transfer elements from the underlying stack onto this stack. + */ + protected Stack vstack; + + /*-----------------------------------------------------------*/ + /*--- General Methods ---------------------------------------*/ + /*-----------------------------------------------------------*/ + + /** + * Transfer an element from the real to the virtual stack. This assumes + * that the virtual stack is currently empty. + */ + protected void get_from_real() { + Symbol stack_sym; + + /* don't transfer if the real stack is empty */ + if (real_next >= real_stack.size()) return; + + /* get a copy of the first Symbol we have not transfered */ + stack_sym = real_stack.get(real_stack.size() - 1 - real_next); + + /* record the transfer */ + real_next++; + + /* put the state number from the Symbol onto the virtual stack */ + vstack.push(stack_sym.parse_state); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Indicate whether the stack is empty. + */ + public boolean empty() { + /* if vstack is empty then we were unable to transfer onto it and + the whole thing is empty. */ + return vstack.empty(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Return value on the top of the stack (without popping it). + */ + public int top() throws java.lang.Exception { + if (vstack.empty()) + throw new Exception( + "Internal parser error: top() called on empty virtual stack"); + + return (vstack.peek()); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Pop the stack. + */ + public void pop() throws java.lang.Exception { + if (vstack.empty()) + throw new Exception( + "Internal parser error: pop from empty virtual stack"); + + /* pop it */ + vstack.pop(); + + /* if we are now empty transfer an element (if there is one) */ + if (vstack.empty()) + get_from_real(); + } + + /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ + + /** + * Push a state number onto the stack. + */ + public void push(int state_num) { + vstack.push(state_num); + } + + /*-----------------------------------------------------------*/ + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java new file mode 100644 index 0000000..b9db702 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Const.java @@ -0,0 +1,2951 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal; + +import java.util.Arrays; +import java.util.Collections; + +/** + * Constants for the project, mostly defined in the JVM specification. + * + * @LastModified: May 2023 + * @since 6.0 (intended to replace the Constants interface) + */ +public final class Const { + + /** + * Java class file format Magic number (0xCAFEBABE) + * + * @see The ClassFile Structure + * in The Java Virtual Machine Specification + */ + public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE; + + /** + * Major version number of class files for Java 1.1. + * + * @see #MINOR_1_1 + */ + public static final short MAJOR_1_1 = 45; + + /** + * Minor version number of class files for Java 1.1. + * + * @see #MAJOR_1_1 + */ + public static final short MINOR_1_1 = 3; + + /** + * Major version number of class files for Java 1.2. + * + * @see #MINOR_1_2 + */ + public static final short MAJOR_1_2 = 46; + + /** + * Minor version number of class files for Java 1.2. + * + * @see #MAJOR_1_2 + */ + public static final short MINOR_1_2 = 0; + + /** + * Major version number of class files for Java 1.2. + * + * @see #MINOR_1_2 + */ + public static final short MAJOR_1_3 = 47; + + /** + * Minor version number of class files for Java 1.3. + * + * @see #MAJOR_1_3 + */ + public static final short MINOR_1_3 = 0; + + /** + * Major version number of class files for Java 1.3. + * + * @see #MINOR_1_3 + */ + public static final short MAJOR_1_4 = 48; + + /** + * Minor version number of class files for Java 1.4. + * + * @see #MAJOR_1_4 + */ + public static final short MINOR_1_4 = 0; + + /** + * Major version number of class files for Java 1.4. + * + * @see #MINOR_1_4 + */ + public static final short MAJOR_1_5 = 49; + + /** + * Minor version number of class files for Java 1.5. + * + * @see #MAJOR_1_5 + */ + public static final short MINOR_1_5 = 0; + + /** + * Major version number of class files for Java 1.6. + * + * @see #MINOR_1_6 + */ + public static final short MAJOR_1_6 = 50; + + /** + * Minor version number of class files for Java 1.6. + * + * @see #MAJOR_1_6 + */ + public static final short MINOR_1_6 = 0; + + /** + * Major version number of class files for Java 1.7. + * + * @see #MINOR_1_7 + */ + public static final short MAJOR_1_7 = 51; + + /** + * Minor version number of class files for Java 1.7. + * + * @see #MAJOR_1_7 + */ + public static final short MINOR_1_7 = 0; + + /** + * Major version number of class files for Java 1.8. + * + * @see #MINOR_1_8 + */ + public static final short MAJOR_1_8 = 52; + + /** + * Minor version number of class files for Java 1.8. + * + * @see #MAJOR_1_8 + */ + public static final short MINOR_1_8 = 0; + + /** + * Major version number of class files for Java 9. + * + * @see #MINOR_9 + */ + public static final short MAJOR_9 = 53; + + /** + * Minor version number of class files for Java 9. + * + * @see #MAJOR_9 + */ + public static final short MINOR_9 = 0; + + /** + * @deprecated Use {@link #MAJOR_9} instead + */ + @Deprecated + public static final short MAJOR_1_9 = MAJOR_9; + + /** + * @deprecated Use {@link #MINOR_9} instead + */ + @Deprecated + public static final short MINOR_1_9 = MINOR_9; + + /** + * Major version number of class files for Java 10. + * + * @see #MINOR_10 + */ + public static final short MAJOR_10 = 54; + + /** + * Minor version number of class files for Java 10. + * + * @see #MAJOR_10 + */ + public static final short MINOR_10 = 0; + + /** + * Major version number of class files for Java 11. + * + * @see #MINOR_11 + */ + public static final short MAJOR_11 = 55; + + /** + * Minor version number of class files for Java 11. + * + * @see #MAJOR_11 + */ + public static final short MINOR_11 = 0; + + /** + * Major version number of class files for Java 12. + * + * @see #MINOR_12 + */ + public static final short MAJOR_12 = 56; + + /** + * Minor version number of class files for Java 12. + * + * @see #MAJOR_12 + */ + public static final short MINOR_12 = 0; + + /** + * Major version number of class files for Java 13. + * + * @see #MINOR_13 + */ + public static final short MAJOR_13 = 57; + + /** + * Minor version number of class files for Java 13. + * + * @see #MAJOR_13 + */ + public static final short MINOR_13 = 0; + + /** + * Minor version number of class files for Java 14. + * + * @see #MAJOR_14 + * @since 6.4.0 + */ + public static final short MINOR_14 = 0; + + /** + * Minor version number of class files for Java 15. + * + * @see #MAJOR_15 + * @since 6.6.0 + */ + public static final short MINOR_15 = 0; + + /** + * Minor version number of class files for Java 16. + * + * @see #MAJOR_16 + * @since 6.6.0 + */ + public static final short MINOR_16 = 0; + + /** + * Minor version number of class files for Java 17. + * + * @see #MAJOR_17 + * @since 6.6.0 + */ + public static final short MINOR_17 = 0; + + /** + * Minor version number of class files for Java 18. + * + * @see #MAJOR_18 + * @since 6.6.0 + */ + public static final short MINOR_18 = 0; + + /** + * Minor version number of class files for Java 19. + * + * @see #MAJOR_19 + * @since 6.6.0 + */ + public static final short MINOR_19 = 0; + + /** + * Major version number of class files for Java 14. + * + * @see #MINOR_14 + * @since 6.4.0 + */ + public static final short MAJOR_14 = 58; + + /** + * Major version number of class files for Java 15. + * + * @see #MINOR_15 + * @since 6.6.0 + */ + public static final short MAJOR_15 = 59; + + /** + * Major version number of class files for Java 16. + * + * @see #MINOR_16 + * @since 6.6.0 + */ + public static final short MAJOR_16 = 60; + + /** + * Major version number of class files for Java 17. + * + * @see #MINOR_17 + * @since 6.6.0 + */ + public static final short MAJOR_17 = 61; + + /** + * Major version number of class files for Java 18. + * + * @see #MINOR_18 + * @since 6.6.0 + */ + public static final short MAJOR_18 = 62; + + /** + * Major version number of class files for Java 19. + * + * @see #MINOR_19 + * @since 6.6.0 + */ + public static final short MAJOR_19 = 63; + + /** + * Default major version number. Class file is for Java 1.1. + * + * @see #MAJOR_1_1 + */ + public static final short MAJOR = MAJOR_1_1; + + /** + * Default major version number. Class file is for Java 1.1. + * + * @see #MAJOR_1_1 + */ + public static final short MINOR = MINOR_1_1; + + /** + * Maximum value for an unsigned short. + */ + public static final int MAX_SHORT = 65535; // 2^16 - 1 + + /** + * Maximum value for an unsigned byte. + */ + public static final int MAX_BYTE = 255; // 2^8 - 1 + + /** + * One of the access flags for fields, methods, or classes. + * + * @see Flag definitions for + * Classes in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag definitions for Fields + * in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag definitions for Methods + * in the Java Virtual Machine Specification (Java SE 9 Edition). + * @see Flag + * definitions for Inner Classes in the Java Virtual Machine Specification (Java SE 9 Edition). + */ + public static final short ACC_PUBLIC = 0x0001; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_PRIVATE = 0x0002; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_PROTECTED = 0x0004; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_STATIC = 0x0008; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_FINAL = 0x0010; + + /** + * One of the access flags for the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_OPEN = 0x0020; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SUPER = 0x0020; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNCHRONIZED = 0x0020; + + /** + * One of the access flags for the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_TRANSITIVE = 0x0020; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_BRIDGE = 0x0040; + + /** + * One of the access flags for the Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_STATIC_PHASE = 0x0040; + + /** + * One of the access flags for fields. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_VOLATILE = 0x0040; + + /** + * One of the access flags for fields. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_TRANSIENT = 0x0080; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_VARARGS = 0x0080; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_NATIVE = 0x0100; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_INTERFACE = 0x0200; + + /** + * One of the access flags for methods or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ABSTRACT = 0x0400; + + /** + * One of the access flags for methods. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_STRICT = 0x0800; + + /** + * One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNTHETIC = 0x1000; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ANNOTATION = 0x2000; + + /** + * One of the access flags for fields or classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_ENUM = 0x4000; + + // Applies to classes compiled by new compilers only + /** + * One of the access flags for MethodParameter or Module attributes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_MANDATED = (short) 0x8000; + + /** + * One of the access flags for classes. + * + * @see #ACC_PUBLIC + */ + public static final short ACC_MODULE = (short) 0x8000; + + /** + * One of the access flags for fields, methods, or classes. + * + * @see #ACC_PUBLIC + * @deprecated Use {@link #MAX_ACC_FLAG_I} + */ + @Deprecated + public static final short MAX_ACC_FLAG = ACC_ENUM; + + /** + * One of the access flags for fields, methods, or classes. ACC_MODULE is negative as a short. + * + * @see #ACC_PUBLIC + * @since 6.4.0 + */ + public static final int MAX_ACC_FLAG_I = 0x8000; // ACC_MODULE is negative as a short + + // Note that do to overloading: + // 'synchronized' is for methods, might be 'open' (if Module), 'super' (if class), or 'transitive' (if Module). + // 'volatile' is for fields, might be 'bridge' (if method) or 'static_phase' (if Module) + // 'transient' is for fields, might be 'varargs' (if method) + // 'module' is for classes, might be 'mandated' (if Module or MethodParameters) + /** + * Marks a constant pool entry as type UTF-8. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Utf8 = 1; + /** + * Marks a constant pool entry as type Integer. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Integer = 3; + /** + * Marks a constant pool entry as type Float. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Float = 4; + + /* + * The description of the constant pool is at: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4 + * References below are to the individual sections + */ + /** + * Marks a constant pool entry as type Long. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Long = 5; + /** + * Marks a constant pool entry as type Double. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Double = 6; + /** + * Marks a constant pool entry as a Class + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Class = 7; + /** + * Marks a constant pool entry as a Field Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Fieldref = 9; + /** + * Marks a constant pool entry as type String + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_String = 8; + /** + * Marks a constant pool entry as a Method Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_Methodref = 10; + /** + * Marks a constant pool entry as an Interface Method Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_InterfaceMethodref = 11; + /** + * Marks a constant pool entry as a name and type. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_NameAndType = 12; + /** + * Marks a constant pool entry as a Method Handle. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_MethodHandle = 15; + /** + * Marks a constant pool entry as a Method Type. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_MethodType = 16; + /** + * Marks a constant pool entry as dynamically computed. + * + * @see Change request for JEP + * 309 + * @since 6.3 + */ + public static final byte CONSTANT_Dynamic = 17; + /** + * Marks a constant pool entry as an Invoke Dynamic + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + */ + public static final byte CONSTANT_InvokeDynamic = 18; + /** + * Marks a constant pool entry as a Module Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + * @since 6.1 + */ + public static final byte CONSTANT_Module = 19; + /** + * Marks a constant pool entry as a Package Reference. + * + * @see The Constant Pool in The + * Java Virtual Machine Specification + * @since 6.1 + */ + public static final byte CONSTANT_Package = 20; + /** + * The name of the static initializer, also called "class initialization method" or "interface + * initialization method". This is "<clinit>". + */ + public static final String STATIC_INITIALIZER_NAME = ""; + /** + * The name of every constructor method in a class, also called "instance initialization method". This is + * "<init>". + */ + public static final String CONSTRUCTOR_NAME = ""; + /** + * Maximum Constant Pool entries. One of the limitations of the Java Virtual Machine. + * + * @see The Java Virtual + * Machine Specification, Java SE 8 Edition, page 330, chapter 4.11. + */ + public static final int MAX_CP_ENTRIES = 65535; + /** + * Maximum code size (plus one; the code size must be LESS than this) One of the limitations of the Java Virtual + * Machine. Note vmspec2 page 152 ("Limitations") says: "The amount of code per non-native, non-abstract method is + * limited to 65536 bytes by the sizes of the indices in the exception_table of the Code attribute (4.7.3), in the + * LineNumberTable attribute (4.7.8), and in the LocalVariableTable attribute (4.7.9)." However this should be taken + * as an upper limit rather than the defined maximum. On page 134 (4.8.1 Static Constants) of the same spec, it says: + * "The value of the code_length item must be less than 65536." The entry in the Limitations section has been removed + * from later versions of the spec; it is not present in the Java SE 8 edition. + * + * @see The Java Virtual + * Machine Specification, Java SE 8 Edition, page 104, chapter 4.7. + */ + public static final int MAX_CODE_SIZE = 65536; // bytes + /** + * The maximum number of dimensions in an array ({@value}). One of the limitations of the Java Virtual Machine. + * + * @see Field Descriptors in + * The Java Virtual Machine Specification + */ + public static final int MAX_ARRAY_DIMENSIONS = 255; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short NOP = 0; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short ACONST_NULL = 1; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_M1 = 2; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_0 = 3; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_1 = 4; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_2 = 5; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_3 = 6; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_4 = 7; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ICONST_5 = 8; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LCONST_0 = 9; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LCONST_1 = 10; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FCONST_0 = 11; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FCONST_1 = 12; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FCONST_2 = 13; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DCONST_0 = 14; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DCONST_1 = 15; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short BIPUSH = 16; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short SIPUSH = 17; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short LDC = 18; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LDC_W = 19; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LDC2_W = 20; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ILOAD = 21; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LLOAD = 22; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FLOAD = 23; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DLOAD = 24; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ALOAD = 25; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ILOAD_0 = 26; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ILOAD_1 = 27; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ILOAD_2 = 28; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ILOAD_3 = 29; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LLOAD_0 = 30; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LLOAD_1 = 31; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LLOAD_2 = 32; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LLOAD_3 = 33; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FLOAD_0 = 34; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FLOAD_1 = 35; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FLOAD_2 = 36; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FLOAD_3 = 37; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DLOAD_0 = 38; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DLOAD_1 = 39; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DLOAD_2 = 40; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DLOAD_3 = 41; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ALOAD_0 = 42; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ALOAD_1 = 43; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ALOAD_2 = 44; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ALOAD_3 = 45; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IALOAD = 46; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LALOAD = 47; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FALOAD = 48; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DALOAD = 49; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short AALOAD = 50; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short BALOAD = 51; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short CALOAD = 52; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short SALOAD = 53; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ISTORE = 54; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LSTORE = 55; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FSTORE = 56; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DSTORE = 57; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ASTORE = 58; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ISTORE_0 = 59; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ISTORE_1 = 60; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ISTORE_2 = 61; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ISTORE_3 = 62; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LSTORE_0 = 63; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LSTORE_1 = 64; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LSTORE_2 = 65; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short LSTORE_3 = 66; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FSTORE_0 = 67; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FSTORE_1 = 68; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FSTORE_2 = 69; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short FSTORE_3 = 70; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DSTORE_0 = 71; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DSTORE_1 = 72; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DSTORE_2 = 73; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short DSTORE_3 = 74; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ASTORE_0 = 75; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ASTORE_1 = 76; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ASTORE_2 = 77; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ASTORE_3 = 78; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IASTORE = 79; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LASTORE = 80; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FASTORE = 81; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DASTORE = 82; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short AASTORE = 83; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short BASTORE = 84; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short CASTORE = 85; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short SASTORE = 86; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short POP = 87; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short POP2 = 88; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short DUP = 89; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DUP_X1 = 90; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DUP_X2 = 91; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DUP2 = 92; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DUP2_X1 = 93; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DUP2_X2 = 94; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short SWAP = 95; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IADD = 96; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LADD = 97; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FADD = 98; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DADD = 99; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ISUB = 100; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LSUB = 101; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FSUB = 102; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DSUB = 103; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IMUL = 104; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LMUL = 105; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FMUL = 106; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DMUL = 107; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IDIV = 108; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LDIV = 109; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FDIV = 110; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DDIV = 111; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IREM = 112; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LREM = 113; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FREM = 114; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DREM = 115; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short INEG = 116; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LNEG = 117; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FNEG = 118; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DNEG = 119; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ISHL = 120; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LSHL = 121; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ISHR = 122; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LSHR = 123; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IUSHR = 124; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LUSHR = 125; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IAND = 126; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LAND = 127; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short IOR = 128; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short LOR = 129; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IXOR = 130; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LXOR = 131; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IINC = 132; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2L = 133; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2F = 134; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2D = 135; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short L2I = 136; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short L2F = 137; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short L2D = 138; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short F2I = 139; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short F2L = 140; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short F2D = 141; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short D2I = 142; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short D2L = 143; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short D2F = 144; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2B = 145; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short INT2BYTE = 145; // Old notation + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2C = 146; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short INT2CHAR = 146; // Old notation + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short I2S = 147; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short INT2SHORT = 147; // Old notation + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LCMP = 148; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FCMPL = 149; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FCMPG = 150; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DCMPL = 151; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DCMPG = 152; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFEQ = 153; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFNE = 154; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFLT = 155; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFGE = 156; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFGT = 157; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFLE = 158; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPEQ = 159; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPNE = 160; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPLT = 161; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPGE = 162; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPGT = 163; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ICMPLE = 164; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ACMPEQ = 165; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short IF_ACMPNE = 166; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short GOTO = 167; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short JSR = 168; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short RET = 169; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short TABLESWITCH = 170; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short LOOKUPSWITCH = 171; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IRETURN = 172; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short LRETURN = 173; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short FRETURN = 174; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short DRETURN = 175; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ARETURN = 176; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short RETURN = 177; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short GETSTATIC = 178; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short PUTSTATIC = 179; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short GETFIELD = 180; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short PUTFIELD = 181; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short INVOKEVIRTUAL = 182; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short INVOKESPECIAL = 183; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0 + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short INVOKESTATIC = 184; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short INVOKEINTERFACE = 185; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short INVOKEDYNAMIC = 186; + /** + * Java VM opcode. + * + * @see Opcode definitions in The + * Java Virtual Machine Specification + */ + public static final short NEW = 187; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short NEWARRAY = 188; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short ANEWARRAY = 189; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short ARRAYLENGTH = 190; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short ATHROW = 191; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short CHECKCAST = 192; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short INSTANCEOF = 193; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short MONITORENTER = 194; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short MONITOREXIT = 195; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short WIDE = 196; + /** + * Java VM opcode. + * + * @see Opcode + * definitions in The Java Virtual Machine Specification + */ + public static final short MULTIANEWARRAY = 197; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short IFNULL = 198; + /** + * Java VM opcode. + * + * @see Opcode definitions + * in The Java Virtual Machine Specification + */ + public static final short IFNONNULL = 199; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short GOTO_W = 200; + /** + * Java VM opcode. + * + * @see Opcode definitions in + * The Java Virtual Machine Specification + */ + public static final short JSR_W = 201; + /** + * JVM internal opcode. + * + * @see Reserved opcodes in the Java + * Virtual Machine Specification + */ + public static final short BREAKPOINT = 202; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short LDC_QUICK = 203; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short LDC_W_QUICK = 204; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short LDC2_W_QUICK = 205; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short GETFIELD_QUICK = 206; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short PUTFIELD_QUICK = 207; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short GETFIELD2_QUICK = 208; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short PUTFIELD2_QUICK = 209; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short GETSTATIC_QUICK = 210; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short PUTSTATIC_QUICK = 211; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short GETSTATIC2_QUICK = 212; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short PUTSTATIC2_QUICK = 213; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKEVIRTUAL_QUICK = 214; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKENONVIRTUAL_QUICK = 215; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKESUPER_QUICK = 216; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKESTATIC_QUICK = 217; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKEINTERFACE_QUICK = 218; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKEVIRTUALOBJECT_QUICK = 219; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short NEW_QUICK = 221; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short ANEWARRAY_QUICK = 222; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short MULTIANEWARRAY_QUICK = 223; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short CHECKCAST_QUICK = 224; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INSTANCEOF_QUICK = 225; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short INVOKEVIRTUAL_QUICK_W = 226; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short GETFIELD_QUICK_W = 227; + /** + * JVM internal opcode. + * + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see Why the _quick + * opcodes were removed from the second version of the Java Virtual Machine Specification. + */ + public static final short PUTFIELD_QUICK_W = 228; + /** + * JVM internal opcode. + * + * @see Reserved opcodes in the Java + * Virtual Machine Specification + */ + public static final short IMPDEP1 = 254; + /** + * JVM internal opcode. + * + * @see Reserved opcodes in the Java + * Virtual Machine Specification + */ + public static final short IMPDEP2 = 255; + /** + * BCEL virtual instruction for pushing an arbitrary data type onto the stack. Will be converted to the appropriate JVM + * opcode when the class is dumped. + */ + public static final short PUSH = 4711; + /** + * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH. Will be converted to the appropriate JVM opcode when + * the class is dumped. + */ + public static final short SWITCH = 4712; + /** + * Illegal opcode. + */ + public static final short UNDEFINED = -1; + /** + * Illegal opcode. + */ + public static final short UNPREDICTABLE = -2; + /** + * Illegal opcode. + */ + public static final short RESERVED = -3; + /** + * Mnemonic for an illegal opcode. + */ + public static final String ILLEGAL_OPCODE = ""; + /** + * Mnemonic for an illegal type. + */ + public static final String ILLEGAL_TYPE = ""; + /** + * Boolean data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_BOOLEAN = 4; + /** + * Char data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_CHAR = 5; + /** + * Float data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_FLOAT = 6; + /** + * Double data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_DOUBLE = 7; + /** + * Byte data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_BYTE = 8; + /** + * Short data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_SHORT = 9; + /** + * Int data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_INT = 10; + /** + * Long data type. + * + * @see Static Constraints in + * the Java Virtual Machine Specification + */ + public static final byte T_LONG = 11; + /** + * Void data type (non-standard). + */ + public static final byte T_VOID = 12; // Non-standard + /** + * Array data type. + */ + public static final byte T_ARRAY = 13; + /** + * Object data type. + */ + public static final byte T_OBJECT = 14; + /** + * Reference data type (deprecated). + */ + public static final byte T_REFERENCE = 14; // Deprecated + /** + * Unknown data type. + */ + public static final byte T_UNKNOWN = 15; + /** + * Address data type. + */ + public static final byte T_ADDRESS = 16; + /** + * Empty arrays used to replace references to ArrayUtils + */ + public static final byte[] EMPTY_BYTE_ARRAY = {}; + public static final int[] EMPTY_INT_ARRAY = {}; + public static final String[] EMPTY_STRING_ARRAY = {}; + /** + * Attributes and their corresponding names. + */ + public static final byte ATTR_UNKNOWN = -1; + public static final byte ATTR_SOURCE_FILE = 0; + public static final byte ATTR_CONSTANT_VALUE = 1; + public static final byte ATTR_CODE = 2; + public static final byte ATTR_EXCEPTIONS = 3; + public static final byte ATTR_LINE_NUMBER_TABLE = 4; + public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5; + public static final byte ATTR_INNER_CLASSES = 6; + public static final byte ATTR_SYNTHETIC = 7; + public static final byte ATTR_DEPRECATED = 8; + public static final byte ATTR_PMG = 9; + public static final byte ATTR_SIGNATURE = 10; + public static final byte ATTR_STACK_MAP = 11; + public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; + public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS = 13; + public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; + public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15; + public static final byte ATTR_ANNOTATION_DEFAULT = 16; + public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 17; + public static final byte ATTR_ENCLOSING_METHOD = 18; + public static final byte ATTR_STACK_MAP_TABLE = 19; + public static final byte ATTR_BOOTSTRAP_METHODS = 20; + public static final byte ATTR_METHOD_PARAMETERS = 21; + public static final byte ATTR_MODULE = 22; + public static final byte ATTR_MODULE_PACKAGES = 23; + public static final byte ATTR_MODULE_MAIN_CLASS = 24; + public static final byte ATTR_NEST_HOST = 25; + public static final byte ATTR_NEST_MEMBERS = 26; + public static final short KNOWN_ATTRIBUTES = 27; // count of attributes + /** + * Constants used in the StackMap attribute. + */ + public static final byte ITEM_Bogus = 0; + public static final byte ITEM_Integer = 1; + public static final byte ITEM_Float = 2; + public static final byte ITEM_Double = 3; + public static final byte ITEM_Long = 4; + public static final byte ITEM_Null = 5; + public static final byte ITEM_InitObject = 6; + public static final byte ITEM_Object = 7; + public static final byte ITEM_NewObject = 8; + /** + * Constants used to identify StackMapEntry types. + *

+ * For those types which can specify a range, the constant names the lowest value. + */ + public static final int SAME_FRAME = 0; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247; + public static final int CHOP_FRAME = 248; + public static final int SAME_FRAME_EXTENDED = 251; + public static final int APPEND_FRAME = 252; + public static final int FULL_FRAME = 255; + /** + * Constants that define the maximum value of those constants which store ranges. + */ + + public static final int SAME_FRAME_MAX = 63; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_MAX = 127; + public static final int CHOP_FRAME_MAX = 250; + public static final int APPEND_FRAME_MAX = 254; + public static final byte REF_getField = 1; + public static final byte REF_getStatic = 2; + public static final byte REF_putField = 3; + public static final byte REF_putStatic = 4; + public static final byte REF_invokeVirtual = 5; + public static final byte REF_invokeStatic = 6; + public static final byte REF_invokeSpecial = 7; + public static final byte REF_newInvokeSpecial = 8; + public static final byte REF_invokeInterface = 9; + /** + * Number of byte code operands for each opcode, i.e., number of bytes after the tag byte itself. Indexed by opcode, so + * NO_OF_OPERANDS[BIPUSH] = the number of operands for a bipush instruction. + */ + static final short[] NO_OF_OPERANDS = {0/* nop */, 0/* aconst_null */, 0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */, 0/* iconst_2 */, + 0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */, 0/* lconst_0 */, 0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */, 0/* fconst_2 */, 0/* dconst_0 */, + 0/* dconst_1 */, 1/* bipush */, 2/* sipush */, 1/* ldc */, 2/* ldc_w */, 2/* ldc2_w */, 1/* iload */, 1/* lload */, 1/* fload */, 1/* dload */, + 1/* aload */, 0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */, 0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */, + 0/* fload_0 */, 0/* fload_1 */, 0/* fload_2 */, 0/* fload_3 */, 0/* dload_0 */, 0/* dload_1 */, 0/* dload_2 */, 0/* dload_3 */, 0/* aload_0 */, + 0/* aload_1 */, 0/* aload_2 */, 0/* aload_3 */, 0/* iaload */, 0/* laload */, 0/* faload */, 0/* daload */, 0/* aaload */, 0/* baload */, 0/* caload */, + 0/* saload */, 1/* istore */, 1/* lstore */, 1/* fstore */, 1/* dstore */, 1/* astore */, 0/* istore_0 */, 0/* istore_1 */, 0/* istore_2 */, + 0/* istore_3 */, 0/* lstore_0 */, 0/* lstore_1 */, 0/* lstore_2 */, 0/* lstore_3 */, 0/* fstore_0 */, 0/* fstore_1 */, 0/* fstore_2 */, 0/* fstore_3 */, + 0/* dstore_0 */, 0/* dstore_1 */, 0/* dstore_2 */, 0/* dstore_3 */, 0/* astore_0 */, 0/* astore_1 */, 0/* astore_2 */, 0/* astore_3 */, 0/* iastore */, + 0/* lastore */, 0/* fastore */, 0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */, 0/* sastore */, 0/* pop */, 0/* pop2 */, 0/* dup */, + 0/* dup_x1 */, 0/* dup_x2 */, 0/* dup2 */, 0/* dup2_x1 */, 0/* dup2_x2 */, 0/* swap */, 0/* iadd */, 0/* ladd */, 0/* fadd */, 0/* dadd */, 0/* isub */, + 0/* lsub */, 0/* fsub */, 0/* dsub */, 0/* imul */, 0/* lmul */, 0/* fmul */, 0/* dmul */, 0/* idiv */, 0/* ldiv */, 0/* fdiv */, 0/* ddiv */, + 0/* irem */, 0/* lrem */, 0/* frem */, 0/* drem */, 0/* ineg */, 0/* lneg */, 0/* fneg */, 0/* dneg */, 0/* ishl */, 0/* lshl */, 0/* ishr */, + 0/* lshr */, 0/* iushr */, 0/* lushr */, 0/* iand */, 0/* land */, 0/* ior */, 0/* lor */, 0/* ixor */, 0/* lxor */, 2/* iinc */, 0/* i2l */, + 0/* i2f */, 0/* i2d */, 0/* l2i */, 0/* l2f */, 0/* l2d */, 0/* f2i */, 0/* f2l */, 0/* f2d */, 0/* d2i */, 0/* d2l */, 0/* d2f */, 0/* i2b */, + 0/* i2c */, 0/* i2s */, 0/* lcmp */, 0/* fcmpl */, 0/* fcmpg */, 0/* dcmpl */, 0/* dcmpg */, 2/* ifeq */, 2/* ifne */, 2/* iflt */, 2/* ifge */, + 2/* ifgt */, 2/* ifle */, 2/* if_icmpeq */, 2/* if_icmpne */, 2/* if_icmplt */, 2/* if_icmpge */, 2/* if_icmpgt */, 2/* if_icmple */, 2/* if_acmpeq */, + 2/* if_acmpne */, 2/* goto */, 2/* jsr */, 1/* ret */, UNPREDICTABLE/* tableswitch */, UNPREDICTABLE/* lookupswitch */, 0/* ireturn */, 0/* lreturn */, + 0/* freturn */, 0/* dreturn */, 0/* areturn */, 0/* return */, 2/* getstatic */, 2/* putstatic */, 2/* getfield */, 2/* putfield */, + 2/* invokevirtual */, 2/* invokespecial */, 2/* invokestatic */, 4/* invokeinterface */, 4/* invokedynamic */, 2/* new */, 1/* newarray */, + 2/* anewarray */, 0/* arraylength */, 0/* athrow */, 2/* checkcast */, 2/* instanceof */, 0/* monitorenter */, 0/* monitorexit */, + UNPREDICTABLE/* wide */, 3/* multianewarray */, 2/* ifnull */, 2/* ifnonnull */, 4/* goto_w */, 4/* jsr_w */, 0/* breakpoint */, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, RESERVED/* impdep1 */, + RESERVED/* impdep2 */ + }; + /** + * How the byte code operands are to be interpreted for each opcode. Indexed by opcode. TYPE_OF_OPERANDS[ILOAD] = an + * array of shorts describing the data types for the instruction. + */ + static final short[][] TYPE_OF_OPERANDS = {{}/* nop */, {}/* aconst_null */, {}/* iconst_m1 */, {}/* iconst_0 */, {}/* iconst_1 */, + {}/* iconst_2 */, {}/* iconst_3 */, {}/* iconst_4 */, {}/* iconst_5 */, {}/* lconst_0 */, {}/* lconst_1 */, {}/* fconst_0 */, {}/* fconst_1 */, + {}/* fconst_2 */, {}/* dconst_0 */, {}/* dconst_1 */, {T_BYTE}/* bipush */, {T_SHORT}/* sipush */, {T_BYTE}/* ldc */, {T_SHORT}/* ldc_w */, + {T_SHORT}/* ldc2_w */, {T_BYTE}/* iload */, {T_BYTE}/* lload */, {T_BYTE}/* fload */, {T_BYTE}/* dload */, {T_BYTE}/* aload */, {}/* iload_0 */, + {}/* iload_1 */, {}/* iload_2 */, {}/* iload_3 */, {}/* lload_0 */, {}/* lload_1 */, {}/* lload_2 */, {}/* lload_3 */, {}/* fload_0 */, {}/* fload_1 */, + {}/* fload_2 */, {}/* fload_3 */, {}/* dload_0 */, {}/* dload_1 */, {}/* dload_2 */, {}/* dload_3 */, {}/* aload_0 */, {}/* aload_1 */, {}/* aload_2 */, + {}/* aload_3 */, {}/* iaload */, {}/* laload */, {}/* faload */, {}/* daload */, {}/* aaload */, {}/* baload */, {}/* caload */, {}/* saload */, + {T_BYTE}/* istore */, {T_BYTE}/* lstore */, {T_BYTE}/* fstore */, {T_BYTE}/* dstore */, {T_BYTE}/* astore */, {}/* istore_0 */, {}/* istore_1 */, + {}/* istore_2 */, {}/* istore_3 */, {}/* lstore_0 */, {}/* lstore_1 */, {}/* lstore_2 */, {}/* lstore_3 */, {}/* fstore_0 */, {}/* fstore_1 */, + {}/* fstore_2 */, {}/* fstore_3 */, {}/* dstore_0 */, {}/* dstore_1 */, {}/* dstore_2 */, {}/* dstore_3 */, {}/* astore_0 */, {}/* astore_1 */, + {}/* astore_2 */, {}/* astore_3 */, {}/* iastore */, {}/* lastore */, {}/* fastore */, {}/* dastore */, {}/* aastore */, {}/* bastore */, + {}/* castore */, {}/* sastore */, {}/* pop */, {}/* pop2 */, {}/* dup */, {}/* dup_x1 */, {}/* dup_x2 */, {}/* dup2 */, {}/* dup2_x1 */, + {}/* dup2_x2 */, {}/* swap */, {}/* iadd */, {}/* ladd */, {}/* fadd */, {}/* dadd */, {}/* isub */, {}/* lsub */, {}/* fsub */, {}/* dsub */, + {}/* imul */, {}/* lmul */, {}/* fmul */, {}/* dmul */, {}/* idiv */, {}/* ldiv */, {}/* fdiv */, {}/* ddiv */, {}/* irem */, {}/* lrem */, + {}/* frem */, {}/* drem */, {}/* ineg */, {}/* lneg */, {}/* fneg */, {}/* dneg */, {}/* ishl */, {}/* lshl */, {}/* ishr */, {}/* lshr */, + {}/* iushr */, {}/* lushr */, {}/* iand */, {}/* land */, {}/* ior */, {}/* lor */, {}/* ixor */, {}/* lxor */, {T_BYTE, T_BYTE}/* iinc */, {}/* i2l */, + {}/* i2f */, {}/* i2d */, {}/* l2i */, {}/* l2f */, {}/* l2d */, {}/* f2i */, {}/* f2l */, {}/* f2d */, {}/* d2i */, {}/* d2l */, {}/* d2f */, + {}/* i2b */, {}/* i2c */, {}/* i2s */, {}/* lcmp */, {}/* fcmpl */, {}/* fcmpg */, {}/* dcmpl */, {}/* dcmpg */, {T_SHORT}/* ifeq */, + {T_SHORT}/* ifne */, {T_SHORT}/* iflt */, {T_SHORT}/* ifge */, {T_SHORT}/* ifgt */, {T_SHORT}/* ifle */, {T_SHORT}/* if_icmpeq */, + {T_SHORT}/* if_icmpne */, {T_SHORT}/* if_icmplt */, {T_SHORT}/* if_icmpge */, {T_SHORT}/* if_icmpgt */, {T_SHORT}/* if_icmple */, + {T_SHORT}/* if_acmpeq */, {T_SHORT}/* if_acmpne */, {T_SHORT}/* goto */, {T_SHORT}/* jsr */, {T_BYTE}/* ret */, {}/* tableswitch */, + {}/* lookupswitch */, {}/* ireturn */, {}/* lreturn */, {}/* freturn */, {}/* dreturn */, {}/* areturn */, {}/* return */, {T_SHORT}/* getstatic */, + {T_SHORT}/* putstatic */, {T_SHORT}/* getfield */, {T_SHORT}/* putfield */, {T_SHORT}/* invokevirtual */, {T_SHORT}/* invokespecial */, + {T_SHORT}/* invokestatic */, {T_SHORT, T_BYTE, T_BYTE}/* invokeinterface */, {T_SHORT, T_BYTE, T_BYTE}/* invokedynamic */, {T_SHORT}/* new */, + {T_BYTE}/* newarray */, {T_SHORT}/* anewarray */, {}/* arraylength */, {}/* athrow */, {T_SHORT}/* checkcast */, {T_SHORT}/* instanceof */, + {}/* monitorenter */, {}/* monitorexit */, {T_BYTE}/* wide */, {T_SHORT, T_BYTE}/* multianewarray */, {T_SHORT}/* ifnull */, {T_SHORT}/* ifnonnull */, + {T_INT}/* goto_w */, {T_INT}/* jsr_w */, {}/* breakpoint */, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, + {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}/* impdep1 */, {}/* impdep2 */ + }; + /** + * Names of opcodes. Indexed by opcode. OPCODE_NAMES[ALOAD] = "aload". + */ + static final String[] OPCODE_NAMES = {"nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1", "iconst_2", "iconst_3", "iconst_4", "iconst_5", + "lconst_0", "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0", "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload", "lload", + "fload", "dload", "aload", "iload_0", "iload_1", "iload_2", "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0", "fload_1", "fload_2", + "fload_3", "dload_0", "dload_1", "dload_2", "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload", "laload", "faload", "daload", "aaload", + "baload", "caload", "saload", "istore", "lstore", "fstore", "dstore", "astore", "istore_0", "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1", + "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2", "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3", "astore_0", "astore_1", + "astore_2", "astore_3", "iastore", "lastore", "fastore", "dastore", "aastore", "bastore", "castore", "sastore", "pop", "pop2", "dup", "dup_x1", + "dup_x2", "dup2", "dup2_x1", "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub", "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", + "ldiv", "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg", "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr", "iand", + "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f", "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f", "i2b", "i2c", "i2s", + "lcmp", "fcmpl", "fcmpg", "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle", "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", + "if_icmpgt", "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret", "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn", "dreturn", + "areturn", "return", "getstatic", "putstatic", "getfield", "putfield", "invokevirtual", "invokespecial", "invokestatic", "invokeinterface", + "invokedynamic", "new", "newarray", "anewarray", "arraylength", "athrow", "checkcast", "instanceof", "monitorenter", "monitorexit", "wide", + "multianewarray", "ifnull", "ifnonnull", "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, + ILLEGAL_OPCODE, ILLEGAL_OPCODE, "impdep1", "impdep2"}; + /** + * @since 6.0 + */ + public static final int OPCODE_NAMES_LENGTH = OPCODE_NAMES.length; + /** + * Number of words consumed on operand stack by instructions. Indexed by opcode. CONSUME_STACK[FALOAD] = number of words + * consumed from the stack by a faload instruction. + */ + static final int[] CONSUME_STACK = {0/* nop */, 0/* aconst_null */, 0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */, 0/* iconst_2 */, + 0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */, 0/* lconst_0 */, 0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */, 0/* fconst_2 */, 0/* dconst_0 */, + 0/* dconst_1 */, 0/* bipush */, 0/* sipush */, 0/* ldc */, 0/* ldc_w */, 0/* ldc2_w */, 0/* iload */, 0/* lload */, 0/* fload */, 0/* dload */, + 0/* aload */, 0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */, 0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */, + 0/* fload_0 */, 0/* fload_1 */, 0/* fload_2 */, 0/* fload_3 */, 0/* dload_0 */, 0/* dload_1 */, 0/* dload_2 */, 0/* dload_3 */, 0/* aload_0 */, + 0/* aload_1 */, 0/* aload_2 */, 0/* aload_3 */, 2/* iaload */, 2/* laload */, 2/* faload */, 2/* daload */, 2/* aaload */, 2/* baload */, 2/* caload */, + 2/* saload */, 1/* istore */, 2/* lstore */, 1/* fstore */, 2/* dstore */, 1/* astore */, 1/* istore_0 */, 1/* istore_1 */, 1/* istore_2 */, + 1/* istore_3 */, 2/* lstore_0 */, 2/* lstore_1 */, 2/* lstore_2 */, 2/* lstore_3 */, 1/* fstore_0 */, 1/* fstore_1 */, 1/* fstore_2 */, 1/* fstore_3 */, + 2/* dstore_0 */, 2/* dstore_1 */, 2/* dstore_2 */, 2/* dstore_3 */, 1/* astore_0 */, 1/* astore_1 */, 1/* astore_2 */, 1/* astore_3 */, 3/* iastore */, + 4/* lastore */, 3/* fastore */, 4/* dastore */, 3/* aastore */, 3/* bastore */, 3/* castore */, 3/* sastore */, 1/* pop */, 2/* pop2 */, 1/* dup */, + 2/* dup_x1 */, 3/* dup_x2 */, 2/* dup2 */, 3/* dup2_x1 */, 4/* dup2_x2 */, 2/* swap */, 2/* iadd */, 4/* ladd */, 2/* fadd */, 4/* dadd */, 2/* isub */, + 4/* lsub */, 2/* fsub */, 4/* dsub */, 2/* imul */, 4/* lmul */, 2/* fmul */, 4/* dmul */, 2/* idiv */, 4/* ldiv */, 2/* fdiv */, 4/* ddiv */, + 2/* irem */, 4/* lrem */, 2/* frem */, 4/* drem */, 1/* ineg */, 2/* lneg */, 1/* fneg */, 2/* dneg */, 2/* ishl */, 3/* lshl */, 2/* ishr */, + 3/* lshr */, 2/* iushr */, 3/* lushr */, 2/* iand */, 4/* land */, 2/* ior */, 4/* lor */, 2/* ixor */, 4/* lxor */, 0/* iinc */, 1/* i2l */, + 1/* i2f */, 1/* i2d */, 2/* l2i */, 2/* l2f */, 2/* l2d */, 1/* f2i */, 1/* f2l */, 1/* f2d */, 2/* d2i */, 2/* d2l */, 2/* d2f */, 1/* i2b */, + 1/* i2c */, 1/* i2s */, 4/* lcmp */, 2/* fcmpl */, 2/* fcmpg */, 4/* dcmpl */, 4/* dcmpg */, 1/* ifeq */, 1/* ifne */, 1/* iflt */, 1/* ifge */, + 1/* ifgt */, 1/* ifle */, 2/* if_icmpeq */, 2/* if_icmpne */, 2/* if_icmplt */, 2 /* if_icmpge */, 2/* if_icmpgt */, 2/* if_icmple */, 2/* if_acmpeq */, + 2/* if_acmpne */, 0/* goto */, 0/* jsr */, 0/* ret */, 1/* tableswitch */, 1/* lookupswitch */, 1/* ireturn */, 2/* lreturn */, 1/* freturn */, + 2/* dreturn */, 1/* areturn */, 0/* return */, 0/* getstatic */, UNPREDICTABLE/* putstatic */, 1/* getfield */, UNPREDICTABLE/* putfield */, + UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */, UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */, + UNPREDICTABLE/* invokedynamic */, 0/* new */, 1/* newarray */, 1/* anewarray */, 1/* arraylength */, 1/* athrow */, 1/* checkcast */, 1/* instanceof */, + 1/* monitorenter */, 1/* monitorexit */, 0/* wide */, UNPREDICTABLE/* multianewarray */, 1/* ifnull */, 1/* ifnonnull */, 0/* goto_w */, 0/* jsr_w */, + 0/* breakpoint */, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNPREDICTABLE/* impdep1 */, UNPREDICTABLE/* impdep2 */ + }; + /** + * Number of words produced onto operand stack by instructions. Indexed by opcode. CONSUME_STACK[DALOAD] = number of + * words consumed from the stack by a daload instruction. + */ + static final int[] PRODUCE_STACK = {0/* nop */, 1/* aconst_null */, 1/* iconst_m1 */, 1/* iconst_0 */, 1/* iconst_1 */, 1/* iconst_2 */, + 1/* iconst_3 */, 1/* iconst_4 */, 1/* iconst_5 */, 2/* lconst_0 */, 2/* lconst_1 */, 1/* fconst_0 */, 1/* fconst_1 */, 1/* fconst_2 */, 2/* dconst_0 */, + 2/* dconst_1 */, 1/* bipush */, 1/* sipush */, 1/* ldc */, 1/* ldc_w */, 2/* ldc2_w */, 1/* iload */, 2/* lload */, 1/* fload */, 2/* dload */, + 1/* aload */, 1/* iload_0 */, 1/* iload_1 */, 1/* iload_2 */, 1/* iload_3 */, 2/* lload_0 */, 2/* lload_1 */, 2/* lload_2 */, 2/* lload_3 */, + 1/* fload_0 */, 1/* fload_1 */, 1/* fload_2 */, 1/* fload_3 */, 2/* dload_0 */, 2/* dload_1 */, 2/* dload_2 */, 2/* dload_3 */, 1/* aload_0 */, + 1/* aload_1 */, 1/* aload_2 */, 1/* aload_3 */, 1/* iaload */, 2/* laload */, 1/* faload */, 2/* daload */, 1/* aaload */, 1/* baload */, 1/* caload */, + 1/* saload */, 0/* istore */, 0/* lstore */, 0/* fstore */, 0/* dstore */, 0/* astore */, 0/* istore_0 */, 0/* istore_1 */, 0/* istore_2 */, + 0/* istore_3 */, 0/* lstore_0 */, 0/* lstore_1 */, 0/* lstore_2 */, 0/* lstore_3 */, 0/* fstore_0 */, 0/* fstore_1 */, 0/* fstore_2 */, 0/* fstore_3 */, + 0/* dstore_0 */, 0/* dstore_1 */, 0/* dstore_2 */, 0/* dstore_3 */, 0/* astore_0 */, 0/* astore_1 */, 0/* astore_2 */, 0/* astore_3 */, 0/* iastore */, + 0/* lastore */, 0/* fastore */, 0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */, 0/* sastore */, 0/* pop */, 0/* pop2 */, 2/* dup */, + 3/* dup_x1 */, 4/* dup_x2 */, 4/* dup2 */, 5/* dup2_x1 */, 6/* dup2_x2 */, 2/* swap */, 1/* iadd */, 2/* ladd */, 1/* fadd */, 2/* dadd */, 1/* isub */, + 2/* lsub */, 1/* fsub */, 2/* dsub */, 1/* imul */, 2/* lmul */, 1/* fmul */, 2/* dmul */, 1/* idiv */, 2/* ldiv */, 1/* fdiv */, 2/* ddiv */, + 1/* irem */, 2/* lrem */, 1/* frem */, 2/* drem */, 1/* ineg */, 2/* lneg */, 1/* fneg */, 2/* dneg */, 1/* ishl */, 2/* lshl */, 1/* ishr */, + 2/* lshr */, 1/* iushr */, 2/* lushr */, 1/* iand */, 2/* land */, 1/* ior */, 2/* lor */, 1/* ixor */, 2/* lxor */, 0/* iinc */, 2/* i2l */, + 1/* i2f */, 2/* i2d */, 1/* l2i */, 1/* l2f */, 2/* l2d */, 1/* f2i */, 2/* f2l */, 2/* f2d */, 1/* d2i */, 2/* d2l */, 1/* d2f */, 1/* i2b */, + 1/* i2c */, 1/* i2s */, 1/* lcmp */, 1/* fcmpl */, 1/* fcmpg */, 1/* dcmpl */, 1/* dcmpg */, 0/* ifeq */, 0/* ifne */, 0/* iflt */, 0/* ifge */, + 0/* ifgt */, 0/* ifle */, 0/* if_icmpeq */, 0/* if_icmpne */, 0/* if_icmplt */, 0/* if_icmpge */, 0/* if_icmpgt */, 0/* if_icmple */, 0/* if_acmpeq */, + 0/* if_acmpne */, 0/* goto */, 1/* jsr */, 0/* ret */, 0/* tableswitch */, 0/* lookupswitch */, 0/* ireturn */, 0/* lreturn */, 0/* freturn */, + 0/* dreturn */, 0/* areturn */, 0/* return */, UNPREDICTABLE/* getstatic */, 0/* putstatic */, UNPREDICTABLE/* getfield */, 0/* putfield */, + UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */, UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */, + UNPREDICTABLE/* invokedynamic */, 1/* new */, 1/* newarray */, 1/* anewarray */, 1/* arraylength */, 1/* athrow */, 1/* checkcast */, 1/* instanceof */, + 0/* monitorenter */, 0/* monitorexit */, 0/* wide */, 1/* multianewarray */, 0/* ifnull */, 0/* ifnonnull */, 0/* goto_w */, 1/* jsr_w */, + 0/* breakpoint */, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, + UNPREDICTABLE/* impdep1 */, UNPREDICTABLE/* impdep2 */ + }; + /** + * The names of the access flags. + */ + private static final String[] ACCESS_NAMES = {"public", "private", "protected", "static", "final", "synchronized", "volatile", "transient", "native", + "interface", "abstract", "strictfp", "synthetic", "annotation", "enum", "module"}; + /** + * @since 6.0 + */ + public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length; + /** + * The names of the types of entries in a constant pool. Use getConstantName instead + */ + private static final String[] CONSTANT_NAMES = {"", "CONSTANT_Utf8", "", "CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double", + "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType", "", "", + "CONSTANT_MethodHandle", "CONSTANT_MethodType", "CONSTANT_Dynamic", "CONSTANT_InvokeDynamic", "CONSTANT_Module", "CONSTANT_Package"}; + /** + * The names of the interfaces implemented by arrays + */ + private static final String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"}; + /** + * The primitive type names corresponding to the T_XX constants, e.g., TYPE_NAMES[T_INT] = "int" + */ + private static final String[] TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "boolean", "char", "float", "double", "byte", "short", + "int", "long", "void", "array", "object", "unknown", "address"}; + /** + * The primitive class names corresponding to the T_XX constants, e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" + */ + private static final String[] CLASS_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "java.lang.Boolean", "java.lang.Character", + "java.lang.Float", "java.lang.Double", "java.lang.Byte", "java.lang.Short", "java.lang.Integer", "java.lang.Long", "java.lang.Void", ILLEGAL_TYPE, + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE}; + /** + * The signature characters corresponding to primitive types, e.g., SHORT_TYPE_NAMES[T_INT] = "I" + */ + private static final String[] SHORT_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "Z", "C", "F", "D", "B", "S", "I", "J", "V", + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE}; + private static final String[] ATTRIBUTE_NAMES = {"SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable", + "InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", + "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", + "StackMapTable", "BootstrapMethods", "MethodParameters", "Module", "ModulePackages", "ModuleMainClass", "NestHost", "NestMembers"}; + private static final String[] ITEM_NAMES = {"Bogus", "Integer", "Float", "Double", "Long", "Null", "InitObject", "Object", "NewObject"}; + /** + * The names of the reference_kinds of a CONSTANT_MethodHandle_info. + */ + private static final String[] METHODHANDLE_NAMES = {"", "getField", "getStatic", "putField", "putStatic", "invokeVirtual", "invokeStatic", "invokeSpecial", + "newInvokeSpecial", "invokeInterface"}; + + private Const() { + } // not instantiable + + /** + * @param index + * @return the ACCESS_NAMES entry at the given index + * @since 6.0 + */ + public static String getAccessName(final int index) { + return ACCESS_NAMES[index]; + } + + /** + * @param index + * @return the attribute name + * @since 6.0 + */ + public static String getAttributeName(final int index) { + return ATTRIBUTE_NAMES[index]; + } + + /** + * The primitive class names corresponding to the T_XX constants, e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" + * + * @param index + * @return the class name + * @since 6.0 + */ + public static String getClassTypeName(final int index) { + return CLASS_TYPE_NAMES[index]; + } + + // Constants defining the behavior of the Method Handles (JVMS 5.4.3.5) + + /** + * @param index + * @return the CONSTANT_NAMES entry at the given index + * @since 6.0 + */ + public static String getConstantName(final int index) { + return CONSTANT_NAMES[index]; + } + + /** + * @param index + * @return Number of words consumed on operand stack + * @since 6.0 + */ + public static int getConsumeStack(final int index) { + return CONSUME_STACK[index]; + } + + /** + * @since 6.0 + */ + public static Iterable getInterfacesImplementedByArrays() { + return Collections.unmodifiableList(Arrays.asList(INTERFACES_IMPLEMENTED_BY_ARRAYS)); + } + + /** + * @param index + * @return the item name + * @since 6.0 + */ + public static String getItemName(final int index) { + return ITEM_NAMES[index]; + } + + /** + * @param index + * @return the method handle name + * @since 6.0 + */ + public static String getMethodHandleName(final int index) { + return METHODHANDLE_NAMES[index]; + } + + /** + * @param index + * @return Number of byte code operands + * @since 6.0 + */ + public static short getNoOfOperands(final int index) { + return NO_OF_OPERANDS[index]; + } + + /** + * @since 6.0 + */ + public static String getOpcodeName(final int index) { + return OPCODE_NAMES[index]; + } + + /** + * @since 6.0 + */ + public static short getOperandType(final int opcode, final int index) { + return TYPE_OF_OPERANDS[opcode][index]; + } + + /** + * @since 6.0 + */ + public static long getOperandTypeCount(final int opcode) { + return TYPE_OF_OPERANDS[opcode].length; + } + + /** + * @param index + * @return Number of words produced onto operand stack + * @since 6.0 + */ + public static int getProduceStack(final int index) { + return PRODUCE_STACK[index]; + } + + /** + * @param index + * @return the short type name + * @since 6.0 + */ + public static String getShortTypeName(final int index) { + return SHORT_TYPE_NAMES[index]; + } + + /** + * The primitive type names corresponding to the T_XX constants, e.g., TYPE_NAMES[T_INT] = "int" + * + * @param index + * @return the type name + * @since 6.0 + */ + public static String getTypeName(final int index) { + return TYPE_NAMES[index]; + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java new file mode 100644 index 0000000..4f9bbf1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/ExceptionConst.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal; + +import jdk.xml.internal.Utils; + +/** + * Exception constants. + * + * @LastModified: Feb 2023 + * @since 6.0 (intended to replace the InstructionConstant interface) + */ +public final class ExceptionConst { + + /** + * Enum corresponding to the various Exception Class arrays, used by + * {@link ExceptionConst#createExceptions(EXCS, Class...)} + */ + public enum EXCS { + EXCS_CLASS_AND_INTERFACE_RESOLUTION, EXCS_FIELD_AND_METHOD_RESOLUTION, EXCS_INTERFACE_METHOD_RESOLUTION, EXCS_STRING_RESOLUTION, EXCS_ARRAY_EXCEPTION, + } + + /** + * The mother of all exceptions + */ + public static final Class THROWABLE = Throwable.class; + + /** + * Super class of any run-time exception + */ + public static final Class RUNTIME_EXCEPTION = RuntimeException.class; + + /** + * Super class of any linking exception (aka Linkage Error) + */ + public static final Class LINKING_EXCEPTION = LinkageError.class; + + /** + * Linking Exceptions + */ + public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class; + public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class; + public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class; + public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class; + public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class; + public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class; + public static final Class INSTANTIATION_ERROR = InstantiationError.class; + public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class; + public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class; + public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class; + public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class; + public static final Class VERIFY_ERROR = VerifyError.class; + /* UnsupportedClassVersionError is new in JDK 1.2 */ +// public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class; + + /** + * Run-Time Exceptions + */ + public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class; + public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class; + public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class; + public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class; + public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class; + + public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class; + /** + * Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual Machine Specification + */ + private static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, + EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR}; // Chapter 5.1 + + private static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = {NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR}; // Chapter 5.2 + + /** + * Empty array. + */ + private static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) + + /** + * Empty array. + */ + private static final Class[] EXCS_STRING_RESOLUTION = new Class[0]; + + // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) + private static final Class[] EXCS_ARRAY_EXCEPTION = {NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION}; + + /** + * Creates a copy of the specified Exception Class array combined with any additional Exception classes. + * + * @param type the basic array type + * @param extraClasses additional classes, if any + * @return the merged array + */ + public static Class[] createExceptions(final EXCS type, final Class... extraClasses) { + switch (type) { + case EXCS_CLASS_AND_INTERFACE_RESOLUTION: + return mergeExceptions(EXCS_CLASS_AND_INTERFACE_RESOLUTION, extraClasses); + case EXCS_ARRAY_EXCEPTION: + return mergeExceptions(EXCS_ARRAY_EXCEPTION, extraClasses); + case EXCS_FIELD_AND_METHOD_RESOLUTION: + return mergeExceptions(EXCS_FIELD_AND_METHOD_RESOLUTION, extraClasses); + case EXCS_INTERFACE_METHOD_RESOLUTION: + return mergeExceptions(EXCS_INTERFACE_METHOD_RESOLUTION, extraClasses); + case EXCS_STRING_RESOLUTION: + return mergeExceptions(EXCS_STRING_RESOLUTION, extraClasses); + default: + throw new AssertionError("Cannot happen; unexpected enum value: " + type); + } + } + + // helper method to merge exception class arrays + private static Class[] mergeExceptions(final Class[] input, final Class... extraClasses) { + return Utils.arraysAppend(input, extraClasses); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java new file mode 100644 index 0000000..418e5f7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/Repository.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal; + + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.util.SyntheticRepository; + +/** + * The repository maintains informations about class interdependencies, e.g., whether a class is a sub-class of another. + * Delegates actual class loading to SyntheticRepository with current class path by default. + * + * @LastModified: Feb 2023 + * @see com.sun.org.apache.bcel.internal.util.Repository + * @see SyntheticRepository + */ +public abstract class Repository { + + private static com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance(); + + /** + * Adds clazz to repository if there isn't an equally named class already in there. + * + * @return old entry in repository + */ + public static JavaClass addClass(final JavaClass clazz) { + final JavaClass old = repository.findClass(clazz.getClassName()); + repository.storeClass(clazz); + return old; + } + + /** + * Clears the repository. + */ + public static void clearCache() { + repository.clear(); + } + + /** + * @return all interfaces implemented by class and its super classes and the interfaces that those interfaces extend, + * and so on. (Some people call this a transitive hull). + * @throws ClassNotFoundException if any of the class's superclasses or superinterfaces can't be found + */ + public static JavaClass[] getInterfaces(final JavaClass clazz) throws ClassNotFoundException { + return clazz.getAllInterfaces(); + } + + /** + * @return all interfaces implemented by class and its super classes and the interfaces that extend those interfaces, + * and so on + * @throws ClassNotFoundException if the named class can't be found, or if any of its superclasses or superinterfaces + * can't be found + */ + public static JavaClass[] getInterfaces(final String className) throws ClassNotFoundException { + return getInterfaces(lookupClass(className)); + } + + /** + * @return currently used repository instance + */ + public static com.sun.org.apache.bcel.internal.util.Repository getRepository() { + return repository; + } + + /** + * @return list of super classes of clazz in ascending order, i.e., Object is always the last element + * @throws ClassNotFoundException if any of the superclasses can't be found + */ + public static JavaClass[] getSuperClasses(final JavaClass clazz) throws ClassNotFoundException { + return clazz.getSuperClasses(); + } + + /** + * @return list of super classes of clazz in ascending order, i.e., Object is always the last element. + * @throws ClassNotFoundException if the named class or any of its superclasses can't be found + */ + public static JavaClass[] getSuperClasses(final String className) throws ClassNotFoundException { + return getSuperClasses(lookupClass(className)); + } + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if any superclasses or superinterfaces of clazz can't be found + */ + public static boolean implementationOf(final JavaClass clazz, final JavaClass inter) throws ClassNotFoundException { + return clazz.implementationOf(inter); + } + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if inter or any superclasses or superinterfaces of clazz can't be found + */ + public static boolean implementationOf(final JavaClass clazz, final String inter) throws ClassNotFoundException { + return implementationOf(clazz, lookupClass(inter)); + } + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if clazz or any superclasses or superinterfaces of clazz can't be found + */ + public static boolean implementationOf(final String clazz, final JavaClass inter) throws ClassNotFoundException { + return implementationOf(lookupClass(clazz), inter); + } + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if clazz, inter, or any superclasses or superinterfaces of clazz can't be found + */ + public static boolean implementationOf(final String clazz, final String inter) throws ClassNotFoundException { + return implementationOf(lookupClass(clazz), lookupClass(inter)); + } + + /** + * Equivalent to runtime "instanceof" operator. + * + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if any superclasses or superinterfaces of clazz can't be found + */ + public static boolean instanceOf(final JavaClass clazz, final JavaClass superclass) throws ClassNotFoundException { + return clazz.instanceOf(superclass); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if superclass can't be found + */ + public static boolean instanceOf(final JavaClass clazz, final String superclass) throws ClassNotFoundException { + return instanceOf(clazz, lookupClass(superclass)); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if clazz can't be found + */ + public static boolean instanceOf(final String clazz, final JavaClass superclass) throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), superclass); + } + + /** + * @return true, if clazz is an instance of superclass + * @throws ClassNotFoundException if either clazz or superclass can't be found + */ + public static boolean instanceOf(final String clazz, final String superclass) throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), lookupClass(superclass)); + } + + /** + * Tries to find class source using the internal repository instance. + * + * @return JavaClass object for given runtime class + * @throws ClassNotFoundException if the class could not be found or parsed correctly + * @see Class + */ + public static JavaClass lookupClass(final Class clazz) throws ClassNotFoundException { + return repository.loadClass(clazz); + } + + /** + * Lookups class somewhere found on your CLASSPATH, or wherever the repository instance looks for it. + * + * @return class object for given fully qualified class name + * @throws ClassNotFoundException if the class could not be found or parsed correctly + */ + public static JavaClass lookupClass(final String className) throws ClassNotFoundException { + return repository.loadClass(className); + } + + /** + * Removes given class from repository. + */ + public static void removeClass(final JavaClass clazz) { + repository.removeClass(clazz); + } + + /** + * Removes class with given (fully qualified) name from repository. + */ + public static void removeClass(final String clazz) { + repository.removeClass(repository.findClass(clazz)); + } + + /** + * Sets repository instance to be used for class loading + */ + public static void setRepository(final com.sun.org.apache.bcel.internal.util.Repository rep) { + repository = rep; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java new file mode 100644 index 0000000..dde4554 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for all objects that have modifiers like private, final, ... I.e. + * classes, fields, and methods. + * + * @LastModified: Jan 2020 + */ +public abstract class AccessFlags { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int access_flags; // TODO not used externally at present + + public AccessFlags() { + } + + /** + * @param a initial access flags + */ + public AccessFlags(final int a) { + access_flags = a; + } + + /** + * @return Access flags of the object aka. "modifiers". + */ + public final int getAccessFlags() { + return access_flags; + } + + /** + * Set access flags aka "modifiers". + * + * @param accessFlags Access flags of the object. + */ + public final void setAccessFlags(final int accessFlags) { + this.access_flags = accessFlags; + } + + /** + * @return Access flags of the object aka. "modifiers". + */ + public final int getModifiers() { + return access_flags; + } + + /** + * Set access flags aka "modifiers". + * + * @param accessFlags Access flags of the object. + */ + public final void setModifiers(final int accessFlags) { + setAccessFlags(accessFlags); + } + + public final boolean isAbstract() { + return (access_flags & Const.ACC_ABSTRACT) != 0; + } + + public final void isAbstract(final boolean flag) { + setFlag(Const.ACC_ABSTRACT, flag); + } + + public final boolean isAnnotation() { + return (access_flags & Const.ACC_ANNOTATION) != 0; + } + + public final void isAnnotation(final boolean flag) { + setFlag(Const.ACC_ANNOTATION, flag); + } + + public final boolean isEnum() { + return (access_flags & Const.ACC_ENUM) != 0; + } + + public final void isEnum(final boolean flag) { + setFlag(Const.ACC_ENUM, flag); + } + + public final boolean isFinal() { + return (access_flags & Const.ACC_FINAL) != 0; + } + + public final void isFinal(final boolean flag) { + setFlag(Const.ACC_FINAL, flag); + } + + public final boolean isInterface() { + return (access_flags & Const.ACC_INTERFACE) != 0; + } + + public final void isInterface(final boolean flag) { + setFlag(Const.ACC_INTERFACE, flag); + } + + public final boolean isNative() { + return (access_flags & Const.ACC_NATIVE) != 0; + } + + public final void isNative(final boolean flag) { + setFlag(Const.ACC_NATIVE, flag); + } + + public final boolean isPrivate() { + return (access_flags & Const.ACC_PRIVATE) != 0; + } + + public final void isPrivate(final boolean flag) { + setFlag(Const.ACC_PRIVATE, flag); + } + + public final boolean isProtected() { + return (access_flags & Const.ACC_PROTECTED) != 0; + } + + public final void isProtected(final boolean flag) { + setFlag(Const.ACC_PROTECTED, flag); + } + + public final boolean isPublic() { + return (access_flags & Const.ACC_PUBLIC) != 0; + } + + public final void isPublic(final boolean flag) { + setFlag(Const.ACC_PUBLIC, flag); + } + + public final boolean isStatic() { + return (access_flags & Const.ACC_STATIC) != 0; + } + + public final void isStatic(final boolean flag) { + setFlag(Const.ACC_STATIC, flag); + } + + public final boolean isStrictfp() { + return (access_flags & Const.ACC_STRICT) != 0; + } + + public final void isStrictfp(final boolean flag) { + setFlag(Const.ACC_STRICT, flag); + } + + public final boolean isSynchronized() { + return (access_flags & Const.ACC_SYNCHRONIZED) != 0; + } + + public final void isSynchronized(final boolean flag) { + setFlag(Const.ACC_SYNCHRONIZED, flag); + } + + public final boolean isSynthetic() { + return (access_flags & Const.ACC_SYNTHETIC) != 0; + } + + public final void isSynthetic(final boolean flag) { + setFlag(Const.ACC_SYNTHETIC, flag); + } + + public final boolean isTransient() { + return (access_flags & Const.ACC_TRANSIENT) != 0; + } + + public final void isTransient(final boolean flag) { + setFlag(Const.ACC_TRANSIENT, flag); + } + + public final boolean isVarArgs() { + return (access_flags & Const.ACC_VARARGS) != 0; + } + + public final void isVarArgs(final boolean flag) { + setFlag(Const.ACC_VARARGS, flag); + } + + public final boolean isVolatile() { + return (access_flags & Const.ACC_VOLATILE) != 0; + } + + public final void isVolatile(final boolean flag) { + setFlag(Const.ACC_VOLATILE, flag); + } + + private void setFlag(final int flag, final boolean set) { + if ((access_flags & flag) != 0) { // Flag is set already + if (!set) { + access_flags ^= flag; + } + } else if (set) { + access_flags |= flag; + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java new file mode 100644 index 0000000..eeae14b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java @@ -0,0 +1,96 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents the default value of a annotation for a method info. + * + * @since 6.0 + */ +public class AnnotationDefault extends Attribute { + + private ElementValue defaultValue; + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + */ + AnnotationDefault(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (ElementValue) null, constantPool); + defaultValue = ElementValue.readElementValue(input, constantPool); + } + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param defaultValue the annotation's default value + * @param constantPool Array of constants + */ + public AnnotationDefault(final int nameIndex, final int length, final ElementValue defaultValue, final ConstantPool constantPool) { + super(Const.ATTR_ANNOTATION_DEFAULT, nameIndex, length, constantPool); + this.defaultValue = defaultValue; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotationDefault(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + defaultValue.dump(dos); + } + + /** + * @return the default value + */ + public final ElementValue getDefaultValue() { + return defaultValue; + } + + /** + * @param defaultValue the default value of this methodinfo's annotation + */ + public final void setDefaultValue(final ElementValue defaultValue) { + this.defaultValue = defaultValue; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java new file mode 100644 index 0000000..8d61825 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class AnnotationElementValue extends ElementValue { + // For annotation element values, this is the annotation + private final AnnotationEntry annotationEntry; + + public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry, final ConstantPool cpool) { + super(type, cpool); + if (type != ANNOTATION) { + throw new ClassFormatException("Only element values of type annotation can be built with this ctor - type specified: " + type); + } + this.annotationEntry = annotationEntry; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 type of value (ANNOTATION == '@') + annotationEntry.dump(dos); + } + + public AnnotationEntry getAnnotationEntry() { + return annotationEntry; + } + + @Override + public String stringifyValue() { + return annotationEntry.toString(); + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java new file mode 100644 index 0000000..033ba34 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * Represents one annotation in the annotation table + * + * @since 6.0 + */ +public class AnnotationEntry implements Node { + + public static final AnnotationEntry[] EMPTY_ARRAY = {}; + private final int typeIndex; + private final ConstantPool constantPool; + private final boolean isRuntimeVisible; + private List elementValuePairs; + + public AnnotationEntry(final int typeIndex, final ConstantPool constantPool, final boolean isRuntimeVisible) { + this.typeIndex = typeIndex; + this.constantPool = constantPool; + this.isRuntimeVisible = isRuntimeVisible; + } + + public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs) { + // Find attributes that contain annotation data + return Stream.of(attrs).filter(Annotations.class::isInstance).flatMap(e -> Stream.of(((Annotations) e).getAnnotationEntries())) + .toArray(AnnotationEntry[]::new); + } + + /** + * Factory method to create an AnnotionEntry from a DataInput + * + * @param input + * @param constantPool + * @param isRuntimeVisible + * @return the entry + * @throws IOException if an I/O error occurs. + */ + public static AnnotationEntry read(final DataInput input, final ConstantPool constantPool, final boolean isRuntimeVisible) throws IOException { + final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constantPool, isRuntimeVisible); + final int numElementValuePairs = input.readUnsignedShort(); + annotationEntry.elementValuePairs = new ArrayList<>(); + for (int i = 0; i < numElementValuePairs; i++) { + annotationEntry.elementValuePairs + .add(new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constantPool), constantPool)); + } + return annotationEntry; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotationEntry(this); + } + + public void addElementNameValuePair(final ElementValuePair elementNameValuePair) { + elementValuePairs.add(elementNameValuePair); + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(typeIndex); // u2 index of type name in cpool + dos.writeShort(elementValuePairs.size()); // u2 element_value pair + // count + for (final ElementValuePair envp : elementValuePairs) { + envp.dump(dos); + } + } + + /** + * @return the annotation type name + */ + public String getAnnotationType() { + return constantPool.getConstantUtf8(typeIndex).getBytes(); + } + + /** + * @return the annotation type index + */ + public int getAnnotationTypeIndex() { + return typeIndex; + } + + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return the element value pairs in this annotation entry + */ + public ElementValuePair[] getElementValuePairs() { + // TODO return List + return elementValuePairs.toArray(ElementValuePair.EMPTY_ARRAY); + } + + /** + * @return the number of element value pairs in this annotation entry + */ + public final int getNumElementValuePairs() { + return elementValuePairs.size(); + } + + public int getTypeIndex() { + return typeIndex; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + public String toShortString() { + final StringBuilder result = new StringBuilder(); + result.append("@"); + result.append(getAnnotationType()); + final ElementValuePair[] evPairs = getElementValuePairs(); + if (evPairs.length > 0) { + result.append("("); + for (final ElementValuePair element : evPairs) { + result.append(element.toShortString()); + result.append(", "); + } + // remove last ", " + result.setLength(result.length() - 2); + result.append(")"); + } + return result.toString(); + } + + @Override + public String toString() { + return toShortString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java new file mode 100644 index 0000000..077cb6b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Annotations.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * base class for annotations + * + * @since 6.0 + */ +public abstract class Annotations extends Attribute implements Iterable { + + private final boolean isRuntimeVisible; + private AnnotationEntry[] annotationTable; + + /** + * Constructs an instance. + * + * @param annotationType the subclass type of the annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param annotationTable the actual annotations + * @param constantPool Array of constants + * @param isRuntimeVisible whether this Annotation visible at runtime + */ + public Annotations(final byte annotationType, final int nameIndex, final int length, final AnnotationEntry[] annotationTable, + final ConstantPool constantPool, final boolean isRuntimeVisible) { + super(annotationType, nameIndex, length, constantPool); + this.annotationTable = annotationTable; + this.isRuntimeVisible = isRuntimeVisible; + } + + /** + * Constructs an instance. + * + * @param annotationType the subclass type of the annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @param isRuntimeVisible whether this Annotation visible at runtime + * @throws IOException if an I/O error occurs. + */ + Annotations(final byte annotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool, + final boolean isRuntimeVisible) throws IOException { + this(annotationType, nameIndex, length, (AnnotationEntry[]) null, constantPool, isRuntimeVisible); + final int annotationTableLength = input.readUnsignedShort(); + annotationTable = new AnnotationEntry[annotationTableLength]; + for (int i = 0; i < annotationTableLength; i++) { + annotationTable[i] = AnnotationEntry.read(input, constantPool, isRuntimeVisible); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly + * defined by the contents of a Java class. I.e., the hierarchy of methods, + * fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotation(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + // TODO Auto-generated method stub + return null; + } + + /** + * Gets the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotationTable; + } + + /** + * Gets the number of annotation entries in this annotation. + * + * @return the number of annotation entries in this annotation + */ + public final int getNumAnnotations() { + if (annotationTable == null) { + return 0; + } + return annotationTable.length; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + @Override + public Iterator iterator() { + return Stream.of(annotationTable).iterator(); + } + + /** + * Sets the entries to set in this annotation. + * + * @param annotationTable the entries to set in this annotation + */ + public final void setAnnotationTable(final AnnotationEntry[] annotationTable) { + this.annotationTable = annotationTable; + } + + /** + * Converts to a String representation. + * + * @return String representation + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(Const.getAttributeName(getTag())); + buf.append(":\n"); + for (int i = 0; i < annotationTable.length; i++) { + buf.append(" ").append(annotationTable[i]); + if (i < annotationTable.length - 1) { + buf.append('\n'); + } + } + return buf.toString(); + } + + protected void writeAnnotations(final DataOutputStream dos) throws IOException { + if (annotationTable == null) { + return; + } + dos.writeShort(annotationTable.length); + for (final AnnotationEntry element : annotationTable) { + element.dump(dos); + } + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java new file mode 100644 index 0000000..e876888 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java @@ -0,0 +1,86 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class ArrayElementValue extends ElementValue { + // For array types, this is the array + private final ElementValue[] elementValues; + + public ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool) { + super(type, cpool); + if (type != ARRAY) { + throw new ClassFormatException("Only element values of type array can be built with this ctor - type specified: " + type); + } + this.elementValues = datums; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 type of value (ARRAY == '[') + dos.writeShort(elementValues.length); + for (final ElementValue evalue : elementValues) { + evalue.dump(dos); + } + } + + public ElementValue[] getElementValuesArray() { + return elementValues; + } + + public int getElementValuesArraySize() { + return elementValues.length; + } + + @Override + public String stringifyValue() { + final StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < elementValues.length; i++) { + sb.append(elementValues[i].stringifyValue()); + if (i + 1 < elementValues.length) { + sb.append(","); + } + } + sb.append("]"); + return sb.toString(); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("{"); + for (int i = 0; i < elementValues.length; i++) { + sb.append(elementValues[i]); + if (i + 1 < elementValues.length) { + sb.append(","); + } + } + sb.append("}"); + return sb.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java new file mode 100644 index 0000000..b015db9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Attribute.java @@ -0,0 +1,362 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * Abstract super class for Attribute objects. Currently the ConstantValue, SourceFile, Code, Exceptiontable, + * LineNumberTable, LocalVariableTable, InnerClasses and Synthetic attributes are supported. The Unknown attribute + * stands for non-standard-attributes. + * + *

+ * attribute_info {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u1 info[attribute_length];
+ * }
+ * 
+ * + * @LastModified: Feb 2023 + * @see ConstantValue + * @see SourceFile + * @see Code + * @see Unknown + * @see ExceptionTable + * @see LineNumberTable + * @see LocalVariableTable + * @see InnerClasses + * @see Synthetic + * @see Deprecated + * @see Signature + */ +public abstract class Attribute implements Cloneable, Node { + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final Attribute[] EMPTY_ARRAY = {}; + private static final boolean debug = false; + private static final Map READERS = new HashMap<>(); + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_index; // Points to attribute name in constant pool TODO make private (has getter & setter) + /** + * @deprecated (since 6.0) (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int length; // Content length of attribute field TODO make private (has getter & setter) + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected byte tag; // Tag to distinguish subclasses TODO make private & final; supposed to be immutable + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected ConstantPool constant_pool; // TODO make private (has getter & setter) + + /** + * Constructs an instance. + * + *
+     * attribute_info {
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *   u1 info[attribute_length];
+     * }
+     * 
+ * + * @param tag tag. + * @param nameIndex u2 name index. + * @param length u4 length. + * @param constantPool constant pool. + */ + protected Attribute(final byte tag, final int nameIndex, final int length, final ConstantPool constantPool) { + this.tag = tag; + this.name_index = Args.requireU2(nameIndex, 0, constantPool.getLength(), getClass().getSimpleName() + " name index"); + this.length = Args.requireU4(length, getClass().getSimpleName() + " attribute length"); + this.constant_pool = constantPool; + } + + /** + * Add an Attribute reader capable of parsing (user-defined) attributes named "name". You should not add readers for the + * standard attributes such as "LineNumberTable", because those are handled internally. + * + * @param name the name of the attribute as stored in the class file + * @param unknownAttributeReader the reader object + */ + public static void addAttributeReader(final String name, final UnknownAttributeReader unknownAttributeReader) { + READERS.put(name, unknownAttributeReader); + } + + protected static void println(final String msg) { + if (debug) { + System.err.println(msg); + } + } + + /** + * Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It + * is called by the Field and Method constructor methods. + * + * @param dataInput Input stream + * @param constantPool Array of constants + * @return Attribute + * @throws IOException if an I/O error occurs. + * @see Field + * @see Method + * @since 6.0 + */ + public static Attribute readAttribute(final DataInput dataInput, final ConstantPool constantPool) throws IOException { + byte tag = Const.ATTR_UNKNOWN; // Unknown attribute + // Get class name from constant pool via 'name_index' indirection + final int nameIndex = dataInput.readUnsignedShort(); + final String name = constantPool.getConstantUtf8(nameIndex).getBytes(); + + // Length of data in bytes + final int length = dataInput.readInt(); + + // Compare strings to find known attribute + for (byte i = 0; i < Const.KNOWN_ATTRIBUTES; i++) { + if (name.equals(Const.getAttributeName(i))) { + tag = i; // found! + break; + } + } + + // Call proper constructor, depending on 'tag' + switch (tag) { + case Const.ATTR_UNKNOWN: + final Object r = READERS.get(name); + if (r instanceof UnknownAttributeReader) { + return ((UnknownAttributeReader) r).createAttribute(nameIndex, length, dataInput, constantPool); + } + return new Unknown(nameIndex, length, dataInput, constantPool); + case Const.ATTR_CONSTANT_VALUE: + return new ConstantValue(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SOURCE_FILE: + return new SourceFile(nameIndex, length, dataInput, constantPool); + case Const.ATTR_CODE: + return new Code(nameIndex, length, dataInput, constantPool); + case Const.ATTR_EXCEPTIONS: + return new ExceptionTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LINE_NUMBER_TABLE: + return new LineNumberTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LOCAL_VARIABLE_TABLE: + return new LocalVariableTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_INNER_CLASSES: + return new InnerClasses(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SYNTHETIC: + return new Synthetic(nameIndex, length, dataInput, constantPool); + case Const.ATTR_DEPRECATED: + return new Deprecated(nameIndex, length, dataInput, constantPool); + case Const.ATTR_PMG: + return new PMGClass(nameIndex, length, dataInput, constantPool); + case Const.ATTR_SIGNATURE: + return new Signature(nameIndex, length, dataInput, constantPool); + case Const.ATTR_STACK_MAP: + // old style stack map: unneeded for JDK5 and below; + // illegal(?) for JDK6 and above. So just delete with a warning. + println("Warning: Obsolete StackMap attribute ignored."); + return new Unknown(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: + return new RuntimeVisibleAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: + return new RuntimeInvisibleAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeVisibleParameterAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeInvisibleParameterAnnotations(nameIndex, length, dataInput, constantPool); + case Const.ATTR_ANNOTATION_DEFAULT: + return new AnnotationDefault(nameIndex, length, dataInput, constantPool); + case Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE: + return new LocalVariableTypeTable(nameIndex, length, dataInput, constantPool); + case Const.ATTR_ENCLOSING_METHOD: + return new EnclosingMethod(nameIndex, length, dataInput, constantPool); + case Const.ATTR_STACK_MAP_TABLE: + // read new style stack map: StackMapTable. The rest of the code + // calls this a StackMap for historical reasons. + return new StackMap(nameIndex, length, dataInput, constantPool); + case Const.ATTR_BOOTSTRAP_METHODS: + return new BootstrapMethods(nameIndex, length, dataInput, constantPool); + case Const.ATTR_METHOD_PARAMETERS: + return new MethodParameters(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE: + return new Module(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE_PACKAGES: + return new ModulePackages(nameIndex, length, dataInput, constantPool); + case Const.ATTR_MODULE_MAIN_CLASS: + return new ModuleMainClass(nameIndex, length, dataInput, constantPool); + case Const.ATTR_NEST_HOST: + return new NestHost(nameIndex, length, dataInput, constantPool); + case Const.ATTR_NEST_MEMBERS: + return new NestMembers(nameIndex, length, dataInput, constantPool); + default: + // Never reached + throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag); + } + } + + /** + * Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It + * is called by the Field and Method constructor methods. + * + * @param dataInputStream Input stream + * @param constantPool Array of constants + * @return Attribute + * @throws IOException if an I/O error occurs. + * @see Field + * @see Method + */ + public static Attribute readAttribute(final DataInputStream dataInputStream, final ConstantPool constantPool) throws IOException { + return readAttribute((DataInput) dataInputStream, constantPool); + } + + /** + * Remove attribute reader + * + * @param name the name of the attribute as stored in the class file + */ + public static void removeAttributeReader(final String name) { + READERS.remove(name); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public abstract void accept(Visitor v); + + /** + * Use copy() if you want to have a deep copy(), i.e., with all references copied correctly. + * + * @return shallow copy of this attribute + */ + @Override + public Object clone() { + Attribute attr = null; + try { + attr = (Attribute) super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + return attr; + } + + /** + * @param constantPool constant pool to save. + * @return deep copy of this attribute. + */ + public abstract Attribute copy(ConstantPool constantPool); + + /** + * Dumps attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(name_index); + file.writeInt(length); + } + + /** + * @return Constant pool used by this object. + * @see ConstantPool + */ + public final ConstantPool getConstantPool() { + return constant_pool; + } + + /** + * @param constantPool Constant pool to be used for this object. + * @see ConstantPool + */ + public final void setConstantPool(final ConstantPool constantPool) { + this.constant_pool = constantPool; + } + + /** + * @return Length of attribute field in bytes. + */ + public final int getLength() { + return length; + } + + /** + * @param length length in bytes. + */ + public final void setLength(final int length) { + this.length = length; + } + + /** + * @return Name of attribute + * @since 6.0 + */ + public String getName() { + return constant_pool.getConstantUtf8(name_index).getBytes(); + } + + /** + * @return Name index in constant pool of attribute name. + */ + public final int getNameIndex() { + return name_index; + } + + /** + * @param nameIndex of attribute. + */ + public final void setNameIndex(final int nameIndex) { + this.name_index = nameIndex; + } + + /** + * @return Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method. + */ + public final byte getTag() { + return tag; + } + + /** + * @return attribute name. + */ + @Override + public String toString() { + return Const.getAttributeName(tag); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java new file mode 100644 index 0000000..5535750 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java @@ -0,0 +1,49 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the + * Attribute.addAttributeReader method. These factory objects should implement this interface. + * + * @see Attribute + * @deprecated Use UnknownAttributeReader instead + */ +@java.lang.Deprecated +public interface AttributeReader { + + /** + * When this attribute reader is added via the static method Attribute.addAttributeReader, an attribute name is + * associated with it. As the class file parser parses attributes, it will call various AttributeReaders based on the + * name of the attributes it is constructing. + * + * @param nameIndex An index into the constant pool, indexing a ConstantUtf8 that represents the name of the attribute. + * @param length The length of the data contained in the attribute. This is written into the constant pool and should + * agree with what the factory expects the length to be. + * @param file This is the data input stream that the factory needs to read its data from. + * @param constantPool This is the constant pool associated with the Attribute that we are constructing. + * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of + * errors, a null can be returned which will cause the parsing of the class file to fail. + * @see Attribute#addAttributeReader(String, AttributeReader) + */ + Attribute createAttribute(int nameIndex, int length, java.io.DataInputStream file, ConstantPool constantPool); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java new file mode 100644 index 0000000..1e68d27 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java @@ -0,0 +1,174 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a bootstrap method attribute, i.e., the bootstrap method ref, the number of bootstrap arguments + * and an array of the bootstrap arguments. + * + * @see The class File Format : + * The BootstrapMethods Attribute + * @since 6.0 + */ +public class BootstrapMethod implements Cloneable { + + /** + * Index of the CONSTANT_MethodHandle_info structure in the constant_pool table + */ + private int bootstrapMethodRef; + + /** + * Array of references to the constant_pool table + */ + private int[] bootstrapArguments; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public BootstrapMethod(final BootstrapMethod c) { + this(c.getBootstrapMethodRef(), c.getBootstrapArguments()); + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + */ + BootstrapMethod(final DataInput input) throws IOException { + this(input.readUnsignedShort(), input.readUnsignedShort()); + + for (int i = 0; i < bootstrapArguments.length; i++) { + bootstrapArguments[i] = input.readUnsignedShort(); + } + } + + // helper method + private BootstrapMethod(final int bootstrapMethodRef, final int numBootstrapArguments) { + this(bootstrapMethodRef, new int[numBootstrapArguments]); + } + + /** + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info + */ + public BootstrapMethod(final int bootstrapMethodRef, final int[] bootstrapArguments) { + this.bootstrapMethodRef = bootstrapMethodRef; + this.bootstrapArguments = bootstrapArguments; + } + + /** + * @return deep copy of this object + */ + public BootstrapMethod copy() { + try { + return (BootstrapMethod) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump object to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(bootstrapMethodRef); + file.writeShort(bootstrapArguments.length); + for (final int bootstrapArgument : bootstrapArguments) { + file.writeShort(bootstrapArgument); + } + } + + /** + * @return int[] of bootstrap_method indices into constant_pool of CONSTANT_[type]_info + */ + public int[] getBootstrapArguments() { + return bootstrapArguments; + } + + /** + * @param bootstrapArguments int[] indices into constant_pool of CONSTANT_[type]_info + */ + public void setBootstrapArguments(final int[] bootstrapArguments) { + this.bootstrapArguments = bootstrapArguments; + } + + /** + * @return index into constant_pool of bootstrap_method + */ + public int getBootstrapMethodRef() { + return bootstrapMethodRef; + } + + /** + * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle + */ + public void setBootstrapMethodRef(final int bootstrapMethodRef) { + this.bootstrapMethodRef = bootstrapMethodRef; + } + + /** + * @return count of number of boostrap arguments + */ + public int getNumBootstrapArguments() { + return bootstrapArguments.length; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + return "BootstrapMethod(" + bootstrapMethodRef + ", " + bootstrapArguments.length + ", " + Arrays.toString(bootstrapArguments) + ")"; + } + + /** + * @return Resolved string representation + */ + public final String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String bootstrapMethodName = constantPool.constantToString(bootstrapMethodRef, Const.CONSTANT_MethodHandle); + buf.append(Utility.compactClassName(bootstrapMethodName, false)); + final int bootstrapArgumentsLen = bootstrapArguments.length; + if (bootstrapArgumentsLen > 0) { + buf.append("\nMethod Arguments:"); + for (int i = 0; i < bootstrapArgumentsLen; i++) { + buf.append("\n ").append(i).append(": "); + buf.append(constantPool.constantToString(constantPool.getConstant(bootstrapArguments[i]))); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java new file mode 100644 index 0000000..849866c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a BootstrapMethods attribute. + * + * @see The class File Format : + * The BootstrapMethods Attribute + * @since 6.0 + */ +public class BootstrapMethods extends Attribute implements Iterable { + + private BootstrapMethod[] bootstrapMethods; // TODO this could be made final (setter is not used) + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public BootstrapMethods(final BootstrapMethods c) { + this(c.getNameIndex(), c.getLength(), c.getBootstrapMethods(), c.getConstantPool()); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param bootstrapMethods array of bootstrap methods + * @param constantPool Array of constants + */ + public BootstrapMethods(final int nameIndex, final int length, final BootstrapMethod[] bootstrapMethods, final ConstantPool constantPool) { + super(Const.ATTR_BOOTSTRAP_METHODS, nameIndex, length, constantPool); + this.bootstrapMethods = bootstrapMethods; + } + + /** + * Construct object from Input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + BootstrapMethods(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (BootstrapMethod[]) null, constantPool); + + final int numBootstrapMethods = input.readUnsignedShort(); + bootstrapMethods = new BootstrapMethod[numBootstrapMethods]; + for (int i = 0; i < numBootstrapMethods; i++) { + bootstrapMethods[i] = new BootstrapMethod(input); + } + } + + /** + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitBootstrapMethods(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public BootstrapMethods copy(final ConstantPool constantPool) { + final BootstrapMethods c = (BootstrapMethods) clone(); + c.bootstrapMethods = new BootstrapMethod[bootstrapMethods.length]; + + for (int i = 0; i < bootstrapMethods.length; i++) { + c.bootstrapMethods[i] = bootstrapMethods[i].copy(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump bootstrap methods attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + + file.writeShort(bootstrapMethods.length); + for (final BootstrapMethod bootstrapMethod : bootstrapMethods) { + bootstrapMethod.dump(file); + } + } + + /** + * @return array of bootstrap method "records" + */ + public final BootstrapMethod[] getBootstrapMethods() { + return bootstrapMethods; + } + + /** + * @param bootstrapMethods the array of bootstrap methods + */ + public final void setBootstrapMethods(final BootstrapMethod[] bootstrapMethods) { + this.bootstrapMethods = bootstrapMethods; + } + + @Override + public Iterator iterator() { + return Stream.of(bootstrapMethods).iterator(); + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("BootstrapMethods("); + buf.append(bootstrapMethods.length); + buf.append("):"); + for (int i = 0; i < bootstrapMethods.length; i++) { + buf.append("\n"); + final int start = buf.length(); + buf.append(" ").append(i).append(": "); + final int indentCount = buf.length() - start; + final String[] lines = bootstrapMethods[i].toString(super.getConstantPool()).split("\\r?\\n"); + buf.append(lines[0]); + for (int j = 1; j < lines.length; j++) { + buf.append("\n").append(" ", 0, indentCount).append(lines[j]); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java new file mode 100644 index 0000000..3df0eb9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java @@ -0,0 +1,59 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class ClassElementValue extends ElementValue { + // For primitive types and string type, this points to the value entry in + // the cpool + // For 'class' this points to the class entry in the cpool + private final int idx; + + public ClassElementValue(final int type, final int idx, final ConstantPool cpool) { + super(type, cpool); + this.idx = idx; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 kind of value + dos.writeShort(idx); + } + + public String getClassString() { + return super.getConstantPool().getConstantUtf8(idx).getBytes(); + } + + public int getIndex() { + return idx; + } + + @Override + public String stringifyValue() { + return super.getConstantPool().getConstantUtf8(idx).getBytes(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java new file mode 100644 index 0000000..a61e1d7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java @@ -0,0 +1,73 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Thrown when the BCEL attempts to read a class file and determines that a class is malformed or otherwise cannot be interpreted as a class file. + */ +public class ClassFormatException extends RuntimeException { + + private static final long serialVersionUID = -3569097343160139969L; + + /** + * Constructs a new instance with {@code null} as its detail message. The cause is not initialized, and may subsequently be initialized by a call to + * {@link #initCause}. + */ + public ClassFormatException() { + } + + /** + * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to + * {@link #initCause}. + * + * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. + */ + public ClassFormatException(final String message) { + super(message); + } + + /** + * Constructs a new instance with the specified detail message and cause. + *

+ * Note that the detail message associated with {@code cause} is not automatically incorporated in this runtime exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that + * the cause is nonexistent or unknown.) + * @since 6.0 + */ + public ClassFormatException(final String message, final Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the + * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables. + * + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the + * cause is nonexistent or unknown.) + * @since 6.7.0 + */ + public ClassFormatException(final Throwable cause) { + super(cause); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java new file mode 100644 index 0000000..4f46b0e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ClassParser.java @@ -0,0 +1,297 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Wrapper class that parses a given Java .class file. The method parse returns a + * JavaClass object on success. When an I/O error or an inconsistency occurs an + * appropriate exception is propagated back to the caller. + *

+ * The structure and the names comply, except for a few conveniences, exactly with the + * JVM specification 1.0. See this paper for further details about + * the structure of a bytecode file. + */ +public final class ClassParser { + + private static final int BUFSIZE = 8192; + private final boolean fileOwned; + private final String fileName; + private final boolean isZip; // Loaded from zip file + private DataInputStream dataInputStream; + private String zipFile; + private int classNameIndex; + private int superclassNameIndex; + private int major; // Compiler version + private int minor; // Compiler version + private int accessFlags; // Access rights of parsed class + private int[] interfaces; // Names of implemented interfaces + private ConstantPool constantPool; // collection of constants + private Field[] fields; // class fields, i.e., its variables + private Method[] methods; // methods defined in the class + private Attribute[] attributes; // attributes defined in the class + + /** + * Parses class from the given stream. + * + * @param inputStream Input stream + * @param fileName File name + */ + public ClassParser(final InputStream inputStream, final String fileName) { + this.fileName = fileName; + this.fileOwned = false; + final String clazz = inputStream.getClass().getName(); // Not a very clean solution ... + this.isZip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); + if (inputStream instanceof DataInputStream) { + this.dataInputStream = (DataInputStream) inputStream; + } else { + this.dataInputStream = new DataInputStream(new BufferedInputStream(inputStream, BUFSIZE)); + } + } + + /** + * Parses class from given .class file. + * + * @param fileName file name + */ + public ClassParser(final String fileName) { + this.isZip = false; + this.fileName = fileName; + this.fileOwned = true; + } + + /** + * Parses class from given .class file in a ZIP-archive + * + * @param zipFile zip file name + * @param fileName file name + */ + public ClassParser(final String zipFile, final String fileName) { + this.isZip = true; + this.fileOwned = true; + this.zipFile = zipFile; + this.fileName = fileName; + } + + /** + * Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods, + * fields and commands. A ClassFormatException is raised, if the file is not a valid .class file. (This does + * not include verification of the byte code as it is performed by the java interpreter). + * + * @return Class object representing the parsed class file + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public JavaClass parse() throws IOException, ClassFormatException { + ZipFile zip = null; + try { + if (fileOwned) { + if (isZip) { + zip = new ZipFile(zipFile); + final ZipEntry entry = zip.getEntry(fileName); + + if (entry == null) { + throw new IOException("File " + fileName + " not found"); + } + + dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), BUFSIZE)); + } else { + dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName), BUFSIZE)); + } + } + /****************** Read headers ********************************/ + // Check magic tag of class file + readID(); + // Get compiler version + readVersion(); + /****************** Read constant pool and related **************/ + // Read constant pool entries + readConstantPool(); + // Get class information + readClassInfo(); + // Get interface information, i.e., implemented interfaces + readInterfaces(); + /****************** Read class fields and methods ***************/ + // Read class fields, i.e., the variables of the class + readFields(); + // Read class methods, i.e., the functions in the class + readMethods(); + // Read class attributes + readAttributes(); + // Check for unknown variables + // Unknown[] u = Unknown.getUnknownAttributes(); + // for (int i=0; i < u.length; i++) + // System.err.println("WARNING: " + u[i]); + // Everything should have been read now + // if(file.available() > 0) { + // int bytes = file.available(); + // byte[] buf = new byte[bytes]; + // file.read(buf); + // if(!(isZip && (buf.length == 1))) { + // System.err.println("WARNING: Trailing garbage at end of " + fileName); + // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf)); + // } + // } + } finally { + // Read everything of interest, so close the file + if (fileOwned) { + try { + if (dataInputStream != null) { + dataInputStream.close(); + } + } catch (final IOException ignored) { + // ignore close exceptions + } + } + try { + if (zip != null) { + zip.close(); + } + } catch (final IOException ignored) { + // ignore close exceptions + } + } + // Return the information we have gathered in a new object + return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes, + isZip ? JavaClass.ZIP : JavaClass.FILE); + } + + /** + * Reads information about the attributes of the class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readAttributes() throws IOException, ClassFormatException { + final int attributesCount = dataInputStream.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(dataInputStream, constantPool); + } + } + + /** + * Reads information about the class and its super class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readClassInfo() throws IOException, ClassFormatException { + accessFlags = dataInputStream.readUnsignedShort(); + /* + * Interfaces are implicitly abstract, the flag should be set according to the JVM specification. + */ + if ((accessFlags & Const.ACC_INTERFACE) != 0) { + accessFlags |= Const.ACC_ABSTRACT; + } + if ((accessFlags & Const.ACC_ABSTRACT) != 0 && (accessFlags & Const.ACC_FINAL) != 0) { + throw new ClassFormatException("Class " + fileName + " can't be both final and abstract"); + } + classNameIndex = dataInputStream.readUnsignedShort(); + superclassNameIndex = dataInputStream.readUnsignedShort(); + } + + /** + * Reads constant pool entries. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readConstantPool() throws IOException, ClassFormatException { + constantPool = new ConstantPool(dataInputStream); + } + + /** + * Reads information about the fields of the class, i.e., its variables. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readFields() throws IOException, ClassFormatException { + final int fieldsCount = dataInputStream.readUnsignedShort(); + fields = new Field[fieldsCount]; + for (int i = 0; i < fieldsCount; i++) { + fields[i] = new Field(dataInputStream, constantPool); + } + } + + /******************** Private utility methods **********************/ + /** + * Checks whether the header of the file is ok. Of course, this has to be the first action on successive file reads. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readID() throws IOException, ClassFormatException { + if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) { + throw new ClassFormatException(fileName + " is not a Java .class file"); + } + } + + /** + * Reads information about the interfaces implemented by this class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readInterfaces() throws IOException, ClassFormatException { + final int interfacesCount = dataInputStream.readUnsignedShort(); + interfaces = new int[interfacesCount]; + for (int i = 0; i < interfacesCount; i++) { + interfaces[i] = dataInputStream.readUnsignedShort(); + } + } + + /** + * Reads information about the methods of the class. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readMethods() throws IOException { + final int methodsCount = dataInputStream.readUnsignedShort(); + methods = new Method[methodsCount]; + for (int i = 0; i < methodsCount; i++) { + methods[i] = new Method(dataInputStream, constantPool); + } + } + + /** + * Reads major and minor version of compiler which created the file. + * + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + private void readVersion() throws IOException, ClassFormatException { + minor = dataInputStream.readUnsignedShort(); + major = dataInputStream.readUnsignedShort(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java new file mode 100644 index 0000000..eaa399b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Code.java @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents a chunk of Java byte code contained in a method. It is instantiated by the + * Attribute.readAttribute() method. A Code attribute contains informations about operand stack, local + * variables, byte code and the exceptions handled within this method. + *

+ * This attribute has attributes itself, namely LineNumberTable which is used for debugging purposes and + * LocalVariableTable which contains information about the local variables. + * + *

+ * Code_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 max_stack;
+ *   u2 max_locals;
+ *   u4 code_length;
+ *   u1 code[code_length];
+ *   u2 exception_table_length;
+ *   {
+ *     u2 start_pc;
+ *     u2 end_pc;
+ *     u2 handler_pc;
+ *     u2 catch_type;
+ *   } exception_table[exception_table_length];
+ *   u2 attributes_count;
+ *   attribute_info attributes[attributes_count];
+ * }
+ * 
+ * + * @LastModified: Feb 2023 + * @see Attribute + * @see CodeException + * @see LineNumberTable + * @see LocalVariableTable + */ +public final class Code extends Attribute { + + private int maxStack; // Maximum size of stack used by this method // TODO this could be made final (setter is not used) + private int maxLocals; // Number of local variables // TODO this could be made final (setter is not used) + private byte[] code; // Actual byte code + private CodeException[] exceptionTable; // Table of handled exceptions + private Attribute[] attributes; // or LocalVariable + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param code The source Code. + */ + public Code(final Code code) { + this(code.getNameIndex(), code.getLength(), code.getMaxStack(), code.getMaxLocals(), code.getCode(), code.getExceptionTable(), code.getAttributes(), + code.getConstantPool()); + } + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param file Input stream + * @param constantPool Array of constants + */ + Code(final int nameIndex, final int length, final DataInput file, final ConstantPool constantPool) throws IOException { + // Initialize with some default values which will be overwritten later + this(nameIndex, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null, (CodeException[]) null, (Attribute[]) null, constantPool); + final int codeLength = Args.requireU4(file.readInt(), 1, "Code length attribute"); + code = new byte[codeLength]; // Read byte code + file.readFully(code); + /* + * Read exception table that contains all regions where an exception handler is active, i.e., a try { ... } catch() + * block. + */ + final int exceptionTableLength = file.readUnsignedShort(); + exceptionTable = new CodeException[exceptionTableLength]; + for (int i = 0; i < exceptionTableLength; i++) { + exceptionTable[i] = new CodeException(file); + } + /* + * Read all attributes, currently 'LineNumberTable' and 'LocalVariableTable' + */ + final int attributesCount = file.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(file, constantPool); + } + /* + * Adjust length, because of setAttributes in this(), s.b. length is incorrect, because it didn't take the internal + * attributes into account yet! Very subtle bug, fixed in 3.1.1. + */ + super.setLength(length); + } + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param maxStack Maximum size of stack + * @param maxLocals Number of local variables + * @param code Actual byte code + * @param exceptionTable of handled exceptions + * @param attributes Attributes of code: LineNumber or LocalVariable + * @param constantPool Array of constants + */ + public Code(final int nameIndex, final int length, final int maxStack, final int maxLocals, final byte[] code, final CodeException[] exceptionTable, + final Attribute[] attributes, final ConstantPool constantPool) { + super(Const.ATTR_CODE, nameIndex, length, constantPool); + this.maxStack = Args.requireU2(maxStack, "maxStack"); + this.maxLocals = Args.requireU2(maxLocals, "maxLocals"); + this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY; + this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY; + Args.requireU2(this.exceptionTable.length, "exceptionTable.length"); + this.attributes = attributes != null ? attributes : EMPTY_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitCode(this); + } + + /** + * @return the full size of this code attribute, minus its first 6 bytes, including the size of all its contained + * attributes + */ + private int calculateLength() { + int len = 0; + if (attributes != null) { + for (final Attribute attribute : attributes) { + len += attribute.getLength() + 6 /* attribute header size */; + } + } + return len + getInternalLength(); + } + + /** + * @param constantPool the constant pool to duplicate + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Code c = (Code) clone(); + if (code != null) { + c.code = code.clone(); + } + c.setConstantPool(constantPool); + c.exceptionTable = new CodeException[exceptionTable.length]; + Arrays.setAll(c.exceptionTable, i -> exceptionTable[i].copy()); + c.attributes = new Attribute[attributes.length]; + Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool)); + return c; + } + + /** + * Dump code attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(maxStack); + file.writeShort(maxLocals); + file.writeInt(code.length); + file.write(code, 0, code.length); + file.writeShort(exceptionTable.length); + for (final CodeException exception : exceptionTable) { + exception.dump(file); + } + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } + + /** + * @return Collection of code attributes. + * @see Attribute + */ + public Attribute[] getAttributes() { + return attributes; + } + + /** + * @param attributes the attributes to set for this Code + */ + public void setAttributes(final Attribute[] attributes) { + this.attributes = attributes != null ? attributes : EMPTY_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @return Actual byte code of the method. + */ + public byte[] getCode() { + return code; + } + + /** + * @param code byte code + */ + public void setCode(final byte[] code) { + this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @return Table of handled exceptions. + * @see CodeException + */ + public CodeException[] getExceptionTable() { + return exceptionTable; + } + + /** + * @param exceptionTable exception table + */ + public void setExceptionTable(final CodeException[] exceptionTable) { + this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY; + super.setLength(calculateLength()); // Adjust length + } + + /** + * @return the internal length of this code attribute (minus the first 6 bytes) and excluding all its attributes + */ + private int getInternalLength() { + return 2 /* maxStack */ + 2 /* maxLocals */ + 4 /* code length */ + + code.length /* byte-code */ + + 2 /* exception-table length */ + + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */ + + 2 /* attributes count */; + } + + /** + * @return LineNumberTable of Code, if it has one + */ + public LineNumberTable getLineNumberTable() { + for (final Attribute attribute : attributes) { + if (attribute instanceof LineNumberTable) { + return (LineNumberTable) attribute; + } + } + return null; + } + + /** + * @return LocalVariableTable of Code, if it has one + */ + public LocalVariableTable getLocalVariableTable() { + for (final Attribute attribute : attributes) { + if (attribute instanceof LocalVariableTable) { + return (LocalVariableTable) attribute; + } + } + return null; + } + + /** + * @return Number of local variables. + */ + public int getMaxLocals() { + return maxLocals; + } + + /** + * @param maxLocals maximum number of local variables + */ + public void setMaxLocals(final int maxLocals) { + this.maxLocals = maxLocals; + } + + /** + * @return Maximum size of stack used by this method. + */ + public int getMaxStack() { + return maxStack; + } + + /** + * @param maxStack maximum stack size + */ + public void setMaxStack(final int maxStack) { + this.maxStack = maxStack; + } + + /** + * @return String representation of code chunk. + */ + @Override + public String toString() { + return toString(true); + } + + /** + * Converts this object to a String. + * + * @param verbose Provides verbose output when true. + * @return String representation of code chunk. + */ + public String toString(final boolean verbose) { + final StringBuilder buf = new StringBuilder(100); // CHECKSTYLE IGNORE MagicNumber + buf.append("Code(maxStack = ").append(maxStack).append(", maxLocals = ").append(maxLocals).append(", code_length = ").append(code.length).append(")\n") + .append(Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose)); + if (exceptionTable.length > 0) { + buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); + for (final CodeException exception : exceptionTable) { + buf.append(exception.toString(super.getConstantPool(), verbose)).append("\n"); + } + } + if (attributes.length > 0) { + buf.append("\nAttribute(s) = "); + for (final Attribute attribute : attributes) { + buf.append("\n").append(attribute.getName()).append(":"); + buf.append("\n").append(attribute); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java new file mode 100644 index 0000000..d90e995 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/CodeException.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents an entry in the exception table of the Code attribute and is used only there. It + * contains a range in which a particular exception handler is active. + * + *
+ * Code_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 max_stack;
+ *   u2 max_locals;
+ *   u4 code_length;
+ *   u1 code[code_length];
+ *   u2 exception_table_length;
+ *   {
+ *     u2 start_pc;
+ *     u2 end_pc;
+ *     u2 handler_pc;
+ *     u2 catch_type;
+ *   } exception_table[exception_table_length];
+ *   u2 attributes_count;
+ *   attribute_info attributes[attributes_count];
+ * }
+ * 
+ * + * @LastModified: Feb 2023 + * @see Code + */ +public final class CodeException implements Cloneable, Node { + + /** + * Empty array. + */ + static final CodeException[] EMPTY_CODE_EXCEPTION_ARRAY = {}; + + /** + * Range in the code the exception handler. + */ + private int startPc; + + /** + * active. startPc is inclusive, endPc exclusive. + */ + private int endPc; + + /** + * Starting address of exception handler, i.e., an offset from start of code. + */ + private int handlerPc; + + /* + * If this is zero the handler catches any exception, otherwise it points to the exception class which is to be caught. + */ + private int catchType; + + /** + * Constructs a new instance from another instance. + * + * @param c Source for copying. + */ + public CodeException(final CodeException c) { + this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); + } + + /** + * Constructs a new instance from a DataInput. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + CodeException(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * Constructs a new instance. + * + * @param startPc Range in the code the exception handler is active, startPc is inclusive while + * @param endPc is exclusive + * @param handlerPc Starting address of exception handler, i.e., an offset from start of code. + * @param catchType If zero the handler catches any exception, otherwise it points to the exception class which is to be + * caught. + */ + public CodeException(final int startPc, final int endPc, final int handlerPc, final int catchType) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.endPc = Args.requireU2(endPc, "endPc"); + this.handlerPc = Args.requireU2(handlerPc, "handlerPc"); + this.catchType = Args.requireU2(catchType, "catchType"); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitCodeException(this); + } + + /** + * @return deep copy of this object + */ + public CodeException copy() { + try { + return (CodeException) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dumps code exception to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(startPc); + file.writeShort(endPc); + file.writeShort(handlerPc); + file.writeShort(catchType); + } + + /** + * @return 0, if the handler catches any exception, otherwise it points to the exception class which is to be caught. + */ + public int getCatchType() { + return catchType; + } + + /** + * @param catchType the type of exception that is caught + */ + public void setCatchType(final int catchType) { + this.catchType = catchType; + } + + /** + * @return Exclusive end index of the region where the handler is active. + */ + public int getEndPC() { + return endPc; + } + + /** + * @param endPc end of handled block + */ + public void setEndPC(final int endPc) { + this.endPc = endPc; + } + + /** + * @return Starting address of exception handler, relative to the code. + */ + public int getHandlerPC() { + return handlerPc; + } + + /** + * @param handlerPc where the actual code is + */ + public void setHandlerPC(final int handlerPc) { // TODO unused + this.handlerPc = handlerPc; + } + + /** + * @return Inclusive start index of the region where the handler is active. + */ + public int getStartPC() { + return startPc; + } + + /** + * @param startPc start of handled block + */ + public void setStartPC(final int startPc) { // TODO unused + this.startPc = startPc; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return "CodeException(startPc = " + startPc + ", endPc = " + endPc + ", handlerPc = " + handlerPc + ", catchType = " + catchType + ")"; + } + + public String toString(final ConstantPool cp) { + return toString(cp, true); + } + + /** + * @param cp constant pool source. + * @param verbose Output more if true. + * @return String representation. + */ + public String toString(final ConstantPool cp, final boolean verbose) { + String str; + if (catchType == 0) { + str = "(0)"; + } else { + str = Utility.compactClassName(cp.getConstantString(catchType, Const.CONSTANT_Class), false) + (verbose ? "(" + catchType + ")" : ""); + } + return startPc + "\t" + endPc + "\t" + handlerPc + "\t" + str; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java new file mode 100644 index 0000000..f7b11d8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Constant.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * Abstract superclass for classes to represent the different constant types + * in the constant pool of a class file. The classes keep closely to + * the JVM specification. + * + * @LastModified: May 2021 + */ +public abstract class Constant implements Cloneable, Node { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final Constant THIS = (Constant) o1; + final Constant THAT = (Constant) o2; + return Objects.equals(THIS.toString(), THAT.toString()); + } + + @Override + public int hashCode(final Object o) { + final Constant THIS = (Constant) o; + return THIS.toString().hashCode(); + } + }; + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected byte tag; // TODO should be private & final + + Constant(final byte tag) { + this.tag = tag; + } + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /* + * In fact this tag is redundant since we can distinguish different 'Constant' objects by their type, i.e., via + * 'instanceof'. In some places we will use the tag for switch()es anyway. + * + * First, we want match the specification as closely as possible. Second we need the tag as an index to select the + * corresponding class name from the 'CONSTANT_NAMES' array. + */ + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + /** + * Reads one constant from the given input, the type depends on a tag byte. + * + * @param dataInput Input stream + * @return Constant object + * @throws IOException if an I/O error occurs reading from the given {@code dataInput}. + * @throws ClassFormatException if the next byte is not recognized + * @since 6.0 made public + */ + public static Constant readConstant(final DataInput dataInput) throws IOException, ClassFormatException { + final byte b = dataInput.readByte(); // Read tag byte + switch (b) { + case Const.CONSTANT_Class: + return new ConstantClass(dataInput); + case Const.CONSTANT_Fieldref: + return new ConstantFieldref(dataInput); + case Const.CONSTANT_Methodref: + return new ConstantMethodref(dataInput); + case Const.CONSTANT_InterfaceMethodref: + return new ConstantInterfaceMethodref(dataInput); + case Const.CONSTANT_String: + return new ConstantString(dataInput); + case Const.CONSTANT_Integer: + return new ConstantInteger(dataInput); + case Const.CONSTANT_Float: + return new ConstantFloat(dataInput); + case Const.CONSTANT_Long: + return new ConstantLong(dataInput); + case Const.CONSTANT_Double: + return new ConstantDouble(dataInput); + case Const.CONSTANT_NameAndType: + return new ConstantNameAndType(dataInput); + case Const.CONSTANT_Utf8: + return ConstantUtf8.getInstance(dataInput); + case Const.CONSTANT_MethodHandle: + return new ConstantMethodHandle(dataInput); + case Const.CONSTANT_MethodType: + return new ConstantMethodType(dataInput); + case Const.CONSTANT_Dynamic: + return new ConstantDynamic(dataInput); + case Const.CONSTANT_InvokeDynamic: + return new ConstantInvokeDynamic(dataInput); + case Const.CONSTANT_Module: + return new ConstantModule(dataInput); + case Const.CONSTANT_Package: + return new ConstantPackage(dataInput); + default: + throw new ClassFormatException("Invalid byte tag in constant pool: " + b); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public abstract void accept(Visitor v); + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return deep copy of this constant + */ + public Constant copy() { + try { + return (Constant) super.clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + public abstract void dump(DataOutputStream file) throws IOException; + + /** + * Returns value as defined by given BCELComparator strategy. By default two Constant objects are said to be equal when + * the result of toString() is equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return Tag of constant, i.e., its type. No setTag() method to avoid confusion. + */ + public final byte getTag() { + return tag; + } + + /** + * Returns value as defined by given BCELComparator strategy. By default return the hashcode of the result of + * toString(). + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return Const.getConstantName(tag) + "[" + tag + "]"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java new file mode 100644 index 0000000..4593413 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Abstract super class for Fieldref, Methodref, InterfaceMethodref and InvokeDynamic constants. + * + * @LastModified: Jun 2019 + * @see ConstantFieldref + * @see ConstantMethodref + * @see ConstantInterfaceMethodref + * @see ConstantInvokeDynamic + */ +public abstract class ConstantCP extends Constant { + + /** + * References to the constants containing the class and the field signature + */ + // Note that this field is used to store the + // bootstrap_method_attr_index of a ConstantInvokeDynamic. + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int class_index; // TODO make private (has getter & setter) + // This field has the same meaning for all subclasses. + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_and_type_index; // TODO make private (has getter & setter) + + /** + * Initialize instance from file data. + * + * @param tag Constant type tag + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantCP(final byte tag, final DataInput file) throws IOException { + this(tag, file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * @param classIndex Reference to the class containing the field + * @param nameAndTypeIndex and the field signature + */ + protected ConstantCP(final byte tag, final int classIndex, final int nameAndTypeIndex) { + super(tag); + this.class_index = classIndex; + this.name_and_type_index = nameAndTypeIndex; + } + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantCP(final ConstantCP c) { + this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Dump constant field reference to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(class_index); + file.writeShort(name_and_type_index); + } + + /** + * @return Class this field belongs to. + */ + public String getClass(final ConstantPool cp) { + return cp.constantToString(class_index, Const.CONSTANT_Class); + } + + /** + * @return Reference (index) to class this constant refers to. + */ + public final int getClassIndex() { + return class_index; + } + + /** + * @param classIndex points to Constant_class + */ + public final void setClassIndex(final int classIndex) { + this.class_index = classIndex; + } + + /** + * @return Reference (index) to signature of the field. + */ + public final int getNameAndTypeIndex() { + return name_and_type_index; + } + + /** + * @param nameAndTypeIndex points to Constant_NameAndType + */ + public final void setNameAndTypeIndex(final int nameAndTypeIndex) { + this.name_and_type_index = nameAndTypeIndex; + } + + /** + * @return String representation. + *

+ * not final as ConstantInvokeDynamic needs to modify + */ + @Override + public String toString() { + return super.toString() + "(class_index = " + class_index + ", name_and_type_index = " + name_and_type_index + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java new file mode 100644 index 0000000..9361a5d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a (external) class. + * + * @see Constant + */ +public final class ConstantClass extends Constant implements ConstantObject { + + private int nameIndex; // Identical to ConstantString except for the name + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantClass(final ConstantClass c) { + this(c.getNameIndex()); + } + + /** + * Constructs an instance from file data. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs reading from the given {@code dataInput}. + */ + ConstantClass(final DataInput dataInput) throws IOException { + this(dataInput.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantClass(final int nameIndex) { + super(Const.CONSTANT_Class); + this.nameIndex = nameIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantClass(this); + } + + /** + * Dumps constant class to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs writing to the DataOutputStream. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of class name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Class + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java new file mode 100644 index 0000000..06b679c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a Double object. + * + * @LastModified: Jun 2019 + * @see Constant + */ +public final class ConstantDouble extends Constant implements ConstantObject { + + private double bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantDouble(final ConstantDouble c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantDouble(final DataInput file) throws IOException { + this(file.readDouble()); + } + + /** + * @param bytes Data + */ + public ConstantDouble(final double bytes) { + super(Const.CONSTANT_Double); + this.bytes = bytes; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantDouble(this); + } + + /** + * Dump constant double to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeDouble(bytes); + } + + /** + * @return data, i.e., 8 bytes. + */ + public double getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represent the double value + */ + public void setBytes(final double bytes) { + this.bytes = bytes; + } + + /** + * @return Double object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Double.valueOf(bytes); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java new file mode 100644 index 0000000..8c4be26 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java @@ -0,0 +1,94 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a dynamically computed + * constant. + * + * @see Constant + * @see Change request for JEP + * 309 + * @since 6.3 + */ +public final class ConstantDynamic extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantDynamic(final ConstantDynamic c) { + this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantDynamic(final DataInput file) throws IOException { + this(file.readShort(), file.readShort()); + } + + + public ConstantDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Dynamic, bootstrapMethodAttrIndex, nameAndTypeIndex); + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantDynamic(this); + } + + /** + * @return Reference (index) to bootstrap method this constant refers to. + *

+ * Note that this method is a functional duplicate of getClassIndex for use by ConstantInvokeDynamic. + * @since 6.0 + */ + public int getBootstrapMethodAttrIndex() { + return super.getClassIndex(); // AKA bootstrap_method_attr_index + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString().replace("class_index", "bootstrap_method_attr_index"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java new file mode 100644 index 0000000..6e98953 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to a field. + */ +public final class ConstantFieldref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantFieldref(final ConstantFieldref c) { + super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantFieldref(final DataInput input) throws IOException { + super(Const.CONSTANT_Fieldref, input); + } + + /** + * @param classIndex Reference to the class containing the Field + * @param nameAndTypeIndex and the Field signature + */ + public ConstantFieldref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Fieldref, classIndex, nameAndTypeIndex); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of Fields, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantFieldref(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java new file mode 100644 index 0000000..7d59c28 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a float object. + * + * @LastModified: Jun 2019 + * @see Constant + */ +public final class ConstantFloat extends Constant implements ConstantObject { + + private float bytes; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public ConstantFloat(final ConstantFloat c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantFloat(final DataInput file) throws IOException { + this(file.readFloat()); + } + + /** + * @param bytes Data + */ + public ConstantFloat(final float bytes) { + super(Const.CONSTANT_Float); + this.bytes = bytes; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantFloat(this); + } + + /** + * Dump constant float to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeFloat(bytes); + } + + /** + * @return data, i.e., 4 bytes. + */ + public float getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represent this float + */ + public void setBytes(final float bytes) { + this.bytes = bytes; + } + + /** + * @return Float object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Float.valueOf(bytes); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java new file mode 100644 index 0000000..7609a04 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to an int object. + * + * @LastModified: Jun 2019 + * @see Constant + */ +public final class ConstantInteger extends Constant implements ConstantObject { + + private int bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantInteger(final ConstantInteger c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInteger(final DataInput file) throws IOException { + this(file.readInt()); + } + + /** + * @param bytes Data + */ + public ConstantInteger(final int bytes) { + super(Const.CONSTANT_Integer); + this.bytes = bytes; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantInteger(this); + } + + /** + * Dump constant integer to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeInt(bytes); + } + + /** + * @return data, i.e., 4 bytes. + */ + public int getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represent this integer + */ + public void setBytes(final int bytes) { + this.bytes = bytes; + } + + /** + * @return Integer object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Integer.valueOf(bytes); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java new file mode 100644 index 0000000..b32c633 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to an interface method. + */ +public final class ConstantInterfaceMethodref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantInterfaceMethodref(final ConstantInterfaceMethodref c) { + super(Const.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInterfaceMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_InterfaceMethodref, input); + } + + /** + * @param classIndex Reference to the class containing the method + * @param nameAndTypeIndex and the method signature + */ + public ConstantInterfaceMethodref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_InterfaceMethodref, classIndex, nameAndTypeIndex); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantInterfaceMethodref(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java new file mode 100644 index 0000000..8f20590 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java @@ -0,0 +1,90 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a invoke dynamic. + * + * @see Constant + * @see The + * CONSTANT_InvokeDynamic_info Structure in The Java Virtual Machine Specification + * @since 6.0 + */ +public final class ConstantInvokeDynamic extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantInvokeDynamic(final ConstantInvokeDynamic c) { + this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantInvokeDynamic(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + public ConstantInvokeDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_InvokeDynamic, bootstrapMethodAttrIndex, nameAndTypeIndex); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantInvokeDynamic(this); + } + + /** + * @return Reference (index) to bootstrap method this constant refers to. + *

+ * Note that this method is a functional duplicate of getClassIndex for use by ConstantInvokeDynamic. + * @since 6.0 + */ + public int getBootstrapMethodAttrIndex() { + return super.getClassIndex(); // AKA bootstrap_method_attr_index + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString().replace("class_index", "bootstrap_method_attr_index"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java new file mode 100644 index 0000000..2689e99 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a long object. + * + * @LastModified: Jan 2020 + * @see Constant + */ +public final class ConstantLong extends Constant implements ConstantObject { + + private long bytes; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantLong(final ConstantLong c) { + this(c.getBytes()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantLong(final DataInput file) throws IOException { + this(file.readLong()); + } + + /** + * @param bytes Data + */ + public ConstantLong(final long bytes) { + super(Const.CONSTANT_Long); + this.bytes = bytes; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantLong(this); + } + + /** + * Dump constant long to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeLong(bytes); + } + + /** + * @return data, i.e., 8 bytes. + */ + public long getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represent this long + */ + public void setBytes(final long bytes) { + this.bytes = bytes; + } + + /** + * @return Long object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return Long.valueOf(bytes); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java new file mode 100644 index 0000000..6656ff2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java @@ -0,0 +1,113 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a method handle. + * + * @see Constant + * @since 6.0 + */ +public final class ConstantMethodHandle extends Constant { + + private int referenceKind; + private int referenceIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodHandle(final ConstantMethodHandle c) { + this(c.getReferenceKind(), c.getReferenceIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodHandle(final DataInput file) throws IOException { + this(file.readUnsignedByte(), file.readUnsignedShort()); + } + + public ConstantMethodHandle(final int referenceKind, final int referenceIndex) { + super(Const.CONSTANT_MethodHandle); + this.referenceKind = referenceKind; + this.referenceIndex = referenceIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantMethodHandle(this); + } + + /** + * Dump method kind and index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeByte(referenceKind); + file.writeShort(referenceIndex); + } + + public int getReferenceIndex() { + return referenceIndex; + } + + public void setReferenceIndex(final int referenceIndex) { + this.referenceIndex = referenceIndex; + } + + public int getReferenceKind() { + return referenceKind; + } + + public void setReferenceKind(final int referenceKind) { + this.referenceKind = referenceKind; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(referenceKind = " + referenceKind + ", referenceIndex = " + referenceIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java new file mode 100644 index 0000000..654d801 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java @@ -0,0 +1,102 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a method type. + * + * @see Constant + * @since 6.0 + */ +public final class ConstantMethodType extends Constant { + + private int descriptorIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodType(final ConstantMethodType c) { + this(c.getDescriptorIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodType(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + public ConstantMethodType(final int descriptorIndex) { + super(Const.CONSTANT_MethodType); + this.descriptorIndex = descriptorIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantMethodType(this); + } + + /** + * Dump name and signature index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(descriptorIndex); + } + + public int getDescriptorIndex() { + return descriptorIndex; + } + + public void setDescriptorIndex(final int descriptorIndex) { + this.descriptorIndex = descriptorIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(descriptorIndex = " + descriptorIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java new file mode 100644 index 0000000..cf18ecf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java @@ -0,0 +1,71 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a constant pool reference to a method. + */ +public final class ConstantMethodref extends ConstantCP { + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantMethodref(final ConstantMethodref c) { + super(Const.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException if an I/O error occurs. + */ + ConstantMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_Methodref, input); + } + + /** + * @param classIndex Reference to the class containing the method + * @param nameAndTypeIndex and the method signature + */ + public ConstantMethodref(final int classIndex, final int nameAndTypeIndex) { + super(Const.CONSTANT_Methodref, classIndex, nameAndTypeIndex); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantMethodref(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java new file mode 100644 index 0000000..06754b9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java @@ -0,0 +1,130 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a module. + * + *

+ * Note: Early access Java 9 support- currently subject to change + *

+ * + * @see Constant + * @since 6.1 + */ +public final class ConstantModule extends Constant implements ConstantObject { + + private int nameIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantModule(final ConstantModule c) { + this(c.getNameIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantModule(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantModule(final int nameIndex) { + super(Const.CONSTANT_Module); + this.nameIndex = nameIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantModule(this); + } + + /** + * Dump constant module to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of module name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Module + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java new file mode 100644 index 0000000..ca69b5d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java @@ -0,0 +1,143 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to the name and signature of a + * field or method. + * + * @see Constant + */ +public final class ConstantNameAndType extends Constant { + + private int nameIndex; // Name of field/method + private int signatureIndex; // and its signature. + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantNameAndType(final ConstantNameAndType c) { + this(c.getNameIndex(), c.getSignatureIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantNameAndType(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * @param nameIndex Name of field/method + * @param signatureIndex and its signature + */ + public ConstantNameAndType(final int nameIndex, final int signatureIndex) { + super(Const.CONSTANT_NameAndType); + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantNameAndType(this); + } + + /** + * Dump name and signature index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + file.writeShort(signatureIndex); + } + + /** + * @return name + */ + public String getName(final ConstantPool cp) { + return cp.constantToString(getNameIndex(), Const.CONSTANT_Utf8); + } + + /** + * @return Name index in constant pool of field/method name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index of this constant + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return signature + */ + public String getSignature(final ConstantPool cp) { + return cp.constantToString(getSignatureIndex(), Const.CONSTANT_Utf8); + } + + /** + * @return Index in constant pool of field/method signature. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @param signatureIndex the signature index in the constant pool of this type + */ + public void setSignatureIndex(final int signatureIndex) { + this.signatureIndex = signatureIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ", signatureIndex = " + signatureIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java new file mode 100644 index 0000000..cb28f7d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java @@ -0,0 +1,35 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * This interface denotes those constants that have a "natural" value, such as ConstantLong, ConstantString, etc.. + * + * @see Constant + */ +public interface ConstantObject { + + /** + * @return object representing the constant, e.g., Long for ConstantLong + */ + Object getConstantValue(ConstantPool cp); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java new file mode 100644 index 0000000..2e8c721 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java @@ -0,0 +1,130 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a package. + * + *

+ * Note: Early access Java 9 support- currently subject to change + *

+ * + * @see Constant + * @since 6.1 + */ +public final class ConstantPackage extends Constant implements ConstantObject { + + private int nameIndex; + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantPackage(final ConstantPackage c) { + this(c.getNameIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantPackage(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8. + */ + public ConstantPackage(final int nameIndex) { + super(Const.CONSTANT_Package); + this.nameIndex = nameIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantPackage(this); + } + + /** + * Dump constant package to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(nameIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Name index in constant pool of package name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @param nameIndex the name index in the constant pool of this Constant Package + */ + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(nameIndex = " + nameIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java new file mode 100644 index 0000000..f221a03 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java @@ -0,0 +1,438 @@ +/* + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents the constant pool, i.e., a table of constants, of a parsed classfile. It may contain null references, due to the JVM specification that + * skips an entry after an 8-byte constant (double, long) entry. Those interested in generating constant pools programmatically should see + * ConstantPoolGen. + * + * @LastModified: Feb 2023 + * @see Constant + * @see com.sun.org.apache.bcel.internal.generic.ConstantPoolGen + */ +public class ConstantPool implements Cloneable, Node, Iterable { + + private Constant[] constantPool; + + /** + * @param constantPool Array of constants + */ + public ConstantPool(final Constant[] constantPool) { + this.constantPool = constantPool; + } + + /** + * Reads constants from given input stream. + * + * @param input Input stream + * @throws IOException if problem in readUnsignedShort or readConstant + */ + public ConstantPool(final DataInput input) throws IOException { + byte tag; + final int constantPoolCount = input.readUnsignedShort(); + constantPool = new Constant[constantPoolCount]; + /* + * constantPool[0] is unused by the compiler and may be used freely by the implementation. + */ + for (int i = 1; i < constantPoolCount; i++) { + constantPool[i] = Constant.readConstant(input); + /* + * Quote from the JVM specification: "All eight byte constants take up two spots in the constant pool. If this is the n'th byte in the constant + * pool, then the next item will be numbered n+2" + * + * Thus we have to increment the index counter. + */ + tag = constantPool[i].getTag(); + if (tag == Const.CONSTANT_Double || tag == Const.CONSTANT_Long) { + i++; + } + } + } + + private static String escape(final String str) { + final int len = str.length(); + final StringBuilder buf = new StringBuilder(len + 5); + final char[] ch = str.toCharArray(); + for (int i = 0; i < len; i++) { + switch (ch[i]) { + case '\n': + buf.append("\\n"); + break; + case '\r': + buf.append("\\r"); + break; + case '\t': + buf.append("\\t"); + break; + case '\b': + buf.append("\\b"); + break; + case '"': + buf.append("\\\""); + break; + default: + buf.append(ch[i]); + } + } + return buf.toString(); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, + * attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantPool(this); + } + + /** + * Resolves constant to a string representation. + * + * @param c Constant to be printed + * @return String representation + * @throws IllegalArgumentException if c is unknown constant type + */ + public String constantToString(Constant c) throws IllegalArgumentException { + String str; + int i; + final byte tag = c.getTag(); + switch (tag) { + case Const.CONSTANT_Class: + i = ((ConstantClass) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + case Const.CONSTANT_String: + i = ((ConstantString) c).getStringIndex(); + c = getConstantUtf8(i); + str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\""; + break; + case Const.CONSTANT_Utf8: + str = ((ConstantUtf8) c).getBytes(); + break; + case Const.CONSTANT_Double: + str = String.valueOf(((ConstantDouble) c).getBytes()); + break; + case Const.CONSTANT_Float: + str = String.valueOf(((ConstantFloat) c).getBytes()); + break; + case Const.CONSTANT_Long: + str = String.valueOf(((ConstantLong) c).getBytes()); + break; + case Const.CONSTANT_Integer: + str = String.valueOf(((ConstantInteger) c).getBytes()); + break; + case Const.CONSTANT_NameAndType: + str = constantToString(((ConstantNameAndType) c).getNameIndex(), Const.CONSTANT_Utf8) + " " + + constantToString(((ConstantNameAndType) c).getSignatureIndex(), Const.CONSTANT_Utf8); + break; + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_Fieldref: + str = constantToString(((ConstantCP) c).getClassIndex(), Const.CONSTANT_Class) + "." + + constantToString(((ConstantCP) c).getNameAndTypeIndex(), Const.CONSTANT_NameAndType); + break; + case Const.CONSTANT_MethodHandle: + // Note that the ReferenceIndex may point to a Fieldref, Methodref or + // InterfaceMethodref - so we need to peek ahead to get the actual type. + final ConstantMethodHandle cmh = (ConstantMethodHandle) c; + str = Const.getMethodHandleName(cmh.getReferenceKind()) + " " + + constantToString(cmh.getReferenceIndex(), getConstant(cmh.getReferenceIndex()).getTag()); + break; + case Const.CONSTANT_MethodType: + final ConstantMethodType cmt = (ConstantMethodType) c; + str = constantToString(cmt.getDescriptorIndex(), Const.CONSTANT_Utf8); + break; + case Const.CONSTANT_InvokeDynamic: + final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) c; + str = cid.getBootstrapMethodAttrIndex() + ":" + constantToString(cid.getNameAndTypeIndex(), Const.CONSTANT_NameAndType); + break; + case Const.CONSTANT_Dynamic: + final ConstantDynamic cd = (ConstantDynamic) c; + str = cd.getBootstrapMethodAttrIndex() + ":" + constantToString(cd.getNameAndTypeIndex(), Const.CONSTANT_NameAndType); + break; + case Const.CONSTANT_Module: + i = ((ConstantModule) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + case Const.CONSTANT_Package: + i = ((ConstantPackage) c).getNameIndex(); + c = getConstantUtf8(i); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + tag); + } + return str; + } + + /** + * Retrieves constant at 'index' from constant pool and resolve it to a string representation. + * + * @param index of constant in constant pool + * @param tag expected type + * @return String representation + */ + public String constantToString(final int index, final byte tag) { + return constantToString(getConstant(index, tag)); + } + + /** + * @return deep copy of this constant pool + */ + public ConstantPool copy() { + ConstantPool c = null; + try { + c = (ConstantPool) clone(); + c.constantPool = new Constant[constantPool.length]; + for (int i = 1; i < constantPool.length; i++) { + if (constantPool[i] != null) { + c.constantPool[i] = constantPool[i].copy(); + } + } + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return c; + } + + /** + * Dump constant pool to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if problem in writeShort or dump + */ + public void dump(final DataOutputStream file) throws IOException { + /* + * Constants over the size of the constant pool shall not be written out. + * This is a redundant measure as the ConstantPoolGen should have already + * reported an error back in the situation. + */ + final int size = Math.min(constantPool.length, Const.MAX_CP_ENTRIES); + + file.writeShort(size); + for (int i = 1; i < size; i++) { + if (constantPool[i] != null) { + constantPool[i].dump(file); + } + } + } + + /** + * Gets constant from constant pool. + * + * @param index Index in constant pool + * @return Constant value + * @throws ClassFormatException if index is invalid + * @see Constant + */ + @SuppressWarnings("unchecked") + public T getConstant(final int index) throws ClassFormatException { + return (T) getConstant(index, Constant.class); + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @param tag Tag of expected constant, i.e., its type + * @return Constant value + * @throws ClassFormatException if constant type does not match tag + * @see Constant + */ + @SuppressWarnings("unchecked") + public T getConstant(final int index, final byte tag) throws ClassFormatException { + return (T) getConstant(index, tag, Constant.class); + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @param tag Tag of expected constant, i.e., its type + * @return Constant value + * @throws ClassFormatException if constant type does not match tag + * @see Constant + * @since 6.6.0 + */ + public T getConstant(final int index, final byte tag, final Class castTo) throws ClassFormatException { + final T c = getConstant(index); + if (c.getTag() != tag) { + throw new ClassFormatException("Expected class '" + Const.getConstantName(tag) + "' at index " + index + " and got " + c); + } + return c; + } + + /** + * Gets constant from constant pool. + * + * @param A {@link Constant} subclass + * @param index Index in constant pool + * @param castTo The {@link Constant} subclass to cast to. + * @return Constant value + * @throws ClassFormatException if index is invalid + * @see Constant + * @since 6.6.0 + */ + public T getConstant(final int index, final Class castTo) throws ClassFormatException { + if (index >= constantPool.length || index < 0) { + throw new ClassFormatException("Invalid constant pool reference using index: " + index + ". Constant pool size is: " + constantPool.length); + } + if (constantPool[index] != null && !castTo.isAssignableFrom(constantPool[index].getClass())) { + throw new ClassFormatException("Invalid constant pool reference at index: " + index + + ". Expected " + castTo + " but was " + constantPool[index].getClass()); + } + // Previous check ensures this won't throw a ClassCastException + final T c = castTo.cast(constantPool[index]); + if (c == null + // the 0th element is always null + && index != 0) { + final Constant prev = constantPool[index - 1]; + if (prev == null || prev.getTag() != Const.CONSTANT_Double && prev.getTag() != Const.CONSTANT_Long) { + throw new ClassFormatException("Constant pool at index " + index + " is null."); + } + } + return c; + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @return ConstantInteger value + * @throws ClassFormatException if constant type does not match tag + * @see ConstantInteger + */ + public ConstantInteger getConstantInteger(final int index) { + return getConstant(index, Const.CONSTANT_Integer, ConstantInteger.class); + } + + /** + * @return Array of constants. + * @see Constant + */ + public Constant[] getConstantPool() { + return constantPool; + } + + /** + * @param constantPool + */ + public void setConstantPool(final Constant[] constantPool) { + this.constantPool = constantPool; + } + + /** + * Gets string from constant pool and bypass the indirection of 'ConstantClass' and 'ConstantString' objects. I.e. these classes have an index field that + * points to another entry of the constant pool of type 'ConstantUtf8' which contains the real data. + * + * @param index Index in constant pool + * @param tag Tag of expected constant, either ConstantClass or ConstantString + * @return Contents of string reference + * @throws IllegalArgumentException if tag is invalid + * @see ConstantClass + * @see ConstantString + */ + public String getConstantString(final int index, final byte tag) throws IllegalArgumentException { + int i; + /* + * This switch() is not that elegant, since the four classes have the same contents, they just differ in the name of the index field variable. But we + * want to stick to the JVM naming conventions closely though we could have solved these more elegantly by using the same variable name or by + * subclassing. + */ + switch (tag) { + case Const.CONSTANT_Class: + i = getConstant(index, ConstantClass.class).getNameIndex(); + break; + case Const.CONSTANT_String: + i = getConstant(index, ConstantString.class).getStringIndex(); + break; + case Const.CONSTANT_Module: + i = getConstant(index, ConstantModule.class).getNameIndex(); + break; + case Const.CONSTANT_Package: + i = getConstant(index, ConstantPackage.class).getNameIndex(); + break; + case Const.CONSTANT_Utf8: + return getConstantUtf8(index).getBytes(); + default: + throw new IllegalArgumentException("getConstantString called with illegal tag " + tag); + } + // Finally get the string from the constant pool + return getConstantUtf8(i).getBytes(); + } + + /** + * Gets constant from constant pool and check whether it has the expected type. + * + * @param index Index in constant pool + * @return ConstantUtf8 value + * @throws ClassFormatException if constant type does not match tag + * @see ConstantUtf8 + */ + public ConstantUtf8 getConstantUtf8(final int index) throws ClassFormatException { + return getConstant(index, Const.CONSTANT_Utf8, ConstantUtf8.class); + } + + /** + * @return Length of constant pool. + */ + public int getLength() { + return constantPool == null ? 0 : constantPool.length; + } + + @Override + public Iterator iterator() { + return Arrays.stream(constantPool).iterator(); + } + + /** + * @param constant Constant to set + */ + public void setConstant(final int index, final Constant constant) { + constantPool[index] = constant; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 1; i < constantPool.length; i++) { + buf.append(i).append(")").append(constantPool[i]).append("\n"); + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java new file mode 100644 index 0000000..287e092 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantString.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from the abstract {@link Constant} and represents a reference to a String object. + * + * @see Constant + */ +public final class ConstantString extends Constant implements ConstantObject { + + private int stringIndex; // Identical to ConstantClass except for this name + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public ConstantString(final ConstantString c) { + this(c.getStringIndex()); + } + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantString(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + /** + * @param stringIndex Index of Constant_Utf8 in constant pool + */ + public ConstantString(final int stringIndex) { + super(Const.CONSTANT_String); + this.stringIndex = stringIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantString(this); + } + + /** + * Dump constant field reference to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(stringIndex); + } + + /** + * @return dereferenced string + */ + public String getBytes(final ConstantPool cp) { + return (String) getConstantValue(cp); + } + + /** + * @return String object + */ + @Override + public Object getConstantValue(final ConstantPool cp) { + return cp.getConstantUtf8(stringIndex).getBytes(); + } + + /** + * @return Index in constant pool of the string (ConstantUtf8). + */ + public int getStringIndex() { + return stringIndex; + } + + /** + * @param stringIndex the index into the constant of the string value + */ + public void setStringIndex(final int stringIndex) { + this.stringIndex = stringIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return super.toString() + "(stringIndex = " + stringIndex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java new file mode 100644 index 0000000..4755c41 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Extends the abstract {@link Constant} to represent a reference to a UTF-8 encoded string. + *

+ * The following system properties govern caching this class performs. + *

+ *
    + *
  • {@value #SYS_PROP_CACHE_MAX_ENTRIES} (since 6.4): The size of the cache, by default 0, meaning caching is + * disabled.
  • + *
  • {@value #SYS_PROP_CACHE_MAX_ENTRY_SIZE} (since 6.0): The maximum size of the values to cache, by default 200, 0 + * disables caching. Values larger than this are not cached.
  • + *
  • {@value #SYS_PROP_STATISTICS} (since 6.0): Prints statistics on the console when the JVM exits.
  • + *
+ *

+ * Here is a sample Maven invocation with caching disabled: + *

+ * + *
+ * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=0 -Dbcel.maxcached=0
+ * 
+ *

+ * Here is a sample Maven invocation with caching enabled: + *

+ * + *
+ * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=100000 -Dbcel.maxcached=5000000
+ * 
+ * + * @LastModified: Feb 2023 + * @see Constant + */ +public final class ConstantUtf8 extends Constant { + + private static final String SYS_PROP_CACHE_MAX_ENTRIES = "bcel.maxcached"; + private static final String SYS_PROP_CACHE_MAX_ENTRY_SIZE = "bcel.maxcached.size"; + private static final String SYS_PROP_STATISTICS = "bcel.statistics"; + // TODO these should perhaps be AtomicInt? + private static volatile int considered; + private static volatile int created; + private static volatile int hits; + private static volatile int skipped; + + static { + if (Cache.BCEL_STATISTICS) { + Runtime.getRuntime().addShutdownHook(new Thread(ConstantUtf8::printStats)); + } + } + + private final String value; + + /** + * Initializes from another object. + * + * @param constantUtf8 the value. + */ + public ConstantUtf8(final ConstantUtf8 constantUtf8) { + this(constantUtf8.getBytes()); + } + + /** + * Initializes instance from file data. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs. + */ + ConstantUtf8(final DataInput dataInput) throws IOException { + super(Const.CONSTANT_Utf8); + value = dataInput.readUTF(); + created++; + } + + /** + * @param value Data + */ + public ConstantUtf8(final String value) { + super(Const.CONSTANT_Utf8); + this.value = Objects.requireNonNull(value, "value"); + created++; + } + + /** + * Clears the cache. + * + * @since 6.4.0 + */ + public static synchronized void clearCache() { + Cache.CACHE.clear(); + } + + // for access by test code + static synchronized void clearStats() { + hits = considered = skipped = created = 0; + } + + /** + * Gets a new or cached instance of the given value. + *

+ * See {@link ConstantUtf8} class Javadoc for details. + *

+ * + * @param value the value. + * @return a new or cached instance of the given value. + * @since 6.0 + */ + public static ConstantUtf8 getCachedInstance(final String value) { + if (value.length() > Cache.MAX_ENTRY_SIZE) { + skipped++; + return new ConstantUtf8(value); + } + considered++; + synchronized (ConstantUtf8.class) { // might be better with a specific lock object + ConstantUtf8 result = Cache.CACHE.get(value); + if (result != null) { + hits++; + return result; + } + result = new ConstantUtf8(value); + Cache.CACHE.put(value, result); + return result; + } + } + + /** + * Gets a new or cached instance of the given value. + *

+ * See {@link ConstantUtf8} class Javadoc for details. + *

+ * + * @param dataInput the value. + * @return a new or cached instance of the given value. + * @throws IOException if an I/O error occurs. + * @since 6.0 + */ + public static ConstantUtf8 getInstance(final DataInput dataInput) throws IOException { + return getInstance(dataInput.readUTF()); + } + + /** + * Gets a new or cached instance of the given value. + *

+ * See {@link ConstantUtf8} class Javadoc for details. + *

+ * + * @param value the value. + * @return a new or cached instance of the given value. + * @since 6.0 + */ + public static ConstantUtf8 getInstance(final String value) { + return Cache.isEnabled() ? getCachedInstance(value) : new ConstantUtf8(value); + } + + // for access by test code + static void printStats() { + final String prefix = "[Apache Commons BCEL]"; + System.err.printf("%s Cache hit %,d/%,d, %d skipped.%n", prefix, hits, considered, skipped); + System.err.printf("%s Total of %,d ConstantUtf8 objects created.%n", prefix, created); + System.err.printf("%s Configuration: %s=%,d, %s=%,d.%n", prefix, SYS_PROP_CACHE_MAX_ENTRIES, Cache.MAX_ENTRIES, SYS_PROP_CACHE_MAX_ENTRY_SIZE, + Cache.MAX_ENTRY_SIZE); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantUtf8(this); + } + + /** + * Dumps String in Utf8 format to file stream. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(super.getTag()); + file.writeUTF(value); + } + + /** + * @return Data converted to string. + */ + public String getBytes() { + return value; + } + + /** + * @param bytes the raw bytes of this UTF-8 + * @deprecated (since 6.0) + */ + @java.lang.Deprecated + public void setBytes(final String bytes) { + throw new UnsupportedOperationException(); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return super.toString() + "(\"" + Utility.replace(value, "\n", "\\n") + "\")"; + } + + private static class Cache { + + private static final boolean BCEL_STATISTICS = false; + private static final int MAX_ENTRIES = 20000; + private static final int INITIAL_CAPACITY = (int) (MAX_ENTRIES / 0.75); + + private static final HashMap CACHE = new LinkedHashMap(INITIAL_CAPACITY, 0.75f, true) { + + private static final long serialVersionUID = -8506975356158971766L; + + @Override + protected boolean removeEldestEntry(final Map.Entry eldest) { + return size() > MAX_ENTRIES; + } + }; + + // Set the size to 0 or below to skip caching entirely + private static final int MAX_ENTRY_SIZE = 200; + + static boolean isEnabled() { + return Cache.MAX_ENTRIES > 0 && MAX_ENTRY_SIZE > 0; + } + + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java new file mode 100644 index 0000000..9b20061 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java @@ -0,0 +1,162 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents a constant value, i.e., a default value for initializing + * a class field. This class is instantiated by the Attribute.readAttribute() method. + * + *
+ * ConstantValue_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 constantvalue_index;
+ * }
+ * 
+ * + * @see Attribute + */ +public final class ConstantValue extends Attribute { + + private int constantValueIndex; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public ConstantValue(final ConstantValue c) { + this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Name index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ConstantValue(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Name index in constant pool + * @param length Content length in bytes + * @param constantValueIndex Index in constant pool + * @param constantPool Array of constants + */ + public ConstantValue(final int nameIndex, final int length, final int constantValueIndex, final ConstantPool constantPool) { + super(Const.ATTR_CONSTANT_VALUE, nameIndex, Args.require(length, 2, "ConstantValue attribute length"), constantPool); + this.constantValueIndex = constantValueIndex; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitConstantValue(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ConstantValue c = (ConstantValue) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump constant value attribute to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(constantValueIndex); + } + + /** + * @return Index in constant pool of constant value. + */ + public int getConstantValueIndex() { + return constantValueIndex; + } + + /** + * @param constantValueIndex the index info the constant pool of this constant value + */ + public void setConstantValueIndex(final int constantValueIndex) { + this.constantValueIndex = constantValueIndex; + } + + /** + * @return String representation of constant value. + */ + @Override + public String toString() { + Constant c = super.getConstantPool().getConstant(constantValueIndex); + String buf; + int i; + // Print constant to string depending on its type + switch (c.getTag()) { + case Const.CONSTANT_Long: + buf = String.valueOf(((ConstantLong) c).getBytes()); + break; + case Const.CONSTANT_Float: + buf = String.valueOf(((ConstantFloat) c).getBytes()); + break; + case Const.CONSTANT_Double: + buf = String.valueOf(((ConstantDouble) c).getBytes()); + break; + case Const.CONSTANT_Integer: + buf = String.valueOf(((ConstantInteger) c).getBytes()); + break; + case Const.CONSTANT_String: + i = ((ConstantString) c).getStringIndex(); + c = super.getConstantPool().getConstantUtf8(i); + buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\""; + break; + default: + throw new IllegalStateException("Type of ConstValue invalid: " + c); + } + return buf; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java new file mode 100644 index 0000000..675e525 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Deprecated.java @@ -0,0 +1,138 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and denotes that this is a deprecated method. It is instantiated from + * the Attribute.readAttribute() method. + * + * @see Attribute + */ +public final class Deprecated extends Attribute { + + private byte[] bytes; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Deprecated(final Deprecated c) { + this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param bytes Attribute contents + * @param constantPool Array of constants + */ + public Deprecated(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_DEPRECATED, nameIndex, Args.require0(length, "Deprecated attribute length"), constantPool); + this.bytes = bytes; + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Deprecated(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + println("Deprecated attribute with length > 0"); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitDeprecated(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Deprecated c = (Deprecated) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @param bytes the raw bytes that represents this byte array + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return attribute name + */ + @Override + public String toString() { + return Const.getAttributeName(Const.ATTR_DEPRECATED) + ": true"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java new file mode 100644 index 0000000..e8ac91f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java @@ -0,0 +1,581 @@ +/* + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.util.Objects; +import java.util.Stack; +import java.util.stream.Stream; + +/** + * Traverses a JavaClass with another Visitor object 'piggy-backed' that is + * applied to all components of a JavaClass object. I.e. this class supplies the + * traversal strategy, other classes can make use of it. + */ +public class DescendingVisitor implements Visitor { + private final JavaClass clazz; + + private final Visitor visitor; + + private final Stack stack = new Stack<>(); + + /** + * @param clazz Class to traverse + * @param visitor visitor object to apply to all components + */ + public DescendingVisitor(final JavaClass clazz, final Visitor visitor) { + this.clazz = clazz; + this.visitor = visitor; + } + + private void accept(final E[] node) { + Stream.of(node).forEach(e -> e.accept(this)); + } + + /** + * @return current object + */ + public Object current() { + return stack.peek(); + } + + /** + * @return container of current entitity, i.e., predecessor during traversal + */ + public Object predecessor() { + return predecessor(0); + } + + /** + * @param level nesting level, i.e., 0 returns the direct predecessor + * @return container of current entitity, i.e., predecessor during traversal + */ + public Object predecessor(final int level) { + final int size = stack.size(); + if (size < 2 || level < 0) { + return null; + } + return stack.elementAt(size - (level + 2)); // size - 1 == current + } + + /** + * Start traversal. + */ + public void visit() { + clazz.accept(this); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations annotation) { + stack.push(annotation); + annotation.accept(visitor); + accept(annotation.getAnnotationEntries()); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry annotationEntry) { + stack.push(annotationEntry); + annotationEntry.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods bm) { + stack.push(bm); + bm.accept(visitor); + // BootstrapMethod[] bms = bm.getBootstrapMethods(); + // for (int i = 0; i < bms.length; i++) + // { + // bms[i].accept(this); + // } + stack.pop(); + } + + @Override + public void visitCode(final Code code) { + stack.push(code); + code.accept(visitor); + accept(code.getExceptionTable()); + accept(code.getAttributes()); + stack.pop(); + } + + @Override + public void visitCodeException(final CodeException ce) { + stack.push(ce); + ce.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantClass(final ConstantClass constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantDouble(final ConstantDouble constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.3 + */ + @Override + public void visitConstantDynamic(final ConstantDynamic obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantFieldref(final ConstantFieldref constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantFloat(final ConstantFloat constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantInteger(final ConstantInteger constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantInvokeDynamic(final ConstantInvokeDynamic constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantLong(final ConstantLong constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantMethodref(final ConstantMethodref constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantModule(final ConstantModule obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantPackage(final ConstantPackage obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantPool(final ConstantPool cp) { + stack.push(cp); + cp.accept(visitor); + Stream.of(cp.getConstantPool()).filter(Objects::nonNull).forEach(e -> e.accept(this)); + stack.pop(); + } + + @Override + public void visitConstantString(final ConstantString constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantUtf8(final ConstantUtf8 constant) { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantValue(final ConstantValue cv) { + stack.push(cv); + cv.accept(visitor); + stack.pop(); + } + + @Override + public void visitDeprecated(final Deprecated attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitExceptionTable(final ExceptionTable table) { + stack.push(table); + table.accept(visitor); + stack.pop(); + } + + @Override + public void visitField(final Field field) { + stack.push(field); + field.accept(visitor); + accept(field.getAttributes()); + stack.pop(); + } + + @Override + public void visitInnerClass(final InnerClass inner) { + stack.push(inner); + inner.accept(visitor); + stack.pop(); + } + + @Override + public void visitInnerClasses(final InnerClasses ic) { + stack.push(ic); + ic.accept(visitor); + accept(ic.getInnerClasses()); + stack.pop(); + } + + @Override + public void visitJavaClass(final JavaClass clazz) { + stack.push(clazz); + clazz.accept(visitor); + accept(clazz.getFields()); + accept(clazz.getMethods()); + accept(clazz.getAttributes()); + clazz.getConstantPool().accept(this); + stack.pop(); + } + + @Override + public void visitLineNumber(final LineNumber number) { + stack.push(number); + number.accept(visitor); + stack.pop(); + } + + @Override + public void visitLineNumberTable(final LineNumberTable table) { + stack.push(table); + table.accept(visitor); + accept(table.getLineNumberTable()); + stack.pop(); + } + + @Override + public void visitLocalVariable(final LocalVariable var) { + stack.push(var); + var.accept(visitor); + stack.pop(); + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable table) { + stack.push(table); + table.accept(visitor); + accept(table.getLocalVariableTable()); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitMethod(final Method method) { + stack.push(method); + method.accept(visitor); + accept(method.getAttributes()); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitMethodParameter(final MethodParameter obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) { + stack.push(obj); + obj.accept(visitor); + Stream.of(obj.getParameters()).forEach(e -> e.accept(this)); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModule(final Module obj) { + stack.push(obj); + obj.accept(visitor); + accept(obj.getRequiresTable()); + accept(obj.getExportsTable()); + accept(obj.getOpensTable()); + accept(obj.getProvidesTable()); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleExports(final ModuleExports obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleMainClass(final ModuleMainClass obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleOpens(final ModuleOpens obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModulePackages(final ModulePackages obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleProvides(final ModuleProvides obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleRequires(final ModuleRequires obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitNestHost(final NestHost obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.4.0 + */ + @Override + public void visitNestMembers(final NestMembers obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + @Override + public void visitSignature(final Signature attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitSourceFile(final SourceFile attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitStackMap(final StackMap table) { + stack.push(table); + table.accept(visitor); + accept(table.getStackMap()); + stack.pop(); + } + + @Override + public void visitStackMapEntry(final StackMapEntry var) { + stack.push(var); + var.accept(visitor); + stack.pop(); + } + + @Override + public void visitSynthetic(final Synthetic attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitUnknown(final Unknown attribute) { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java new file mode 100644 index 0000000..cb89c6c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValue.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * The element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1 + * + *
+ * element_value {
+ *    u1 tag;
+ *    union {
+ *        u2 const_value_index;
+ *
+ *        {   u2 type_name_index;
+ *            u2 const_name_index;
+ *        } enum_const_value;
+ *
+ *        u2 class_info_index;
+ *
+ *        annotation annotation_value;
+ *
+ *        {   u2            num_values;
+ *            element_value values[num_values];
+ *        } array_value;
+ *    } value;
+ * }
+ * 
+ * + * @LastModified: May 2021 + * @since 6.0 + */ +public abstract class ElementValue { + + public static final byte STRING = 's'; + public static final byte ENUM_CONSTANT = 'e'; + public static final byte CLASS = 'c'; + public static final byte ANNOTATION = '@'; + public static final byte ARRAY = '['; + public static final byte PRIMITIVE_INT = 'I'; + public static final byte PRIMITIVE_BYTE = 'B'; + public static final byte PRIMITIVE_CHAR = 'C'; + public static final byte PRIMITIVE_DOUBLE = 'D'; + public static final byte PRIMITIVE_FLOAT = 'F'; + public static final byte PRIMITIVE_LONG = 'J'; + public static final byte PRIMITIVE_SHORT = 'S'; + public static final byte PRIMITIVE_BOOLEAN = 'Z'; + + /** + * Reads an {@code element_value} as an {@code ElementValue}. + * + * @param input Raw data input. + * @param cpool Constant pool. + * @return a new ElementValue. + * @throws IOException if an I/O error occurs. + */ + public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException { + return readElementValue(input, cpool, 0); + } + + /** + * Reads an {@code element_value} as an {@code ElementValue}. + * + * @param input Raw data input. + * @param cpool Constant pool. + * @param arrayNesting level of current array nesting. + * @return a new ElementValue. + * @throws IOException if an I/O error occurs. + * @since 6.7.0 + */ + public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool, int arrayNesting) + throws IOException { + final byte tag = input.readByte(); + switch (tag) { + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_DOUBLE: + case PRIMITIVE_FLOAT: + case PRIMITIVE_INT: + case PRIMITIVE_LONG: + case PRIMITIVE_SHORT: + case PRIMITIVE_BOOLEAN: + case STRING: + return new SimpleElementValue(tag, input.readUnsignedShort(), cpool); + + case ENUM_CONSTANT: + return new EnumElementValue(ENUM_CONSTANT, input.readUnsignedShort(), input.readUnsignedShort(), cpool); + + case CLASS: + return new ClassElementValue(CLASS, input.readUnsignedShort(), cpool); + + case ANNOTATION: + // TODO isRuntimeVisible + return new AnnotationElementValue(ANNOTATION, AnnotationEntry.read(input, cpool, false), cpool); + + case ARRAY: + arrayNesting++; + if (arrayNesting > Const.MAX_ARRAY_DIMENSIONS) { + // JVM spec 4.4.1 + throw new ClassFormatException(String.format("Arrays are only valid if they represent %,d or fewer dimensions.", Const.MAX_ARRAY_DIMENSIONS)); + } + final int numArrayVals = input.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; + for (int j = 0; j < numArrayVals; j++) { + evalues[j] = ElementValue.readElementValue(input, cpool, arrayNesting); + } + return new ArrayElementValue(ARRAY, evalues, cpool); + + default: + throw new ClassFormatException("Unexpected element value tag in annotation: " + tag); + } + } + + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @java.lang.Deprecated + protected int type; // TODO should be final + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @java.lang.Deprecated + protected ConstantPool cpool; // TODO should be final + + protected ElementValue(final int type, final ConstantPool cpool) { + this.type = type; + this.cpool = cpool; + } + + public abstract void dump(DataOutputStream dos) throws IOException; + + /** + * @since 6.0 + */ + final ConstantPool getConstantPool() { + return cpool; + } + + public int getElementValueType() { + return type; + } + + /** + * @since 6.0 + */ + final int getType() { + return type; + } + + public abstract String stringifyValue(); + + public String toShortString() { + return stringifyValue(); + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java new file mode 100644 index 0000000..8a2e670 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java @@ -0,0 +1,70 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * An annotation's element value pair. + * + * @since 6.0 + */ +public class ElementValuePair { + + static final ElementValuePair[] EMPTY_ARRAY = {}; + + private final ElementValue elementValue; + + private final ConstantPool constantPool; + + private final int elementNameIndex; + + public ElementValuePair(final int elementNameIndex, final ElementValue elementValue, final ConstantPool constantPool) { + this.elementValue = elementValue; + this.elementNameIndex = elementNameIndex; + this.constantPool = constantPool; + } + + protected void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(elementNameIndex); // u2 name of the element + elementValue.dump(dos); + } + + public int getNameIndex() { + return elementNameIndex; + } + + public String getNameString() { + return constantPool.getConstantUtf8(elementNameIndex).getBytes(); + } + + public final ElementValue getValue() { + return elementValue; + } + + public String toShortString() { + final StringBuilder result = new StringBuilder(); + result.append(getNameString()).append("=").append(getValue().toShortString()); + return result.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java new file mode 100644 index 0000000..bb4d8cc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java @@ -0,0 +1,343 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Visitor with empty method bodies, can be extended and used in conjunction with the DescendingVisitor class, e.g. By + * courtesy of David Spencer. + * + * @see DescendingVisitor + */ +public class EmptyVisitor implements Visitor { + protected EmptyVisitor() { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods obj) { + } + + @Override + public void visitCode(final Code obj) { + } + + @Override + public void visitCodeException(final CodeException obj) { + } + + @Override + public void visitConstantClass(final ConstantClass obj) { + } + + @Override + public void visitConstantDouble(final ConstantDouble obj) { + } + + /** + * @since 6.3 + */ + @Override + public void visitConstantDynamic(final ConstantDynamic obj) { + } + + @Override + public void visitConstantFieldref(final ConstantFieldref obj) { + } + + @Override + public void visitConstantFloat(final ConstantFloat obj) { + } + + @Override + public void visitConstantInteger(final ConstantInteger obj) { + } + + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) { + } + + @Override + public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj) { + } + + @Override + public void visitConstantLong(final ConstantLong obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) { + } + + @Override + public void visitConstantMethodref(final ConstantMethodref obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantModule(final ConstantModule constantModule) { + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType obj) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantPackage(final ConstantPackage constantPackage) { + } + + @Override + public void visitConstantPool(final ConstantPool obj) { + } + + @Override + public void visitConstantString(final ConstantString obj) { + } + + @Override + public void visitConstantUtf8(final ConstantUtf8 obj) { + } + + @Override + public void visitConstantValue(final ConstantValue obj) { + } + + @Override + public void visitDeprecated(final Deprecated obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) { + } + + @Override + public void visitExceptionTable(final ExceptionTable obj) { + } + + @Override + public void visitField(final Field obj) { + } + + @Override + public void visitInnerClass(final InnerClass obj) { + } + + @Override + public void visitInnerClasses(final InnerClasses obj) { + } + + @Override + public void visitJavaClass(final JavaClass obj) { + } + + @Override + public void visitLineNumber(final LineNumber obj) { + } + + @Override + public void visitLineNumberTable(final LineNumberTable obj) { + } + + @Override + public void visitLocalVariable(final LocalVariable obj) { + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) { + } + + @Override + public void visitMethod(final Method obj) { + } + + /** + * @since 6.0 + * @Override public void visitStackMapTable(StackMapTable obj) { } + */ + + /** + * @since 6.0 + * @Override public void visitStackMapTableEntry(StackMapTableEntry obj) { } + */ + + /** + * @since 6.4.0 + */ + @Override + public void visitMethodParameter(final MethodParameter obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModule(final Module obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleExports(final ModuleExports obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleMainClass(final ModuleMainClass obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleOpens(final ModuleOpens obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModulePackages(final ModulePackages obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleProvides(final ModuleProvides obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitModuleRequires(final ModuleRequires obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitNestHost(final NestHost obj) { + } + + /** + * @since 6.4.0 + */ + @Override + public void visitNestMembers(final NestMembers obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) { + } + + @Override + public void visitSignature(final Signature obj) { + } + + @Override + public void visitSourceFile(final SourceFile obj) { + } + + @Override + public void visitStackMap(final StackMap obj) { + } + + @Override + public void visitStackMapEntry(final StackMapEntry obj) { + } + + @Override + public void visitSynthetic(final Synthetic obj) { + } + + @Override + public void visitUnknown(final Unknown obj) { + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java new file mode 100644 index 0000000..326e777 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java @@ -0,0 +1,107 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This attribute exists for local or anonymous classes and ... there can be only one. + * + * @since 6.0 + */ +public class EnclosingMethod extends Attribute { + + // Pointer to the CONSTANT_Class_info structure representing the + // innermost class that encloses the declaration of the current class. + private int classIndex; + + // If the current class is not immediately enclosed by a method or + // constructor, then the value of the method_index item must be zero. + // Otherwise, the value of the method_index item must point to a + // CONSTANT_NameAndType_info structure representing the name and the + // type of a method in the class referenced by the class we point + // to in the class_index. *It is the compiler responsibility* to + // ensure that the method identified by this index is the closest + // lexically enclosing method that includes the local/anonymous class. + private int methodIndex; + + // Ctors - and code to read an attribute in. + EnclosingMethod(final int nameIndex, final int len, final DataInput input, final ConstantPool cpool) throws IOException { + this(nameIndex, len, input.readUnsignedShort(), input.readUnsignedShort(), cpool); + } + + private EnclosingMethod(final int nameIndex, final int len, final int classIndex, final int methodIndex, final ConstantPool cpool) { + super(Const.ATTR_ENCLOSING_METHOD, nameIndex, Args.require(len, 4, "EnclosingMethod attribute length"), cpool); + this.classIndex = Args.requireU2(classIndex, 0, cpool.getLength(), "EnclosingMethod class index"); + this.methodIndex = Args.requireU2(methodIndex, "EnclosingMethod method index"); + } + + @Override + public void accept(final Visitor v) { + v.visitEnclosingMethod(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(classIndex); + file.writeShort(methodIndex); + } + + public final ConstantClass getEnclosingClass() { + return super.getConstantPool().getConstant(classIndex, Const.CONSTANT_Class, ConstantClass.class); + } + + // Accessors + public final int getEnclosingClassIndex() { + return classIndex; + } + + public final ConstantNameAndType getEnclosingMethod() { + if (methodIndex == 0) { + return null; + } + return super.getConstantPool().getConstant(methodIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + } + + public final int getEnclosingMethodIndex() { + return methodIndex; + } + + public final void setEnclosingClassIndex(final int idx) { + classIndex = idx; + } + + public final void setEnclosingMethodIndex(final int idx) { + methodIndex = idx; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java new file mode 100644 index 0000000..0a8163e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java @@ -0,0 +1,72 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class EnumElementValue extends ElementValue { + // For enum types, these two indices point to the type and value + private final int typeIdx; + + private final int valueIdx; + + public EnumElementValue(final int type, final int typeIdx, final int valueIdx, final ConstantPool cpool) { + super(type, cpool); + if (type != ENUM_CONSTANT) { + throw new ClassFormatException("Only element values of type enum can be built with this ctor - type specified: " + type); + } + this.typeIdx = typeIdx; + this.valueIdx = valueIdx; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getType()); // u1 type of value (ENUM_CONSTANT == 'e') + dos.writeShort(typeIdx); // u2 + dos.writeShort(valueIdx); // u2 + } + + public String getEnumTypeString() { + return super.getConstantPool().getConstantUtf8(typeIdx).getBytes(); + } + + public String getEnumValueString() { + return super.getConstantPool().getConstantUtf8(valueIdx).getBytes(); + } + + public int getTypeIndex() { + return typeIdx; + } + + public int getValueIndex() { + return valueIdx; + } + + @Override + public String stringifyValue() { + return super.getConstantPool().getConstantUtf8(valueIdx).getBytes(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java new file mode 100644 index 0000000..ba65ad8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents the table of exceptions that are thrown by a method. This attribute may be used once per + * method. The name of this class is ExceptionTable for historical reasons; The Java Virtual Machine + * Specification, Second Edition defines this attribute using the name Exceptions (which is inconsistent with + * the other classes). + * + *
+ * Exceptions_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 number_of_exceptions;
+ *   u2 exception_index_table[number_of_exceptions];
+ * }
+ * 
+ * + * @LastModified: Feb 2023 + * @see Code + */ +public final class ExceptionTable extends Attribute { + + private int[] exceptionIndexTable; // constant pool + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ExceptionTable(final ExceptionTable c) { + this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ExceptionTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int exceptionCount = input.readUnsignedShort(); + exceptionIndexTable = new int[exceptionCount]; + for (int i = 0; i < exceptionCount; i++) { + exceptionIndexTable[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param exceptionIndexTable Table of indices in constant pool + * @param constantPool Array of constants + */ + public ExceptionTable(final int nameIndex, final int length, final int[] exceptionIndexTable, final ConstantPool constantPool) { + super(Const.ATTR_EXCEPTIONS, nameIndex, length, constantPool); + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.exceptionIndexTable.length, "exceptionIndexTable.length"); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ExceptionTable c = (ExceptionTable) clone(); + if (exceptionIndexTable != null) { + c.exceptionIndexTable = exceptionIndexTable.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump exceptions attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(exceptionIndexTable.length); + for (final int index : exceptionIndexTable) { + file.writeShort(index); + } + } + + /** + * @return Array of indices into constant pool of thrown exceptions. + */ + public int[] getExceptionIndexTable() { + return exceptionIndexTable; + } + + /** + * @return class names of thrown exceptions + */ + public String[] getExceptionNames() { + final String[] names = new String[exceptionIndexTable.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class))); + return names; + } + + /** + * @return Length of exception table. + */ + public int getNumberOfExceptions() { + return exceptionIndexTable == null ? 0 : exceptionIndexTable.length; + } + + /** + * @param exceptionIndexTable the list of exception indexes Also redefines number_of_exceptions according to table + * length. + */ + public void setExceptionIndexTable(final int[] exceptionIndexTable) { + this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of thrown exceptions. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + String str; + buf.append("Exceptions: "); + for (int i = 0; i < exceptionIndexTable.length; i++) { + str = super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class); + buf.append(Utility.compactClassName(str, false)); + if (i < exceptionIndexTable.length - 1) { + buf.append(", "); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java new file mode 100644 index 0000000..cc5b3bb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Field.java @@ -0,0 +1,198 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM + * specification for details. + */ +public final class Field extends FieldOrMethod { + + /** + * Empty array constant. + * + * @since 6.6.0 + */ + public static final Field[] EMPTY_ARRAY = {}; + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final Field THIS = (Field) o1; + final Field THAT = (Field) o2; + return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final Field THIS = (Field) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * Empty array. + */ + static final Field[] EMPTY_FIELD_ARRAY = {}; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + /** + * Construct object from file stream. + * + * @param file Input stream + */ + Field(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException { + super(file, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Field(final Field c) { + super(c); + } + + /** + * @param accessFlags Access rights of field + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + public Field(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) { + super(accessFlags, nameIndex, signatureIndex, attributes, constantPool); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitField(this); + } + + /** + * @return deep copy of this field + */ + public Field copy(final ConstantPool constantPool) { + return (Field) copy_(constantPool); + } + + /** + * Return value as defined by given BCELComparator strategy. By default two Field objects are said to be equal when + * their names and signatures are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return constant value associated with this field (may be null) + */ + public ConstantValue getConstantValue() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute.getTag() == Const.ATTR_CONSTANT_VALUE) { + return (ConstantValue) attribute; + } + } + return null; + } + + /** + * @return type of field + */ + public Type getType() { + return Type.getReturnType(getSignature()); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Return string representation close to declaration format, 'public static final short MAX = 100', e.g.. + * + * @return String representation of field, including the signature. + */ + @Override + public String toString() { + String name; + String signature; + String access; // Short cuts to constant pool + + // Get names from constant pool + access = Utility.accessToString(super.getAccessFlags()); + access = access.isEmpty() ? "" : access + " "; + signature = Utility.signatureToString(getSignature()); + name = getName(); + final StringBuilder buf = new StringBuilder(64); // CHECKSTYLE IGNORE MagicNumber + buf.append(access).append(signature).append(" ").append(name); + final ConstantValue cv = getConstantValue(); + if (cv != null) { + buf.append(" = ").append(cv); + } + for (final Attribute attribute : super.getAttributes()) { + if (!(attribute instanceof ConstantValue)) { + buf.append(" [").append(attribute).append("]"); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java new file mode 100644 index 0000000..0311ef3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +/** + * Abstract super class for fields and methods. + * + * @LastModified: Jan 2020 + */ +public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_index; // Points to field name in constant pool + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int signature_index; // Points to encoded signature + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected Attribute[] attributes; // Collection of attributes + + /** + * @deprecated (since 6.0) will be removed (not needed) + */ + @java.lang.Deprecated + protected int attributes_count; // No. of attributes + + // @since 6.0 + private AnnotationEntry[] annotationEntries; // annotations defined on the field or method + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected ConstantPool constant_pool; + + private String signatureAttributeString; + private boolean searchedForSignatureAttribute; + + FieldOrMethod() { + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + protected FieldOrMethod(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, constantPool); + final int attributesCount = file.readUnsignedShort(); + attributes = new Attribute[attributesCount]; + for (int i = 0; i < attributesCount; i++) { + attributes[i] = Attribute.readAttribute(file, constantPool); + } + this.attributes_count = attributesCount; // init deprecated field + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput, ConstantPool)} instead. + */ + @java.lang.Deprecated + protected FieldOrMethod(final DataInputStream file, final ConstantPool constantPool) throws IOException { + this((DataInput) file, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + protected FieldOrMethod(final FieldOrMethod c) { + this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c.getConstantPool()); + } + + /** + * @param accessFlags Access rights of method + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + protected FieldOrMethod(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, + final ConstantPool constantPool) { + super(accessFlags); + this.name_index = nameIndex; + this.signature_index = signatureIndex; + this.constant_pool = constantPool; + setAttributes(attributes); + } + + /** + * @return deep copy of this field + */ + protected FieldOrMethod copy_(final ConstantPool constantPool) { + try { + final FieldOrMethod c = (FieldOrMethod) clone(); + c.constant_pool = constantPool; + c.attributes = new Attribute[attributes.length]; + c.attributes_count = attributes_count; // init deprecated field + Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool)); + return c; + } catch (final CloneNotSupportedException e) { + throw new IllegalStateException(e); + } + } + + /** + * Dump object to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(super.getAccessFlags()); + file.writeShort(name_index); + file.writeShort(signature_index); + file.writeShort(attributes_count); + if (attributes != null) { + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } + } + + /** + * @return Annotations on the field or method + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotationEntries == null) { + annotationEntries = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotationEntries; + } + + /** + * @return Collection of object attributes. + */ + public final Attribute[] getAttributes() { + return attributes; + } + + /** + * @return Constant pool used by this object. + */ + public final ConstantPool getConstantPool() { + return constant_pool; + } + + /** + * Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature may be + * (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector<Ljava/lang/String>;' Coded for + * performance - searches for the attribute only when requested - only searches for it once. + * + * @since 6.0 + */ + public final String getGenericSignature() { + if (!searchedForSignatureAttribute) { + boolean found = false; + for (int i = 0; !found && i < attributes.length; i++) { + if (attributes[i] instanceof Signature) { + signatureAttributeString = ((Signature) attributes[i]).getSignature(); + found = true; + } + } + searchedForSignatureAttribute = true; + } + return signatureAttributeString; + } + + /** + * @return Name of object, i.e., method name or field name + */ + public final String getName() { + return constant_pool.getConstantUtf8(name_index).getBytes(); + } + + /** + * @return Index in constant pool of object's name. + */ + public final int getNameIndex() { + return name_index; + } + + /** + * @return String representation of object's type signature (java style) + */ + public final String getSignature() { + return constant_pool.getConstantUtf8(signature_index).getBytes(); + } + + /** + * @return Index in constant pool of field signature. + */ + public final int getSignatureIndex() { + return signature_index; + } + + /** + * @param attributes Collection of object attributes. + */ + public final void setAttributes(final Attribute[] attributes) { + this.attributes = attributes; + this.attributes_count = attributes != null ? attributes.length : 0; // init deprecated field + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public final void setConstantPool(final ConstantPool constantPool) { + this.constant_pool = constantPool; + } + + /** + * @param nameIndex Index in constant pool of object's name. + */ + public final void setNameIndex(final int nameIndex) { + this.name_index = nameIndex; + } + + /** + * @param signatureIndex Index in constant pool of field signature. + */ + public final void setSignatureIndex(final int signatureIndex) { + this.signature_index = signatureIndex; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java new file mode 100644 index 0000000..9cce5cc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClass.java @@ -0,0 +1,198 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a inner class attribute, i.e., the class indices of the inner and outer classes, the name and + * the attributes of the inner class. + * + * @see InnerClasses + */ +public final class InnerClass implements Cloneable, Node { + + private int innerClassIndex; + private int outerClassIndex; + private int innerNameIndex; + private int innerAccessFlags; + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + InnerClass(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * Initialize from another object. + * + * @param c Source to copy. + */ + public InnerClass(final InnerClass c) { + this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c.getInnerAccessFlags()); + } + + /** + * @param innerClassIndex Class index in constant pool of inner class + * @param outerClassIndex Class index in constant pool of outer class + * @param innerNameIndex Name index in constant pool of inner class + * @param innerAccessFlags Access flags of inner class + */ + public InnerClass(final int innerClassIndex, final int outerClassIndex, final int innerNameIndex, final int innerAccessFlags) { + this.innerClassIndex = innerClassIndex; + this.outerClassIndex = outerClassIndex; + this.innerNameIndex = innerNameIndex; + this.innerAccessFlags = innerAccessFlags; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitInnerClass(this); + } + + /** + * @return deep copy of this object + */ + public InnerClass copy() { + try { + return (InnerClass) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump inner class attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(innerClassIndex); + file.writeShort(outerClassIndex); + file.writeShort(innerNameIndex); + file.writeShort(innerAccessFlags); + } + + /** + * @return access flags of inner class. + */ + public int getInnerAccessFlags() { + return innerAccessFlags; + } + + /** + * @return class index of inner class. + */ + public int getInnerClassIndex() { + return innerClassIndex; + } + + /** + * @return name index of inner class. + */ + public int getInnerNameIndex() { + return innerNameIndex; + } + + /** + * @return class index of outer class. + */ + public int getOuterClassIndex() { + return outerClassIndex; + } + + /** + * @param innerAccessFlags access flags for this inner class + */ + public void setInnerAccessFlags(final int innerAccessFlags) { + this.innerAccessFlags = innerAccessFlags; + } + + /** + * @param innerClassIndex index into the constant pool for this class + */ + public void setInnerClassIndex(final int innerClassIndex) { + this.innerClassIndex = innerClassIndex; + } + + /** + * @param innerNameIndex index into the constant pool for this class's name + */ + public void setInnerNameIndex(final int innerNameIndex) { // TODO unused + this.innerNameIndex = innerNameIndex; + } + + /** + * @param outerClassIndex index into the constant pool for the owning class + */ + public void setOuterClassIndex(final int outerClassIndex) { // TODO unused + this.outerClassIndex = outerClassIndex; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + return "InnerClass(" + innerClassIndex + ", " + outerClassIndex + ", " + innerNameIndex + ", " + innerAccessFlags + ")"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + String outerClassName; + String innerName; + String innerClassName = constantPool.getConstantString(innerClassIndex, Const.CONSTANT_Class); + innerClassName = Utility.compactClassName(innerClassName, false); + if (outerClassIndex != 0) { + outerClassName = constantPool.getConstantString(outerClassIndex, Const.CONSTANT_Class); + outerClassName = " of class " + Utility.compactClassName(outerClassName, false); + } else { + outerClassName = ""; + } + if (innerNameIndex != 0) { + innerName = constantPool.getConstantUtf8(innerNameIndex).getBytes(); + } else { + innerName = "(anonymous)"; + } + String access = Utility.accessToString(innerAccessFlags, true); + access = access.isEmpty() ? "" : access + " "; + return " " + access + innerName + "=class " + innerClassName + outerClassName; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java new file mode 100644 index 0000000..322ecbc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java @@ -0,0 +1,161 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and denotes that this class is an Inner class of another. to the source + * file of this class. It is instantiated from the Attribute.readAttribute() method. + * + * @see Attribute + */ +public final class InnerClasses extends Attribute implements Iterable { + + /** + * Empty array. + */ + private static final InnerClass[] EMPTY_INNER_CLASSE_ARRAY = {}; + + private InnerClass[] innerClasses; + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public InnerClasses(final InnerClasses c) { + this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool()); + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + InnerClasses(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (InnerClass[]) null, constantPool); + final int classCount = input.readUnsignedShort(); + innerClasses = new InnerClass[classCount]; + for (int i = 0; i < classCount; i++) { + innerClasses[i] = new InnerClass(input); + } + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param innerClasses array of inner classes attributes + * @param constantPool Array of constants + */ + public InnerClasses(final int nameIndex, final int length, final InnerClass[] innerClasses, final ConstantPool constantPool) { + super(Const.ATTR_INNER_CLASSES, nameIndex, length, constantPool); + this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY; + Args.requireU2(this.innerClasses.length, "innerClasses.length"); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitInnerClasses(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + // TODO this could be recoded to use a lower level constructor after creating a copy of the inner classes + final InnerClasses c = (InnerClasses) clone(); + c.innerClasses = new InnerClass[innerClasses.length]; + Arrays.setAll(c.innerClasses, i -> innerClasses[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(innerClasses.length); + for (final InnerClass innerClass : innerClasses) { + innerClass.dump(file); + } + } + + /** + * @return array of inner class "records" + */ + public InnerClass[] getInnerClasses() { + return innerClasses; + } + + @Override + public Iterator iterator() { + return Stream.of(innerClasses).iterator(); + } + + /** + * @param innerClasses the array of inner classes + */ + public void setInnerClasses(final InnerClass[] innerClasses) { + this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("InnerClasses("); + buf.append(innerClasses.length); + buf.append("):\n"); + for (final InnerClass innerClass : innerClasses) { + buf.append(innerClass.toString(super.getConstantPool())).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java new file mode 100644 index 0000000..744db67 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/JavaClass.java @@ -0,0 +1,864 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.util.BCELComparator; +import com.sun.org.apache.bcel.internal.util.ClassQueue; +import com.sun.org.apache.bcel.internal.util.SyntheticRepository; + +/** + * Represents a Java class, i.e., the data structures, constant pool, fields, methods and commands contained in a Java + * .class file. See JVM specification for details. The intent of + * this class is to represent a parsed or otherwise existing class file. Those interested in programmatically generating + * classes should see the ClassGen class. + * + * @LastModified: Feb 2023 + * @see com.sun.org.apache.bcel.internal.generic.ClassGen + */ +public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { + + /** + * The standard class file extension. + * + * @since 6.7.0 + */ + public static final String EXTENSION = ".class"; + + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final JavaClass[] EMPTY_ARRAY = {}; + + public static final byte HEAP = 1; + public static final byte FILE = 2; + public static final byte ZIP = 3; + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final JavaClass THIS = (JavaClass) o1; + final JavaClass THAT = (JavaClass) o2; + return Objects.equals(THIS.getClassName(), THAT.getClassName()); + } + + @Override + public int hashCode(final Object o) { + final JavaClass THIS = (JavaClass) o; + return THIS.getClassName().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + private static String indent(final Object obj) { + final StringTokenizer tokenizer = new StringTokenizer(obj.toString(), "\n"); + final StringBuilder buf = new StringBuilder(); + while (tokenizer.hasMoreTokens()) { + buf.append("\t").append(tokenizer.nextToken()).append("\n"); + } + return buf.toString(); + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private String fileName; + private final String packageName; + private String sourceFileName = ""; + private int classNameIndex; + private int superclassNameIndex; + private String className; + private String superclassName; + private int major; + private int minor; // Compiler version + private ConstantPool constantPool; // Constant pool + private int[] interfaces; // implemented interfaces + private String[] interfaceNames; + private Field[] fields; // Fields, i.e., variables of class + private Method[] methods; // methods defined in the class + private Attribute[] attributes; // attributes defined in the class + + private AnnotationEntry[] annotations; // annotations defined on the class + private byte source = HEAP; // Generated in memory + + private boolean isAnonymous; + + private boolean isNested; + + private boolean computedNestedTypeStatus; + + /** + * In cases where we go ahead and create something, use the default SyntheticRepository, because we don't know any + * better. + */ + private transient com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance(); + + /** + * Constructor gets all contents as arguments. + * + * @param classNameIndex Class name + * @param superclassNameIndex Superclass name + * @param fileName File name + * @param major Major compiler version + * @param minor Minor compiler version + * @param accessFlags Access rights defined by bit flags + * @param constantPool Array of constants + * @param interfaces Implemented interfaces + * @param fields Class fields + * @param methods Class methods + * @param attributes Class attributes + */ + public JavaClass(final int classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags, + final ConstantPool constantPool, final int[] interfaces, final Field[] fields, final Method[] methods, final Attribute[] attributes) { + this(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes, HEAP); + } + + /** + * Constructor gets all contents as arguments. + * + * @param classNameIndex Index into constant pool referencing a ConstantClass that represents this class. + * @param superclassNameIndex Index into constant pool referencing a ConstantClass that represents this class's + * superclass. + * @param fileName File name + * @param major Major compiler version + * @param minor Minor compiler version + * @param accessFlags Access rights defined by bit flags + * @param constantPool Array of constants + * @param interfaces Implemented interfaces + * @param fields Class fields + * @param methods Class methods + * @param attributes Class attributes + * @param source Read from file or generated in memory? + */ + public JavaClass(final int classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags, + final ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, final byte source) { + super(accessFlags); + if (interfaces == null) { + interfaces = Const.EMPTY_INT_ARRAY; + } + if (attributes == null) { + attributes = Attribute.EMPTY_ARRAY; + } + if (fields == null) { + fields = Field.EMPTY_FIELD_ARRAY; + } + if (methods == null) { + methods = Method.EMPTY_METHOD_ARRAY; + } + this.classNameIndex = classNameIndex; + this.superclassNameIndex = superclassNameIndex; + this.fileName = fileName; + this.major = major; + this.minor = minor; + this.constantPool = constantPool; + this.interfaces = interfaces; + this.fields = fields; + this.methods = methods; + this.attributes = attributes; + this.source = source; + // Get source file name if available + for (final Attribute attribute : attributes) { + if (attribute instanceof SourceFile) { + sourceFileName = ((SourceFile) attribute).getSourceFileName(); + break; + } + } + /* + * According to the specification the following entries must be of type 'ConstantClass' but we check that anyway via the + * 'ConstPool.getConstant' method. + */ + className = constantPool.getConstantString(classNameIndex, Const.CONSTANT_Class); + className = Utility.compactClassName(className, false); + final int index = className.lastIndexOf('.'); + if (index < 0) { + packageName = ""; + } else { + packageName = className.substring(0, index); + } + if (superclassNameIndex > 0) { + // May be zero -> class is java.lang.Object + superclassName = constantPool.getConstantString(superclassNameIndex, Const.CONSTANT_Class); + superclassName = Utility.compactClassName(superclassName, false); + } else { + superclassName = "java.lang.Object"; + } + interfaceNames = new String[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) { + final String str = constantPool.getConstantString(interfaces[i], Const.CONSTANT_Class); + interfaceNames[i] = Utility.compactClassName(str, false); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitJavaClass(this); + } + + /** + * Return the natural ordering of two JavaClasses. This ordering is based on the class name + * + * @since 6.0 + */ + @Override + public int compareTo(final JavaClass obj) { + return getClassName().compareTo(obj.getClassName()); + } + + private void computeNestedTypeStatus() { + if (computedNestedTypeStatus) { + return; + } + for (final Attribute attribute : this.attributes) { + if (attribute instanceof InnerClasses) { + ((InnerClasses) attribute).forEach(innerClass -> { + boolean innerClassAttributeRefersToMe = false; + String innerClassName = constantPool.getConstantString(innerClass.getInnerClassIndex(), Const.CONSTANT_Class); + innerClassName = Utility.compactClassName(innerClassName, false); + if (innerClassName.equals(getClassName())) { + innerClassAttributeRefersToMe = true; + } + if (innerClassAttributeRefersToMe) { + this.isNested = true; + if (innerClass.getInnerNameIndex() == 0) { + this.isAnonymous = true; + } + } + }); + } + } + this.computedNestedTypeStatus = true; + } + + /** + * @return deep copy of this class + */ + public JavaClass copy() { + try { + final JavaClass c = (JavaClass) clone(); + c.constantPool = constantPool.copy(); + c.interfaces = interfaces.clone(); + c.interfaceNames = interfaceNames.clone(); + c.fields = new Field[fields.length]; + Arrays.setAll(c.fields, i -> fields[i].copy(c.constantPool)); + c.methods = new Method[methods.length]; + Arrays.setAll(c.methods, i -> methods[i].copy(c.constantPool)); + c.attributes = new Attribute[attributes.length]; + Arrays.setAll(c.attributes, i -> attributes[i].copy(c.constantPool)); + return c; + } catch (final CloneNotSupportedException e) { + return null; + } + } + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeInt(Const.JVM_CLASSFILE_MAGIC); + file.writeShort(minor); + file.writeShort(major); + constantPool.dump(file); + file.writeShort(super.getAccessFlags()); + file.writeShort(classNameIndex); + file.writeShort(superclassNameIndex); + file.writeShort(interfaces.length); + for (final int interface1 : interfaces) { + file.writeShort(interface1); + } + file.writeShort(fields.length); + for (final Field field : fields) { + field.dump(file); + } + file.writeShort(methods.length); + for (final Method method : methods) { + method.dump(file); + } + if (attributes != null) { + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } else { + file.writeShort(0); + } + file.flush(); + } + + /** + * Dump class to a file. + * + * @param file Output file + * @throws IOException if an I/O error occurs. + */ + public void dump(final File file) throws IOException { + final String parent = file.getParent(); + if (parent != null) { + final File dir = new File(parent); + if (!dir.mkdirs() && !dir.isDirectory()) { + throw new IOException("Could not create the directory " + dir); + } + } + try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) { + dump(dos); + } + } + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final OutputStream file) throws IOException { + dump(new DataOutputStream(file)); + } + + /** + * Dump class to a file named fileName. + * + * @param fileName Output file name + * @throws IOException if an I/O error occurs. + */ + public void dump(final String fileName) throws IOException { + dump(new File(fileName)); + } + + /** + * Return value as defined by given BCELComparator strategy. By default two JavaClass objects are said to be equal when + * their class names are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * Get all interfaces implemented by this JavaClass (transitively). + * + * @throws ClassNotFoundException if any of the class's superclasses or interfaces can't be found. + */ + public JavaClass[] getAllInterfaces() throws ClassNotFoundException { + final ClassQueue queue = new ClassQueue(); + final Set allInterfaces = new TreeSet<>(); + queue.enqueue(this); + while (!queue.empty()) { + final JavaClass clazz = queue.dequeue(); + final JavaClass souper = clazz.getSuperClass(); + final JavaClass[] interfaces = clazz.getInterfaces(); + if (clazz.isInterface()) { + allInterfaces.add(clazz); + } else if (souper != null) { + queue.enqueue(souper); + } + for (final JavaClass iface : interfaces) { + queue.enqueue(iface); + } + } + return allInterfaces.toArray(JavaClass.EMPTY_ARRAY); + } + + /** + * @return Annotations on the class + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotations == null) { + annotations = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotations; + } + + /** + * @return Attributes of the class. + */ + public Attribute[] getAttributes() { + return attributes; + } + + /** + * @return class in binary format + */ + public byte[] getBytes() { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (DataOutputStream dos = new DataOutputStream(baos)) { + dump(dos); + } catch (final IOException e) { + e.printStackTrace(); + } + return baos.toByteArray(); + } + + /** + * @return Class name. + */ + public String getClassName() { + return className; + } + + /** + * @return Class name index. + */ + public int getClassNameIndex() { + return classNameIndex; + } + + /** + * @return Constant pool. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return Fields, i.e., variables of the class. Like the JVM spec mandates for the classfile format, these fields are + * those specific to this class, and not those of the superclass or superinterfaces. + */ + public Field[] getFields() { + return fields; + } + + /** + * @return File name of class, aka SourceFile attribute value + */ + public String getFileName() { + return fileName; + } + + /** + * @return Indices in constant pool of implemented interfaces. + */ + public int[] getInterfaceIndices() { + return interfaces; + } + + /** + * @return Names of implemented interfaces. + */ + public String[] getInterfaceNames() { + return interfaceNames; + } + + /** + * Get interfaces directly implemented by this JavaClass. + * + * @throws ClassNotFoundException if any of the class's interfaces can't be found. + */ + public JavaClass[] getInterfaces() throws ClassNotFoundException { + final String[] interfaces = getInterfaceNames(); + final JavaClass[] classes = new JavaClass[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) { + classes[i] = repository.loadClass(interfaces[i]); + } + return classes; + } + + /** + * @return Major number of class file version. + */ + public int getMajor() { + return major; + } + + /** + * @return A {@link Method} corresponding to java.lang.reflect.Method if any + */ + public Method getMethod(final java.lang.reflect.Method m) { + for (final Method method : methods) { + if (m.getName().equals(method.getName()) && m.getModifiers() == method.getModifiers() && Type.getSignature(m).equals(method.getSignature())) { + return method; + } + } + return null; + } + + /** + * @return Methods of the class. + */ + public Method[] getMethods() { + return methods; + } + + /** + * @return Minor number of class file version. + */ + public int getMinor() { + return minor; + } + + /** + * @return Package name. + */ + public String getPackageName() { + return packageName; + } + + /** + * Gets the ClassRepository which holds its definition. By default this is the same as + * SyntheticRepository.getInstance(); + */ + public com.sun.org.apache.bcel.internal.util.Repository getRepository() { + return repository; + } + + /** + * @return returns either HEAP (generated), FILE, or ZIP + */ + public final byte getSource() { + return source; + } + + /** + * @return file name where this class was read from + */ + public String getSourceFileName() { + return sourceFileName; + } + + /** + * Gets the source file path including the package path. + * + * @return path to original source file of parsed class, relative to original source directory. + * @since 6.7.0 + */ + public String getSourceFilePath() { + final StringBuilder outFileName = new StringBuilder(); + if (!packageName.isEmpty()) { + outFileName.append(Utility.packageToPath(packageName)); + outFileName.append('/'); + } + outFileName.append(sourceFileName); + return outFileName.toString(); + } + + /** + * @return the superclass for this JavaClass object, or null if this is java.lang.Object + * @throws ClassNotFoundException if the superclass can't be found + */ + public JavaClass getSuperClass() throws ClassNotFoundException { + if ("java.lang.Object".equals(getClassName())) { + return null; + } + return repository.loadClass(getSuperclassName()); + } + + /** + * @return list of super classes of this class in ascending order, i.e., java.lang.Object is always the last element + * @throws ClassNotFoundException if any of the superclasses can't be found + */ + public JavaClass[] getSuperClasses() throws ClassNotFoundException { + JavaClass clazz = this; + final List allSuperClasses = new ArrayList<>(); + for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { + allSuperClasses.add(clazz); + } + return allSuperClasses.toArray(JavaClass.EMPTY_ARRAY); + } + + /** + * returns the super class name of this class. In the case that this class is java.lang.Object, it will return itself + * (java.lang.Object). This is probably incorrect but isn't fixed at this time to not break existing clients. + * + * @return Superclass name. + */ + public String getSuperclassName() { + return superclassName; + } + + /** + * @return Class name index. + */ + public int getSuperclassNameIndex() { + return superclassNameIndex; + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * @return true, if this class is an implementation of interface inter + * @throws ClassNotFoundException if superclasses or superinterfaces of this class can't be found + */ + public boolean implementationOf(final JavaClass inter) throws ClassNotFoundException { + if (!inter.isInterface()) { + throw new IllegalArgumentException(inter.getClassName() + " is no interface"); + } + if (this.equals(inter)) { + return true; + } + final JavaClass[] superInterfaces = getAllInterfaces(); + for (final JavaClass superInterface : superInterfaces) { + if (superInterface.equals(inter)) { + return true; + } + } + return false; + } + + /** + * Equivalent to runtime "instanceof" operator. + * + * @return true if this JavaClass is derived from the super class + * @throws ClassNotFoundException if superclasses or superinterfaces of this object can't be found + */ + public final boolean instanceOf(final JavaClass superclass) throws ClassNotFoundException { + if (this.equals(superclass)) { + return true; + } + for (final JavaClass clazz : getSuperClasses()) { + if (clazz.equals(superclass)) { + return true; + } + } + if (superclass.isInterface()) { + return implementationOf(superclass); + } + return false; + } + + /** + * @since 6.0 + */ + public final boolean isAnonymous() { + computeNestedTypeStatus(); + return this.isAnonymous; + } + + public final boolean isClass() { + return (super.getAccessFlags() & Const.ACC_INTERFACE) == 0; + } + + /** + * @since 6.0 + */ + public final boolean isNested() { + computeNestedTypeStatus(); + return this.isNested; + } + + public final boolean isSuper() { + return (super.getAccessFlags() & Const.ACC_SUPER) != 0; + } + + /** + * @param attributes . + */ + public void setAttributes(final Attribute[] attributes) { + this.attributes = attributes; + } + + /** + * @param className . + */ + public void setClassName(final String className) { + this.className = className; + } + + /** + * @param classNameIndex . + */ + public void setClassNameIndex(final int classNameIndex) { + this.classNameIndex = classNameIndex; + } + + /** + * @param constantPool . + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + /** + * @param fields . + */ + public void setFields(final Field[] fields) { + this.fields = fields; + } + + /** + * Set File name of class, aka SourceFile attribute value + */ + public void setFileName(final String fileName) { + this.fileName = fileName; + } + + /** + * @param interfaceNames . + */ + public void setInterfaceNames(final String[] interfaceNames) { + this.interfaceNames = interfaceNames; + } + + /** + * @param interfaces . + */ + public void setInterfaces(final int[] interfaces) { + this.interfaces = interfaces; + } + + /** + * @param major . + */ + public void setMajor(final int major) { + this.major = major; + } + + /** + * @param methods . + */ + public void setMethods(final Method[] methods) { + this.methods = methods; + } + + /** + * @param minor . + */ + public void setMinor(final int minor) { + this.minor = minor; + } + + /** + * Sets the ClassRepository which loaded the JavaClass. Should be called immediately after parsing is done. + */ + public void setRepository(final com.sun.org.apache.bcel.internal.util.Repository repository) { // TODO make protected? + this.repository = repository; + } + + /** + * Set absolute path to file this class was read from. + */ + public void setSourceFileName(final String sourceFileName) { + this.sourceFileName = sourceFileName; + } + + /** + * @param superclassName . + */ + public void setSuperclassName(final String superclassName) { + this.superclassName = superclassName; + } + + /** + * @param superclassNameIndex . + */ + public void setSuperclassNameIndex(final int superclassNameIndex) { + this.superclassNameIndex = superclassNameIndex; + } + + /** + * @return String representing class contents. + */ + @Override + public String toString() { + String access = Utility.accessToString(super.getAccessFlags(), true); + access = access.isEmpty() ? "" : access + " "; + final StringBuilder buf = new StringBuilder(128); + buf.append(access).append(Utility.classOrInterface(super.getAccessFlags())).append(" ").append(className).append(" extends ") + .append(Utility.compactClassName(superclassName, false)).append('\n'); + final int size = interfaces.length; + if (size > 0) { + buf.append("implements\t\t"); + for (int i = 0; i < size; i++) { + buf.append(interfaceNames[i]); + if (i < size - 1) { + buf.append(", "); + } + } + buf.append('\n'); + } + buf.append("file name\t\t").append(fileName).append('\n'); + buf.append("compiled from\t\t").append(sourceFileName).append('\n'); + buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); + buf.append("access flags\t\t").append(super.getAccessFlags()).append('\n'); + buf.append("constant pool\t\t").append(constantPool.getLength()).append(" entries\n"); + buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n"); + if (attributes.length > 0) { + buf.append("\nAttribute(s):\n"); + for (final Attribute attribute : attributes) { + buf.append(indent(attribute)); + } + } + final AnnotationEntry[] annotations = getAnnotationEntries(); + if (annotations != null && annotations.length > 0) { + buf.append("\nAnnotation(s):\n"); + for (final AnnotationEntry annotation : annotations) { + buf.append(indent(annotation)); + } + } + if (fields.length > 0) { + buf.append("\n").append(fields.length).append(" fields:\n"); + for (final Field field : fields) { + buf.append("\t").append(field).append('\n'); + } + } + if (methods.length > 0) { + buf.append("\n").append(methods.length).append(" methods:\n"); + for (final Method method : methods) { + buf.append("\t").append(method).append('\n'); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java new file mode 100644 index 0000000..ea00b75 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumber.java @@ -0,0 +1,147 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents a (PC offset, line number) pair, i.e., a line number in the source that corresponds to a + * relative address in the byte code. This is used for debugging purposes. + * + * @see LineNumberTable + */ +public final class LineNumber implements Cloneable, Node { + + static final LineNumber[] EMPTY_ARRAY = {}; + + /** + * Program Counter (PC) corresponds to line + */ + private int startPc; + + /** + * number in source file + */ + private int lineNumber; + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + LineNumber(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + /** + * @param startPc Program Counter (PC) corresponds to + * @param lineNumber line number in source file + */ + public LineNumber(final int startPc, final int lineNumber) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.lineNumber = Args.requireU2(lineNumber, "lineNumber"); + } + + /** + * Initialize from another object. + * + * @param c the object to copy + */ + public LineNumber(final LineNumber c) { + this(c.getStartPC(), c.getLineNumber()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLineNumber(this); + } + + /** + * @return deep copy of this object + */ + public LineNumber copy() { + try { + return (LineNumber) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump line number/pc pair to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(startPc); + file.writeShort(lineNumber); + } + + /** + * @return Corresponding source line + */ + public int getLineNumber() { + return lineNumber & 0xffff; + } + + /** + * @return PC in code + */ + public int getStartPC() { + return startPc & 0xffff; + } + + /** + * @param lineNumber the source line number + */ + public void setLineNumber(final int lineNumber) { + this.lineNumber = (short) lineNumber; + } + + /** + * @param startPc the pc for this line number + */ + public void setStartPC(final int startPc) { + this.startPc = (short) startPc; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "LineNumber(" + getStartPC() + ", " + getLineNumber() + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java new file mode 100644 index 0000000..3afb2f9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +import jdk.xml.internal.SecuritySupport; + +/** + * This class represents a table of line numbers for debugging purposes. This attribute is used by the Code + * attribute. It contains pairs of PCs and line numbers. + * + * @LastModified: May 2021 + * @see Code + * @see LineNumber + */ +public final class LineNumberTable extends Attribute implements Iterable { + + private static final int MAX_LINE_LENGTH = 72; + private LineNumber[] lineNumberTable; // Table of line/numbers pairs + + /** + * Construct object from input stream. + * + * @param nameIndex Index of name + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + LineNumberTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (LineNumber[]) null, constantPool); + final int lineNumberTableLength = input.readUnsignedShort(); + lineNumberTable = new LineNumber[lineNumberTableLength]; + for (int i = 0; i < lineNumberTableLength; i++) { + lineNumberTable[i] = new LineNumber(input); + } + } + + /* + * @param nameIndex Index of name + * + * @param length Content length in bytes + * + * @param lineNumberTable Table of line/numbers pairs + * + * @param constantPool Array of constants + */ + public LineNumberTable(final int nameIndex, final int length, final LineNumber[] lineNumberTable, final ConstantPool constantPool) { + super(Const.ATTR_LINE_NUMBER_TABLE, nameIndex, length, constantPool); + this.lineNumberTable = lineNumberTable != null ? lineNumberTable : LineNumber.EMPTY_ARRAY; + Args.requireU2(this.lineNumberTable.length, "lineNumberTable.length"); + } + + /* + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + */ + public LineNumberTable(final LineNumberTable c) { + this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLineNumberTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + // TODO could use the lower level constructor and thereby allow + // lineNumberTable to be made final + final LineNumberTable c = (LineNumberTable) clone(); + c.lineNumberTable = new LineNumber[lineNumberTable.length]; + Arrays.setAll(c.lineNumberTable, i -> lineNumberTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump line number table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(lineNumberTable.length); + for (final LineNumber lineNumber : lineNumberTable) { + lineNumber.dump(file); + } + } + + /** + * @return Array of (pc offset, line number) pairs. + */ + public LineNumber[] getLineNumberTable() { + return lineNumberTable; + } + + /** + * Map byte code positions to source code lines. + * + * @param pos byte code offset + * @return corresponding line in source code + */ + public int getSourceLine(final int pos) { + int l = 0; + int r = lineNumberTable.length - 1; + if (r < 0) { + return -1; + } + int minIndex = -1; + int min = -1; + /* + * Do a binary search since the array is ordered. + */ + do { + final int i = l + r >>> 1; + final int j = lineNumberTable[i].getStartPC(); + if (j == pos) { + return lineNumberTable[i].getLineNumber(); + } + if (pos < j) { + r = i - 1; + } else { + l = i + 1; + } + /* + * If exact match can't be found (which is the most common case) return the line number that corresponds to the greatest + * index less than pos. + */ + if (j < pos && j > min) { + min = j; + minIndex = i; + } + } while (l <= r); + /* + * It's possible that we did not find any valid entry for the bytecode offset we were looking for. + */ + if (minIndex < 0) { + return -1; + } + return lineNumberTable[minIndex].getLineNumber(); + } + + public int getTableLength() { + return lineNumberTable == null ? 0 : lineNumberTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(lineNumberTable).iterator(); + } + + /** + * @param lineNumberTable the line number entries for this table + */ + public void setLineNumberTable(final LineNumber[] lineNumberTable) { + this.lineNumberTable = lineNumberTable; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + final StringBuilder line = new StringBuilder(); + for (int i = 0; i < lineNumberTable.length; i++) { + line.append(lineNumberTable[i].toString()); + if (i < lineNumberTable.length - 1) { + line.append(", "); + } + if (line.length() > MAX_LINE_LENGTH && i < lineNumberTable.length - 1) { + line.append(SecuritySupport.NEWLINE); + buf.append(line); + line.setLength(0); + } + } + buf.append(line); + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java new file mode 100644 index 0000000..b844168 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents a local variable within a method. It contains its scope, name, signature and index on the + * method's frame. It is used both to represent an element of the LocalVariableTable as well as an element of the + * LocalVariableTypeTable. The nomenclature used here may be a bit confusing; while the two items have the same layout + * in a class file, a LocalVariableTable attribute contains a descriptor_index, not a signatureIndex. The + * LocalVariableTypeTable attribute does have a signatureIndex. + * + * @LastModified: Feb 2023 + * @see com.sun.org.apache.bcel.internal.classfile.Utility for more details on the difference. + * @see LocalVariableTable + * @see LocalVariableTypeTable + */ +public final class LocalVariable implements Cloneable, Node { + + static final LocalVariable[] EMPTY_ARRAY = {}; + + /** + * Range in which the variable is valid. + */ + private int startPc; + + private int length; + + /** + * Index in constant pool of variable name. + */ + private int nameIndex; + + /** + * Technically, a decscriptor_index for a local variable table entry and a signatureIndex for a local variable type table entry. Index of variable signature + */ + private int signatureIndex; + + /* + * Variable is index'th local variable on this method's frame. + */ + private int index; + + private ConstantPool constantPool; + + /** + * Never changes; used to match up with LocalVariableTypeTable entries. + */ + private final int origIndex; + + /** + * Constructs object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + LocalVariable(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), constantPool); + } + + /** + * @param startPc Range in which the variable + * @param length ... is valid + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature + * @param index Variable is 'index'th local variable on the method's frame + * @param constantPool Array of constants + */ + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool) { + this(startPc, length, nameIndex, signatureIndex, index, constantPool, index); + } + + /** + * @param startPc Range in which the variable + * @param length ... is valid + * @param nameIndex Index in constant pool of variable name + * @param signatureIndex Index of variable's signature + * @param index Variable is 'index'th local variable on the method's frame + * @param constantPool Array of constants + * @param origIndex Variable is 'index'th local variable on the method's frame prior to any changes + */ + public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool, + final int origIndex) { + this.startPc = Args.requireU2(startPc, "startPc"); + this.length = Args.requireU2(length, "length"); + this.nameIndex = Args.requireU2(nameIndex, "nameIndex"); + this.signatureIndex = Args.requireU2(signatureIndex, "signatureIndex"); + this.index = Args.requireU2(index, "index"); + this.origIndex = Args.requireU2(origIndex, "origIndex"); + this.constantPool = constantPool; + } + + /** + * Initializes from another LocalVariable. Note that both objects use the same references (shallow copy). Use copy() for + * a physical copy. + * + * @param localVariable Another LocalVariable. + */ + public LocalVariable(final LocalVariable localVariable) { + this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(), localVariable.getSignatureIndex(), localVariable.getIndex(), + localVariable.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLocalVariable(this); + } + + /** + * @return deep copy of this object + */ + public LocalVariable copy() { + try { + return (LocalVariable) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dumps local variable to file stream in binary format. + * + * @param dataOutputStream Output file stream + * @throws IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void dump(final DataOutputStream dataOutputStream) throws IOException { + dataOutputStream.writeShort(startPc); + dataOutputStream.writeShort(length); + dataOutputStream.writeShort(nameIndex); + dataOutputStream.writeShort(signatureIndex); + dataOutputStream.writeShort(index); + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return index of register where variable is stored + */ + public int getIndex() { + return index; + } + + /** + * @return Variable is valid within getStartPC() .. getStartPC()+getLength() + */ + public int getLength() { + return length; + } + + /** + * @return Variable name. + */ + public String getName() { + return constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * @return Index in constant pool of variable name. + */ + public int getNameIndex() { + return nameIndex; + } + + /** + * @return index of register where variable was originally stored + */ + public int getOrigIndex() { + return origIndex; + } + + /** + * @return Signature. + */ + public String getSignature() { + return constantPool.getConstantUtf8(signatureIndex).getBytes(); + } + + /** + * @return Index in constant pool of variable signature. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @return Start of range where the variable is valid + */ + public int getStartPC() { + return startPc; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + /** + * @param index the index in the local variable table of this variable + */ + public void setIndex(final int index) { // TODO unused + this.index = index; + } + + /** + * @param length the length of this local variable + */ + public void setLength(final int length) { + this.length = length; + } + + /** + * @param nameIndex the index into the constant pool for the name of this variable + */ + public void setNameIndex(final int nameIndex) { // TODO unused + this.nameIndex = nameIndex; + } + + /** + * @param signatureIndex the index into the constant pool for the signature of this variable + */ + public void setSignatureIndex(final int signatureIndex) { // TODO unused + this.signatureIndex = signatureIndex; + } + + /** + * @param startPc Specify range where the local variable is valid. + */ + public void setStartPC(final int startPc) { // TODO unused + this.startPc = startPc; + } + + /** + * @return string representation. + */ + @Override + public String toString() { + return toStringShared(false); + } + + /* + * Helper method shared with LocalVariableTypeTable + */ + String toStringShared(final boolean typeTable) { + final String name = getName(); + final String signature = Utility.signatureToString(getSignature(), false); + final String label = "LocalVariable" + (typeTable ? "Types" : ""); + return label + "(startPc = " + startPc + ", length = " + length + ", index = " + index + ":" + signature + " " + name + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java new file mode 100644 index 0000000..b0b90e8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java @@ -0,0 +1,191 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents colection of local variables in a method. This attribute is contained in the Code + * attribute. + * + * @see Code + * @see LocalVariable + */ +public class LocalVariableTable extends Attribute implements Iterable { + + private LocalVariable[] localVariableTable; // variables + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + LocalVariableTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (LocalVariable[]) null, constantPool); + final int localVariableTableLength = input.readUnsignedShort(); + localVariableTable = new LocalVariable[localVariableTableLength]; + for (int i = 0; i < localVariableTableLength; i++) { + localVariableTable[i] = new LocalVariable(input, constantPool); + } + } + + /** + * @param nameIndex Index in constant pool to 'LocalVariableTable' + * @param length Content length in bytes + * @param localVariableTable Table of local variables + * @param constantPool Array of constants + */ + public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, final ConstantPool constantPool) { + super(Const.ATTR_LOCAL_VARIABLE_TABLE, nameIndex, length, constantPool); + this.localVariableTable = localVariableTable != null ? localVariableTable : LocalVariable.EMPTY_ARRAY; + Args.requireU2(this.localVariableTable.length, "localVariableTable.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public LocalVariableTable(final LocalVariableTable c) { + this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLocalVariableTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final LocalVariableTable c = (LocalVariableTable) clone(); + c.localVariableTable = new LocalVariable[localVariableTable.length]; + Arrays.setAll(c.localVariableTable, i -> localVariableTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump local variable table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(localVariableTable.length); + for (final LocalVariable variable : localVariableTable) { + variable.dump(file); + } + } + + /** + * @param index the variable slot + * @return the first LocalVariable that matches the slot or null if not found + * @deprecated since 5.2 because multiple variables can share the same slot, use getLocalVariable(int index, int pc) + * instead. + */ + @java.lang.Deprecated + public final LocalVariable getLocalVariable(final int index) { + for (final LocalVariable variable : localVariableTable) { + if (variable.getIndex() == index) { + return variable; + } + } + return null; + } + + /** + * @param index the variable slot + * @param pc the current pc that this variable is alive + * @return the LocalVariable that matches or null if not found + */ + public final LocalVariable getLocalVariable(final int index, final int pc) { + for (final LocalVariable variable : localVariableTable) { + if (variable.getIndex() == index) { + final int startPc = variable.getStartPC(); + final int endPc = startPc + variable.getLength(); + if (pc >= startPc && pc <= endPc) { + return variable; + } + } + } + return null; + } + + /** + * @return Array of local variables of method. + */ + public final LocalVariable[] getLocalVariableTable() { + return localVariableTable; + } + + public final int getTableLength() { + return localVariableTable == null ? 0 : localVariableTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(localVariableTable).iterator(); + } + + public final void setLocalVariableTable(final LocalVariable[] localVariableTable) { + this.localVariableTable = localVariableTable; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < localVariableTable.length; i++) { + buf.append(localVariableTable[i]); + if (i < localVariableTable.length - 1) { + buf.append('\n'); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java new file mode 100644 index 0000000..08868a8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java @@ -0,0 +1,160 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +// The new table is used when generic types are about... + +//LocalVariableTable_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 local_variable_table_length; +// { u2 start_pc; +// u2 length; +// u2 name_index; +// u2 descriptor_index; +// u2 index; +// } local_variable_table[local_variable_table_length]; +// } + +//LocalVariableTypeTable_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 local_variable_type_table_length; +// { +// u2 start_pc; +// u2 length; +// u2 name_index; +// u2 signature_index; +// u2 index; +// } localVariableTypeTable[local_variable_type_table_length]; +// } +// J5TODO: Needs some testing ! + +/** + * @since 6.0 + */ +public class LocalVariableTypeTable extends Attribute implements Iterable { + + private LocalVariable[] localVariableTypeTable; // variables + + LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException { + this(nameIdx, len, (LocalVariable[]) null, cpool); + + final int localVariableTypeTableLength = input.readUnsignedShort(); + localVariableTypeTable = new LocalVariable[localVariableTypeTableLength]; + + for (int i = 0; i < localVariableTypeTableLength; i++) { + localVariableTypeTable[i] = new LocalVariable(input, cpool); + } + } + + public LocalVariableTypeTable(final int nameIndex, final int length, final LocalVariable[] localVariableTypeTable, final ConstantPool constantPool) { + super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, nameIndex, length, constantPool); + this.localVariableTypeTable = localVariableTypeTable != null ? localVariableTypeTable : LocalVariable.EMPTY_ARRAY; + Args.requireU2(this.localVariableTypeTable.length, "localVariableTypeTable.length"); + } + + public LocalVariableTypeTable(final LocalVariableTypeTable c) { + this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool()); + } + + @Override + public void accept(final Visitor v) { + v.visitLocalVariableTypeTable(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final LocalVariableTypeTable c = (LocalVariableTypeTable) clone(); + + c.localVariableTypeTable = new LocalVariable[localVariableTypeTable.length]; + Arrays.setAll(c.localVariableTypeTable, i -> localVariableTypeTable[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(localVariableTypeTable.length); + for (final LocalVariable variable : localVariableTypeTable) { + variable.dump(file); + } + } + + public final LocalVariable getLocalVariable(final int index) { + for (final LocalVariable variable : localVariableTypeTable) { + if (variable.getIndex() == index) { + return variable; + } + } + + return null; + } + + public final LocalVariable[] getLocalVariableTypeTable() { + return localVariableTypeTable; + } + + public final int getTableLength() { + return localVariableTypeTable == null ? 0 : localVariableTypeTable.length; + } + + @Override + public Iterator iterator() { + return Stream.of(localVariableTypeTable).iterator(); + } + + public final void setLocalVariableTable(final LocalVariable[] localVariableTable) { + this.localVariableTypeTable = localVariableTable; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + + for (int i = 0; i < localVariableTypeTable.length; i++) { + buf.append(localVariableTypeTable[i].toStringShared(true)); + + if (i < localVariableTypeTable.length - 1) { + buf.append('\n'); + } + } + + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java new file mode 100644 index 0000000..2d9950d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Method.java @@ -0,0 +1,261 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.generic.Type; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * This class represents the method info structure, i.e., the representation for a method in the class. See JVM + * specification for details. A method has access flags, a name, a signature and a number of attributes. + */ +public final class Method extends FieldOrMethod { + + /** + * Empty array constant. + * + * @since 6.6.0 + */ + public static final Method[] EMPTY_ARRAY = {}; + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final Method THIS = (Method) o1; + final Method THAT = (Method) o2; + return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final Method THIS = (Method) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * Empty array. + */ + static final Method[] EMPTY_METHOD_ARRAY = {}; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + // annotations defined on the parameters of a method + private ParameterAnnotationEntry[] parameterAnnotationEntries; + + /** + * Empty constructor, all attributes have to be defined via 'setXXX' methods. Use at your own risk. + */ + public Method() { + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + Method(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException { + super(file, constantPool); + } + + /** + * @param accessFlags Access rights of method + * @param nameIndex Points to field name in constant pool + * @param signatureIndex Points to encoded signature + * @param attributes Collection of attributes + * @param constantPool Array of constants + */ + public Method(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) { + super(accessFlags, nameIndex, signatureIndex, attributes, constantPool); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Method(final Method c) { + super(c); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitMethod(this); + } + + /** + * @return deep copy of this method + */ + public Method copy(final ConstantPool constantPool) { + return (Method) copy_(constantPool); + } + + /** + * Return value as defined by given BCELComparator strategy. By default two method objects are said to be equal when + * their names and signatures are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * @return array of method argument types + */ + public Type[] getArgumentTypes() { + return Type.getArgumentTypes(getSignature()); + } + + /** + * @return Code attribute of method, if any + */ + public Code getCode() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute instanceof Code) { + return (Code) attribute; + } + } + return null; + } + + /** + * @return ExceptionTable attribute of method, if any, i.e., list all exceptions the method may throw not exception + * handlers! + */ + public ExceptionTable getExceptionTable() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute instanceof ExceptionTable) { + return (ExceptionTable) attribute; + } + } + return null; + } + + /** + * @return LineNumberTable of code attribute if any, i.e. the call is forwarded to the Code atribute. + */ + public LineNumberTable getLineNumberTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLineNumberTable(); + } + + /** + * @return LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute. + */ + public LocalVariableTable getLocalVariableTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLocalVariableTable(); + } + + /** + * @return Annotations on the parameters of a method + * @since 6.0 + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + if (parameterAnnotationEntries == null) { + parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes()); + } + return parameterAnnotationEntries; + } + + /** + * @return return type of method + */ + public Type getReturnType() { + return Type.getReturnType(getSignature()); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Return string representation close to declaration format, 'public static void main(String[] args) throws + * IOException', e.g. + * + * @return String representation of the method. + */ + @Override + public String toString() { + final String access = Utility.accessToString(super.getAccessFlags()); + // Get name and signature from constant pool + ConstantUtf8 c = super.getConstantPool().getConstantUtf8(super.getSignatureIndex()); + String signature = c.getBytes(); + c = super.getConstantPool().getConstantUtf8(super.getNameIndex()); + final String name = c.getBytes(); + signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); + final StringBuilder buf = new StringBuilder(signature); + for (final Attribute attribute : super.getAttributes()) { + if (!(attribute instanceof Code || attribute instanceof ExceptionTable)) { + buf.append(" [").append(attribute).append("]"); + } + } + final ExceptionTable e = getExceptionTable(); + if (e != null) { + final String str = e.toString(); + if (!str.isEmpty()) { + buf.append("\n\t\tthrows ").append(str); + } + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java new file mode 100644 index 0000000..a95f012 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java @@ -0,0 +1,129 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Entry of the parameters table. + * + * @see The class File Format : + * The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameter implements Cloneable, Node { + + /** + * Index of the CONSTANT_Utf8_info structure in the constant_pool table representing the name of the parameter + */ + private int nameIndex; + + /** + * The access flags + */ + private int accessFlags; + + public MethodParameter() { + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + MethodParameter(final DataInput input) throws IOException { + nameIndex = input.readUnsignedShort(); + accessFlags = input.readUnsignedShort(); + } + + @Override + public void accept(final Visitor v) { + v.visitMethodParameter(this); + } + + /** + * @return deep copy of this object + */ + public MethodParameter copy() { + try { + return (MethodParameter) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump object to file stream on binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(nameIndex); + file.writeShort(accessFlags); + } + + public int getAccessFlags() { + return accessFlags; + } + + public int getNameIndex() { + return nameIndex; + } + + /** + * Returns the name of the parameter. + */ + public String getParameterName(final ConstantPool constantPool) { + if (nameIndex == 0) { + return null; + } + return constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + public boolean isFinal() { + return (accessFlags & Const.ACC_FINAL) != 0; + } + + public boolean isMandated() { + return (accessFlags & Const.ACC_MANDATED) != 0; + } + + public boolean isSynthetic() { + return (accessFlags & Const.ACC_SYNTHETIC) != 0; + } + + public void setAccessFlags(final int accessFlags) { + this.accessFlags = accessFlags; + } + + public void setNameIndex(final int nameIndex) { + this.nameIndex = nameIndex; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java new file mode 100644 index 0000000..adfe80d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a MethodParameters attribute. + * + * @see The class File Format : + * The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameters extends Attribute implements Iterable { + + /** + * Empty array. + */ + private static final MethodParameter[] EMPTY_METHOD_PARAMETER_ARRAY = {}; + + private MethodParameter[] parameters = EMPTY_METHOD_PARAMETER_ARRAY; + + MethodParameters(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_METHOD_PARAMETERS, nameIndex, length, constantPool); + + final int parameterCount = input.readUnsignedByte(); + parameters = new MethodParameter[parameterCount]; + for (int i = 0; i < parameterCount; i++) { + parameters[i] = new MethodParameter(input); + } + } + + @Override + public void accept(final Visitor v) { + v.visitMethodParameters(this); + } + + @Override + public Attribute copy(final ConstantPool constantPool) { + final MethodParameters c = (MethodParameters) clone(); + c.parameters = new MethodParameter[parameters.length]; + + Arrays.setAll(c.parameters, i -> parameters[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump method parameters attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeByte(parameters.length); + for (final MethodParameter parameter : parameters) { + parameter.dump(file); + } + } + + public MethodParameter[] getParameters() { + return parameters; + } + + @Override + public Iterator iterator() { + return Stream.of(parameters).iterator(); + } + + public void setParameters(final MethodParameter[] parameters) { + this.parameters = parameters; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java new file mode 100644 index 0000000..6bf355e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Module.java @@ -0,0 +1,254 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from Attribute and represents the list of modules required, exported, opened or + * provided by a module. There may be at most one Module attribute in a ClassFile structure. + * + * @see Attribute + * @since 6.4.0 + */ +public final class Module extends Attribute { + + /** + * The module file name extension. + * + * @since 6.7.0 + */ + public static final String EXTENSION = ".jmod"; + + private final int moduleNameIndex; + private final int moduleFlags; + private final int moduleVersionIndex; + + private ModuleRequires[] requiresTable; + private ModuleExports[] exportsTable; + private ModuleOpens[] opensTable; + private final int usesCount; + private final int[] usesIndex; + private ModuleProvides[] providesTable; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Module(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_MODULE, nameIndex, length, constantPool); + + moduleNameIndex = input.readUnsignedShort(); + moduleFlags = input.readUnsignedShort(); + moduleVersionIndex = input.readUnsignedShort(); + + final int requiresCount = input.readUnsignedShort(); + requiresTable = new ModuleRequires[requiresCount]; + for (int i = 0; i < requiresCount; i++) { + requiresTable[i] = new ModuleRequires(input); + } + + final int exportsCount = input.readUnsignedShort(); + exportsTable = new ModuleExports[exportsCount]; + for (int i = 0; i < exportsCount; i++) { + exportsTable[i] = new ModuleExports(input); + } + + final int opensCount = input.readUnsignedShort(); + opensTable = new ModuleOpens[opensCount]; + for (int i = 0; i < opensCount; i++) { + opensTable[i] = new ModuleOpens(input); + } + + usesCount = input.readUnsignedShort(); + usesIndex = new int[usesCount]; + for (int i = 0; i < usesCount; i++) { + usesIndex[i] = input.readUnsignedShort(); + } + + final int providesCount = input.readUnsignedShort(); + providesTable = new ModuleProvides[providesCount]; + for (int i = 0; i < providesCount; i++) { + providesTable[i] = new ModuleProvides(input); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModule(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Module c = (Module) clone(); + + c.requiresTable = new ModuleRequires[requiresTable.length]; + Arrays.setAll(c.requiresTable, i -> requiresTable[i].copy()); + + c.exportsTable = new ModuleExports[exportsTable.length]; + Arrays.setAll(c.exportsTable, i -> exportsTable[i].copy()); + + c.opensTable = new ModuleOpens[opensTable.length]; + Arrays.setAll(c.opensTable, i -> opensTable[i].copy()); + + c.providesTable = new ModuleProvides[providesTable.length]; + Arrays.setAll(c.providesTable, i -> providesTable[i].copy()); + + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump Module attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + + file.writeShort(moduleNameIndex); + file.writeShort(moduleFlags); + file.writeShort(moduleVersionIndex); + + file.writeShort(requiresTable.length); + for (final ModuleRequires entry : requiresTable) { + entry.dump(file); + } + + file.writeShort(exportsTable.length); + for (final ModuleExports entry : exportsTable) { + entry.dump(file); + } + + file.writeShort(opensTable.length); + for (final ModuleOpens entry : opensTable) { + entry.dump(file); + } + + file.writeShort(usesIndex.length); + for (final int entry : usesIndex) { + file.writeShort(entry); + } + + file.writeShort(providesTable.length); + for (final ModuleProvides entry : providesTable) { + entry.dump(file); + } + } + + /** + * @return table of exported interfaces + * @see ModuleExports + */ + public ModuleExports[] getExportsTable() { + return exportsTable; + } + + /** + * @return table of provided interfaces + * @see ModuleOpens + */ + public ModuleOpens[] getOpensTable() { + return opensTable; + } + + /** + * @return table of provided interfaces + * @see ModuleProvides + */ + public ModuleProvides[] getProvidesTable() { + return providesTable; + } + + /** + * @return table of required modules + * @see ModuleRequires + */ + public ModuleRequires[] getRequiresTable() { + return requiresTable; + } + + /** + * @return String representation, i.e., a list of packages. + */ + @Override + public String toString() { + final ConstantPool cp = super.getConstantPool(); + final StringBuilder buf = new StringBuilder(); + buf.append("Module:\n"); + buf.append(" name: ").append(Utility.pathToPackage(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module))).append("\n"); + buf.append(" flags: ").append(String.format("%04x", moduleFlags)).append("\n"); + final String version = moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); + buf.append(" version: ").append(version).append("\n"); + + buf.append(" requires(").append(requiresTable.length).append("):\n"); + for (final ModuleRequires module : requiresTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" exports(").append(exportsTable.length).append("):\n"); + for (final ModuleExports module : exportsTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" opens(").append(opensTable.length).append("):\n"); + for (final ModuleOpens module : opensTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + buf.append(" uses(").append(usesIndex.length).append("):\n"); + for (final int index : usesIndex) { + final String className = cp.getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + + buf.append(" provides(").append(providesTable.length).append("):\n"); + for (final ModuleProvides module : providesTable) { + buf.append(" ").append(module.toString(cp)).append("\n"); + } + + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java new file mode 100644 index 0000000..8a97f4b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java @@ -0,0 +1,123 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the exports table of the Module attribute. Each entry describes a package which may + * open the parent module. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleExports implements Cloneable, Node { + + private final int exportsIndex; // points to CONSTANT_Package_info + private final int exportsFlags; + private final int exportsToCount; + private final int[] exportsToIndex; // points to CONSTANT_Module_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleExports(final DataInput file) throws IOException { + exportsIndex = file.readUnsignedShort(); + exportsFlags = file.readUnsignedShort(); + exportsToCount = file.readUnsignedShort(); + exportsToIndex = new int[exportsToCount]; + for (int i = 0; i < exportsToCount; i++) { + exportsToIndex[i] = file.readUnsignedShort(); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModuleExports(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleExports copy() { + try { + return (ModuleExports) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(exportsIndex); + file.writeShort(exportsFlags); + file.writeShort(exportsToCount); + for (final int entry : exportsToIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "exports(" + exportsIndex + ", " + exportsFlags + ", " + exportsToCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String packageName = constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); + buf.append(Utility.compactClassName(packageName, false)); + buf.append(", ").append(String.format("%04x", exportsFlags)); + buf.append(", to(").append(exportsToCount).append("):\n"); + for (final int index : exportsToIndex) { + final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); + buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java new file mode 100644 index 0000000..c8ef582 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java @@ -0,0 +1,134 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and indicates the main class of a module. There may be at most one + * ModuleMainClass attribute in a ClassFile structure. + * + * @see Attribute + */ +public final class ModuleMainClass extends Attribute { + + private int mainClassIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, 0, constantPool); + mainClassIndex = input.readUnsignedShort(); + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param mainClassIndex Host class index + * @param constantPool Array of constants + */ + public ModuleMainClass(final int nameIndex, final int length, final int mainClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.mainClassIndex = Args.requireU2(mainClassIndex, "mainClassIndex"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ModuleMainClass(final ModuleMainClass c) { + this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., + * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModuleMainClass(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ModuleMainClass c = (ModuleMainClass) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump ModuleMainClass attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(mainClassIndex); + } + + /** + * @return index into constant pool of host class name. + */ + public int getHostClassIndex() { + return mainClassIndex; + } + + /** + * @param mainClassIndex the host class index + */ + public void setHostClassIndex(final int mainClassIndex) { + this.mainClassIndex = mainClassIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("ModuleMainClass: "); + final String className = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(className, false)); + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java new file mode 100644 index 0000000..06b404d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java @@ -0,0 +1,123 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the opens table of the Module attribute. Each entry describes a package which the + * parent module opens. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleOpens implements Cloneable, Node { + + private final int opensIndex; // points to CONSTANT_Package_info + private final int opensFlags; + private final int opensToCount; + private final int[] opensToIndex; // points to CONSTANT_Module_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleOpens(final DataInput file) throws IOException { + opensIndex = file.readUnsignedShort(); + opensFlags = file.readUnsignedShort(); + opensToCount = file.readUnsignedShort(); + opensToIndex = new int[opensToCount]; + for (int i = 0; i < opensToCount; i++) { + opensToIndex[i] = file.readUnsignedShort(); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModuleOpens(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleOpens copy() { + try { + return (ModuleOpens) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(opensIndex); + file.writeShort(opensFlags); + file.writeShort(opensToCount); + for (final int entry : opensToIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "opens(" + opensIndex + ", " + opensFlags + ", " + opensToCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String packageName = constantPool.constantToString(opensIndex, Const.CONSTANT_Package); + buf.append(Utility.compactClassName(packageName, false)); + buf.append(", ").append(String.format("%04x", opensFlags)); + buf.append(", to(").append(opensToCount).append("):\n"); + for (final int index : opensToIndex) { + final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); + buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java new file mode 100644 index 0000000..f876737 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents the list of packages that are exported or opened by the + * Module attribute. There may be at most one ModulePackages attribute in a ClassFile structure. + * + * @LastModified: Feb 2023 + * @see Attribute + */ +public final class ModulePackages extends Attribute { + + private int[] packageIndexTable; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + ModulePackages(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int packageCount = input.readUnsignedShort(); + packageIndexTable = new int[packageCount]; + for (int i = 0; i < packageCount; i++) { + packageIndexTable[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param packageIndexTable Table of indices in constant pool + * @param constantPool Array of constants + */ + public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable, final ConstantPool constantPool) { + super(Const.ATTR_MODULE_PACKAGES, nameIndex, length, constantPool); + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.packageIndexTable.length, "packageIndexTable.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public ModulePackages(final ModulePackages c) { + this(c.getNameIndex(), c.getLength(), c.getPackageIndexTable(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModulePackages(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final ModulePackages c = (ModulePackages) clone(); + if (packageIndexTable != null) { + c.packageIndexTable = packageIndexTable.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump ModulePackages attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(packageIndexTable.length); + for (final int index : packageIndexTable) { + file.writeShort(index); + } + } + + /** + * @return Length of package table. + */ + public int getNumberOfPackages() { + return packageIndexTable == null ? 0 : packageIndexTable.length; + } + + /** + * @return array of indices into constant pool of package names. + */ + public int[] getPackageIndexTable() { + return packageIndexTable; + } + + /** + * @return string array of package names + */ + public String[] getPackageNames() { + final String[] names = new String[packageIndexTable.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(packageIndexTable[i], Const.CONSTANT_Package))); + return names; + } + + /** + * @param packageIndexTable the list of package indexes Also redefines number_of_packages according to table length. + */ + public void setPackageIndexTable(final int[] packageIndexTable) { + this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of packages. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("ModulePackages("); + buf.append(packageIndexTable.length); + buf.append("):\n"); + for (final int index : packageIndexTable) { + final String packageName = super.getConstantPool().getConstantString(index, Const.CONSTANT_Package); + buf.append(" ").append(Utility.compactClassName(packageName, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java new file mode 100644 index 0000000..f6c6058 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java @@ -0,0 +1,119 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the provides table of the Module attribute. Each entry describes a service + * implementation that the parent module provides. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleProvides implements Cloneable, Node { + + private final int providesIndex; // points to CONSTANT_Class_info + private final int providesWithCount; + private final int[] providesWithIndex; // points to CONSTANT_Class_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleProvides(final DataInput file) throws IOException { + providesIndex = file.readUnsignedShort(); + providesWithCount = file.readUnsignedShort(); + providesWithIndex = new int[providesWithCount]; + for (int i = 0; i < providesWithCount; i++) { + providesWithIndex[i] = file.readUnsignedShort(); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModuleProvides(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleProvides copy() { + try { + return (ModuleProvides) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(providesIndex); + file.writeShort(providesWithCount); + for (final int entry : providesWithIndex) { + file.writeShort(entry); + } + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "provides(" + providesIndex + ", " + providesWithCount + ", ...)"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String interfaceName = constantPool.constantToString(providesIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(interfaceName, false)); + buf.append(", with(").append(providesWithCount).append("):\n"); + for (final int index : providesWithIndex) { + final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java new file mode 100644 index 0000000..c9c26c2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java @@ -0,0 +1,112 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents an entry in the requires table of the Module attribute. Each entry describes a module on which + * the parent module depends. + * + * @see Module + * @since 6.4.0 + */ +public final class ModuleRequires implements Cloneable, Node { + + private final int requiresIndex; // points to CONSTANT_Module_info + private final int requiresFlags; + private final int requiresVersionIndex; // either 0 or points to CONSTANT_Utf8_info + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O Exception occurs in readUnsignedShort + */ + ModuleRequires(final DataInput file) throws IOException { + requiresIndex = file.readUnsignedShort(); + requiresFlags = file.readUnsignedShort(); + requiresVersionIndex = file.readUnsignedShort(); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitModuleRequires(this); + } + + // TODO add more getters and setters? + + /** + * @return deep copy of this object + */ + public ModuleRequires copy() { + try { + return (ModuleRequires) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump table entry to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O Exception occurs in writeShort + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeShort(requiresIndex); + file.writeShort(requiresFlags); + file.writeShort(requiresVersionIndex); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "requires(" + requiresIndex + ", " + String.format("%04x", requiresFlags) + ", " + requiresVersionIndex + ")"; + } + + /** + * @return Resolved string representation + */ + public String toString(final ConstantPool constantPool) { + final StringBuilder buf = new StringBuilder(); + final String moduleName = constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); + buf.append(Utility.compactClassName(moduleName, false)); + buf.append(", ").append(String.format("%04x", requiresFlags)); + final String version = requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); + buf.append(", ").append(version); + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java new file mode 100644 index 0000000..7739cb9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestHost.java @@ -0,0 +1,134 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and records the nest host of the nest to which the current class or + * interface claims to belong. There may be at most one NestHost attribute in a ClassFile structure. + * + * @see Attribute + */ +public final class NestHost extends Attribute { + + private int hostClassIndex; + + /** + * Constructs object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + NestHost(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, 0, constantPool); + hostClassIndex = input.readUnsignedShort(); + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param hostClassIndex Host class index + * @param constantPool Array of constants + */ + public NestHost(final int nameIndex, final int length, final int hostClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.hostClassIndex = Args.requireU2(hostClassIndex, "hostClassIndex"); + } + + /** + * Initializes from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public NestHost(final NestHost c) { + this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitNestHost(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final NestHost c = (NestHost) clone(); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dumps NestHost attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(hostClassIndex); + } + + /** + * @return index into constant pool of host class name. + */ + public int getHostClassIndex() { + return hostClassIndex; + } + + /** + * @param hostClassIndex the host class index + */ + public void setHostClassIndex(final int hostClassIndex) { + this.hostClassIndex = hostClassIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("NestHost: "); + final String className = super.getConstantPool().getConstantString(hostClassIndex, Const.CONSTANT_Class); + buf.append(Utility.compactClassName(className, false)); + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java new file mode 100644 index 0000000..436f977 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/NestMembers.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and records the classes and interfaces that are authorized to claim + * membership in the nest hosted by the current class or interface. There may be at most one NestMembers attribute in a + * ClassFile structure. + * + * @LastModified: Feb 2023 + * @see Attribute + */ +public final class NestMembers extends Attribute { + + private int[] classes; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + NestMembers(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (int[]) null, constantPool); + final int classCount = input.readUnsignedShort(); + classes = new int[classCount]; + for (int i = 0; i < classCount; i++) { + classes[i] = input.readUnsignedShort(); + } + } + + /** + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param classes Table of indices in constant pool + * @param constantPool Array of constants + */ + public NestMembers(final int nameIndex, final int length, final int[] classes, final ConstantPool constantPool) { + super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool); + this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY; + Args.requireU2(this.classes.length, "classes.length"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public NestMembers(final NestMembers c) { + this(c.getNameIndex(), c.getLength(), c.getClasses(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitNestMembers(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final NestMembers c = (NestMembers) clone(); + if (classes.length > 0) { + c.classes = classes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump NestMembers attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(classes.length); + for (final int index : classes) { + file.writeShort(index); + } + } + + /** + * @return array of indices into constant pool of class names. + */ + public int[] getClasses() { + return classes; + } + + /** + * @return string array of class names + */ + public String[] getClassNames() { + final String[] names = new String[classes.length]; + Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(classes[i], Const.CONSTANT_Class))); + return names; + } + + /** + * @return Length of classes table. + */ + public int getNumberClasses() { + return classes.length; + } + + /** + * @param classes the list of class indexes Also redefines number_of_classes according to table length. + */ + public void setClasses(final int[] classes) { + this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY; + } + + /** + * @return String representation, i.e., a list of classes. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("NestMembers("); + buf.append(classes.length); + buf.append("):\n"); + for (final int index : classes) { + final String className = super.getConstantPool().getConstantString(index, Const.CONSTANT_Class); + buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + } + return buf.substring(0, buf.length() - 1); // remove the last newline + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java new file mode 100644 index 0000000..c039573 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Node.java @@ -0,0 +1,30 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Denote class to have an accept method(); + */ +public interface Node { + + void accept(Visitor obj); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java new file mode 100644 index 0000000..2272d0d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/PMGClass.java @@ -0,0 +1,157 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class is derived from Attribute and represents a reference to a PMG attribute. + * + * @see Attribute + */ +public final class PMGClass extends Attribute { + + private int pmgClassIndex; + private int pmgIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + PMGClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param pmgIndex index in constant pool for source file name + * @param pmgClassIndex Index in constant pool to CONSTANT_Utf8 + * @param constantPool Array of constants + */ + public PMGClass(final int nameIndex, final int length, final int pmgIndex, final int pmgClassIndex, final ConstantPool constantPool) { + super(Const.ATTR_PMG, nameIndex, length, constantPool); + this.pmgIndex = pmgIndex; + this.pmgClassIndex = pmgClassIndex; + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param pgmClass Source to copy. + */ + public PMGClass(final PMGClass pgmClass) { + this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(), pgmClass.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + println("Visiting non-standard PMGClass object"); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(pmgIndex); + file.writeShort(pmgClassIndex); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getPMGClassIndex() { + return pmgClassIndex; + } + + /** + * @return PMG class name. + */ + public String getPMGClassName() { + return super.getConstantPool().getConstantUtf8(pmgClassIndex).getBytes(); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getPMGIndex() { + return pmgIndex; + } + + /** + * @return PMG name. + */ + public String getPMGName() { + return super.getConstantPool().getConstantUtf8(pmgIndex).getBytes(); + } + + /** + * @param pmgClassIndex + */ + public void setPMGClassIndex(final int pmgClassIndex) { + this.pmgClassIndex = pmgClassIndex; + } + + /** + * @param pmgIndex + */ + public void setPMGIndex(final int pmgIndex) { + this.pmgIndex = pmgIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java new file mode 100644 index 0000000..a3070fa --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java @@ -0,0 +1,93 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * represents one parameter annotation in the parameter annotation table + * + * @since 6.0 + */ +public class ParameterAnnotationEntry implements Node { + + static final ParameterAnnotationEntry[] EMPTY_ARRAY = {}; + + public static ParameterAnnotationEntry[] createParameterAnnotationEntries(final Attribute[] attrs) { + // Find attributes that contain parameter annotation data + final List accumulatedAnnotations = new ArrayList<>(attrs.length); + for (final Attribute attribute : attrs) { + if (attribute instanceof ParameterAnnotations) { + final ParameterAnnotations runtimeAnnotations = (ParameterAnnotations) attribute; + Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getParameterAnnotationEntries()); + } + } + return accumulatedAnnotations.toArray(ParameterAnnotationEntry.EMPTY_ARRAY); + } + + private final AnnotationEntry[] annotationTable; + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException if an I/O error occurs. + */ + ParameterAnnotationEntry(final DataInput input, final ConstantPool constantPool) throws IOException { + final int annotationTableLength = input.readUnsignedShort(); + annotationTable = new AnnotationEntry[annotationTableLength]; + for (int i = 0; i < annotationTableLength; i++) { + // TODO isRuntimeVisible + annotationTable[i] = AnnotationEntry.read(input, constantPool, false); + } + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitParameterAnnotationEntry(this); + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(annotationTable.length); + for (final AnnotationEntry entry : annotationTable) { + entry.dump(dos); + } + } + + /** + * returns the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotationTable; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java new file mode 100644 index 0000000..a067035 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java @@ -0,0 +1,127 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.stream.Stream; + +/** + * base class for parameter annotations + * + * @since 6.0 + */ +public abstract class ParameterAnnotations extends Attribute implements Iterable { + + /** + * Table of parameter annotations + */ + private ParameterAnnotationEntry[] parameterAnnotationTable; + + /** + * @param parameterAnnotationType the subclass type of the parameter annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + */ + ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + this(parameterAnnotationType, nameIndex, length, (ParameterAnnotationEntry[]) null, constantPool); + final int numParameters = input.readUnsignedByte(); + parameterAnnotationTable = new ParameterAnnotationEntry[numParameters]; + for (int i = 0; i < numParameters; i++) { + parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constantPool); + } + } + + /** + * @param parameterAnnotationType the subclass type of the parameter annotation + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param parameterAnnotationTable the actual parameter annotations + * @param constantPool Array of constants + */ + public ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, + final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) { + super(parameterAnnotationType, nameIndex, length, constantPool); + this.parameterAnnotationTable = parameterAnnotationTable; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitParameterAnnotation(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + dos.writeByte(parameterAnnotationTable.length); + + for (final ParameterAnnotationEntry element : parameterAnnotationTable) { + element.dump(dos); + } + + } + + /** + * returns the array of parameter annotation entries in this parameter annotation + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + return parameterAnnotationTable; + } + + /** + * @return the parameter annotation entry table + */ + public final ParameterAnnotationEntry[] getParameterAnnotationTable() { + return parameterAnnotationTable; + } + + @Override + public Iterator iterator() { + return Stream.of(parameterAnnotationTable).iterator(); + } + + /** + * @param parameterAnnotationTable the entries to set in this parameter annotation + */ + public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable) { + this.parameterAnnotationTable = parameterAnnotationTable; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java new file mode 100644 index 0000000..2c67095 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * represents an annotation that is represented in the class file but is not provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeInvisibleAnnotations extends Annotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeInvisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, false); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java new file mode 100644 index 0000000..e8cddfd --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents a parameter annotation that is represented in the class file but is not provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeInvisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + super(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java new file mode 100644 index 0000000..2965df5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * represents an annotation that is represented in the class file and is provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeVisibleAnnotations extends Annotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeVisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + super(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, true); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java new file mode 100644 index 0000000..f3fbf42 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Represents a parameter annotation that is represented in the class file and is provided to the JVM. + * + * @since 6.0 + */ +public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param nameIndex Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public RuntimeVisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) + throws IOException { + super(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java new file mode 100644 index 0000000..f0b7929 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Signature.java @@ -0,0 +1,258 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.ByteArrayInputStream; +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents a reference to a GJ attribute. + * + * @see Attribute + */ +public final class Signature extends Attribute { + + /** + * Extends ByteArrayInputStream to make 'unreading' chars possible. + */ + private static final class MyByteArrayInputStream extends ByteArrayInputStream { + + MyByteArrayInputStream(final String data) { + super(data.getBytes(StandardCharsets.UTF_8)); + } + + String getData() { + return new String(buf, StandardCharsets.UTF_8); + } + + void unread() { + if (pos > 0) { + pos--; + } + } + } + + private static boolean identStart(final int ch) { + return ch == 'T' || ch == 'L'; + } + + // @since 6.0 is no longer final + public static boolean isActualParameterList(final String s) { + return s.startsWith("L") && s.endsWith(">;"); + } + + // @since 6.0 is no longer final + public static boolean isFormalParameterList(final String s) { + return s.startsWith("<") && s.indexOf(':') > 0; + } + + private static void matchGJIdent(final MyByteArrayInputStream in, final StringBuilder buf) { + int ch; + matchIdent(in, buf); + ch = in.read(); + if (ch == '<' || ch == '(') { // Parameterized or method + // System.out.println("Enter <"); + buf.append((char) ch); + matchGJIdent(in, buf); + while ((ch = in.read()) != '>' && ch != ')') { // List of parameters + if (ch == -1) { + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " reaching EOF"); + } + // System.out.println("Still no >"); + buf.append(", "); + in.unread(); + matchGJIdent(in, buf); // Recursive call + } + // System.out.println("Exit >"); + buf.append((char) ch); + } else { + in.unread(); + } + ch = in.read(); + if (identStart(ch)) { + in.unread(); + matchGJIdent(in, buf); + } else if (ch == ')') { + in.unread(); + } else if (ch != ';') { + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " read " + (char) ch); + } + } + + private static void matchIdent(final MyByteArrayInputStream in, final StringBuilder buf) { + int ch; + if ((ch = in.read()) == -1) { + throw new IllegalArgumentException("Illegal signature: " + in.getData() + " no ident, reaching EOF"); + } + // System.out.println("return from ident:" + (char)ch); + if (!identStart(ch)) { + final StringBuilder buf2 = new StringBuilder(); + int count = 1; + while (Character.isJavaIdentifierPart((char) ch)) { + buf2.append((char) ch); + count++; + ch = in.read(); + } + if (ch == ':') { // Ok, formal parameter + final int skipExpected = "Ljava/lang/Object".length(); + final long skipActual = in.skip(skipExpected); + if (skipActual != skipExpected) { + throw new IllegalStateException(String.format("Unexpected skip: expected=%,d, actual=%,d", skipExpected, skipActual)); + } + buf.append(buf2); + ch = in.read(); + in.unread(); + // System.out.println("so far:" + buf2 + ":next:" +(char)ch); + } else { + for (int i = 0; i < count; i++) { + in.unread(); + } + } + return; + } + final StringBuilder buf2 = new StringBuilder(); + ch = in.read(); + do { + buf2.append((char) ch); + ch = in.read(); + // System.out.println("within ident:"+ (char)ch); + } while (ch != -1 && (Character.isJavaIdentifierPart((char) ch) || ch == '/')); + buf.append(Utility.pathToPackage(buf2.toString())); + // System.out.println("regular return ident:"+ (char)ch + ":" + buf2); + if (ch != -1) { + in.unread(); + } + } + + public static String translate(final String s) { + // System.out.println("Sig:" + s); + final StringBuilder buf = new StringBuilder(); + matchGJIdent(new MyByteArrayInputStream(s), buf); + return buf.toString(); + } + + private int signatureIndex; + + /** + * Construct object from file stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Signature(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param signatureIndex Index in constant pool to CONSTANT_Utf8 + * @param constantPool Array of constants + */ + public Signature(final int nameIndex, final int length, final int signatureIndex, final ConstantPool constantPool) { + super(Const.ATTR_SIGNATURE, nameIndex, Args.require(length, 2, "Signature length attribute"), constantPool); + this.signatureIndex = signatureIndex; + // validate: + Objects.requireNonNull(constantPool.getConstantUtf8(signatureIndex), "constantPool.getConstantUtf8(signatureIndex)"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public Signature(final Signature c) { + this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + // System.err.println("Visiting non-standard Signature object"); + v.visitSignature(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(signatureIndex); + } + + /** + * @return GJ signature. + */ + public String getSignature() { + return super.getConstantPool().getConstantUtf8(signatureIndex).getBytes(); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getSignatureIndex() { + return signatureIndex; + } + + /** + * @param signatureIndex the index info the constant pool of this signature + */ + public void setSignatureIndex(final int signatureIndex) { + this.signatureIndex = signatureIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "Signature: " + getSignature(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java new file mode 100644 index 0000000..ae94f3f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java @@ -0,0 +1,183 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * @since 6.0 + */ +public class SimpleElementValue extends ElementValue { + private int index; + + public SimpleElementValue(final int type, final int index, final ConstantPool cpool) { + super(type, cpool); + this.index = index; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + final int type = super.getType(); + dos.writeByte(type); // u1 kind of value + switch (type) { + case PRIMITIVE_INT: + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_FLOAT: + case PRIMITIVE_LONG: + case PRIMITIVE_BOOLEAN: + case PRIMITIVE_SHORT: + case PRIMITIVE_DOUBLE: + case STRING: + dos.writeShort(getIndex()); + break; + default: + throw new ClassFormatException("SimpleElementValue doesnt know how to write out type " + type); + } + } + + /** + * @return Value entry index in the cpool + */ + public int getIndex() { + return index; + } + + public boolean getValueBoolean() { + if (super.getType() != PRIMITIVE_BOOLEAN) { + throw new IllegalStateException("Dont call getValueBoolean() on a non BOOLEAN ElementValue"); + } + final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return bo.getBytes() != 0; + } + + public byte getValueByte() { + if (super.getType() != PRIMITIVE_BYTE) { + throw new IllegalStateException("Dont call getValueByte() on a non BYTE ElementValue"); + } + return (byte) super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public char getValueChar() { + if (super.getType() != PRIMITIVE_CHAR) { + throw new IllegalStateException("Dont call getValueChar() on a non CHAR ElementValue"); + } + return (char) super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public double getValueDouble() { + if (super.getType() != PRIMITIVE_DOUBLE) { + throw new IllegalStateException("Dont call getValueDouble() on a non DOUBLE ElementValue"); + } + final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex()); + return d.getBytes(); + } + + public float getValueFloat() { + if (super.getType() != PRIMITIVE_FLOAT) { + throw new IllegalStateException("Dont call getValueFloat() on a non FLOAT ElementValue"); + } + final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex()); + return f.getBytes(); + } + + public int getValueInt() { + if (super.getType() != PRIMITIVE_INT) { + throw new IllegalStateException("Dont call getValueInt() on a non INT ElementValue"); + } + return super.getConstantPool().getConstantInteger(getIndex()).getBytes(); + } + + public long getValueLong() { + if (super.getType() != PRIMITIVE_LONG) { + throw new IllegalStateException("Dont call getValueLong() on a non LONG ElementValue"); + } + final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex()); + return j.getBytes(); + } + + public short getValueShort() { + if (super.getType() != PRIMITIVE_SHORT) { + throw new IllegalStateException("Dont call getValueShort() on a non SHORT ElementValue"); + } + final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return (short) s.getBytes(); + } + + public String getValueString() { + if (super.getType() != STRING) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + return super.getConstantPool().getConstantUtf8(getIndex()).getBytes(); + } + + public void setIndex(final int index) { + this.index = index; + } + + // Whatever kind of value it is, return it as a string + @Override + public String stringifyValue() { + final ConstantPool cpool = super.getConstantPool(); + final int type = super.getType(); + switch (type) { + case PRIMITIVE_INT: + return Integer.toString(cpool.getConstantInteger(getIndex()).getBytes()); + case PRIMITIVE_LONG: + final ConstantLong j = cpool.getConstant(getIndex(), Const.CONSTANT_Long, ConstantLong.class); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + final ConstantDouble d = cpool.getConstant(getIndex(), Const.CONSTANT_Double, ConstantDouble.class); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + final ConstantFloat f = cpool.getConstant(getIndex(), Const.CONSTANT_Float, ConstantFloat.class); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + final ConstantInteger s = cpool.getConstantInteger(getIndex()); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + final ConstantInteger b = cpool.getConstantInteger(getIndex()); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + final ConstantInteger ch = cpool.getConstantInteger(getIndex()); + return String.valueOf((char) ch.getBytes()); + case PRIMITIVE_BOOLEAN: + final ConstantInteger bo = cpool.getConstantInteger(getIndex()); + if (bo.getBytes() == 0) { + return "false"; + } + return "true"; + case STRING: + return cpool.getConstantUtf8(getIndex()).getBytes(); + default: + throw new IllegalStateException("SimpleElementValue class does not know how to stringify type " + type); + } + } + + @Override + public String toString() { + return stringifyValue(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java new file mode 100644 index 0000000..dad8236 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/SourceFile.java @@ -0,0 +1,138 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and represents a reference to the source file of this class. At most + * one SourceFile attribute should appear per classfile. The intention of this class is that it is instantiated from the + * Attribute.readAttribute() method. + * + * @see Attribute + */ +public final class SourceFile extends Attribute { + + private int sourceFileIndex; + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + SourceFile(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, input.readUnsignedShort(), constantPool); + } + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8, which should represent the string "SourceFile". + * @param length Content length in bytes, the value should be 2. + * @param constantPool The constant pool that this attribute is associated with. + * @param sourceFileIndex Index in constant pool to CONSTANT_Utf8. This string will be interpreted as the name of the + * file from which this class was compiled. It will not be interpreted as indicating the name of the directory + * contqining the file or an absolute path; this information has to be supplied the consumer of this attribute - + * in many cases, the JVM. + */ + public SourceFile(final int nameIndex, final int length, final int sourceFileIndex, final ConstantPool constantPool) { + super(Const.ATTR_SOURCE_FILE, nameIndex, Args.require(length, 2, "SourceFile length attribute"), constantPool); + this.sourceFileIndex = Args.requireU2(sourceFileIndex, 0, constantPool.getLength(), "SourceFile source file index"); + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a + * physical copy. + * + * @param c Source to copy. + */ + public SourceFile(final SourceFile c) { + this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitSourceFile(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + return (Attribute) clone(); + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(sourceFileIndex); + } + + /** + * @return Index in constant pool of source file name. + */ + public int getSourceFileIndex() { + return sourceFileIndex; + } + + /** + * @return Source file name. + */ + public String getSourceFileName() { + return super.getConstantPool().getConstantUtf8(sourceFileIndex).getBytes(); + } + + /** + * @param sourceFileIndex + */ + public void setSourceFileIndex(final int sourceFileIndex) { + this.sourceFileIndex = sourceFileIndex; + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "SourceFile: " + getSourceFileName(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java new file mode 100644 index 0000000..fdb828d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMap.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class represents a stack map attribute used for preverification of Java classes for the + * Java 2 Micro Edition (J2ME). This attribute is used by the + * KVM and contained within the Code attribute of a method. See CLDC + * specification 5.3.1.2 + * + *
+ * StackMapTable_attribute {
+ *   u2              attribute_name_index;
+ *   u4              attribute_length;
+ *   u2              number_of_entries;
+ *   stack_map_frame entries[number_of_entries];
+ * }
+ * 
+ * + * @LastModified: Oct 2020 + * @see Code + * @see StackMapEntry + * @see StackMapType + */ +public final class StackMap extends Attribute { + + private StackMapEntry[] table; // Table of stack map entries + + /** + * Construct object from input stream. + * + * @param nameIndex Index of name + * @param length Content length in bytes + * @param dataInput Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + StackMap(final int nameIndex, final int length, final DataInput dataInput, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (StackMapEntry[]) null, constantPool); + final int mapLength = dataInput.readUnsignedShort(); + table = new StackMapEntry[mapLength]; + for (int i = 0; i < mapLength; i++) { + table[i] = new StackMapEntry(dataInput, constantPool); + } + } + + /* + * @param nameIndex Index of name + * + * @param length Content length in bytes + * + * @param map Table of stack map entries + * + * @param constantPool Array of constants + */ + public StackMap(final int nameIndex, final int length, final StackMapEntry[] table, final ConstantPool constantPool) { + super(Const.ATTR_STACK_MAP, nameIndex, length, constantPool); + this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY; + Args.requireU2(this.table.length, "table.length"); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackMap(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final StackMap c = (StackMap) clone(); + c.table = new StackMapEntry[table.length]; + Arrays.setAll(c.table, i -> table[i].copy()); + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump stack map table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(table.length); + for (final StackMapEntry entry : table) { + entry.dump(file); + } + } + + public int getMapLength() { + return table.length; + } + + /** + * @return Array of stack map entries + */ + public StackMapEntry[] getStackMap() { + return table; + } + + /** + * @param table Array of stack map entries + */ + public void setStackMap(final StackMapEntry[] table) { + this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY; + int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps + for (final StackMapEntry element : this.table) { + len += element.getMapEntrySize(); + } + setLength(len); + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder("StackMap("); + int runningOffset = -1; // no +1 on first entry + for (int i = 0; i < table.length; i++) { + runningOffset = table[i].getByteCodeOffset() + runningOffset + 1; + buf.append(String.format("%n@%03d %s", runningOffset, table[i])); + if (i < table.length - 1) { + buf.append(", "); + } + } + buf.append(')'); + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java new file mode 100644 index 0000000..207e609 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java @@ -0,0 +1,417 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a stack map entry recording the types of local variables and the of stack items at a given + * byte code offset. See CLDC specification 5.3.1.2. + *

+ * See also https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4 + * + *

+ * union stack_map_frame {
+ *   same_frame;
+ *   same_locals_1_stack_item_frame;
+ *   same_locals_1_stack_item_frame_extended;
+ *   chop_frame;
+ *   same_frame_extended;
+ *   append_frame;
+ *   full_frame;
+ * }
+ * 
+ * + * @see StackMap + * @see StackMapType + */ +public final class StackMapEntry implements Node, Cloneable { + + static final StackMapEntry[] EMPTY_ARRAY = {}; + + private int frameType; + private int byteCodeOffset; + private StackMapType[] typesOfLocals; + private StackMapType[] typesOfStackItems; + private ConstantPool constantPool; + + /** + * Construct object from input stream. + * + * @param dataInput Input stream + * @throws IOException if an I/O error occurs. + */ + StackMapEntry(final DataInput dataInput, final ConstantPool constantPool) throws IOException { + this(dataInput.readByte() & 0xFF, -1, null, null, constantPool); + + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_FRAME; + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byteCodeOffset = frameType - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + typesOfStackItems = new StackMapType[]{new StackMapType(dataInput, constantPool)}; + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + byteCodeOffset = dataInput.readUnsignedShort(); + typesOfStackItems = new StackMapType[]{new StackMapType(dataInput, constantPool)}; + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + byteCodeOffset = dataInput.readUnsignedShort(); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + byteCodeOffset = dataInput.readUnsignedShort(); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + byteCodeOffset = dataInput.readUnsignedShort(); + final int numberOfLocals = frameType - 251; + typesOfLocals = new StackMapType[numberOfLocals]; + for (int i = 0; i < numberOfLocals; i++) { + typesOfLocals[i] = new StackMapType(dataInput, constantPool); + } + } else if (frameType == Const.FULL_FRAME) { + byteCodeOffset = dataInput.readUnsignedShort(); + final int numberOfLocals = dataInput.readUnsignedShort(); + typesOfLocals = new StackMapType[numberOfLocals]; + for (int i = 0; i < numberOfLocals; i++) { + typesOfLocals[i] = new StackMapType(dataInput, constantPool); + } + final int numberOfStackItems = dataInput.readUnsignedShort(); + typesOfStackItems = new StackMapType[numberOfStackItems]; + for (int i = 0; i < numberOfStackItems; i++) { + typesOfStackItems[i] = new StackMapType(dataInput, constantPool); + } + } else { + /* Can't happen */ + throw new ClassFormatException("Invalid frame type found while parsing stack map table: " + frameType); + } + } + + /** + * DO NOT USE + * + * @param byteCodeOffset + * @param numberOfLocals NOT USED + * @param typesOfLocals array of {@link StackMapType}s of locals + * @param numberOfStackItems NOT USED + * @param typesOfStackItems array ot {@link StackMapType}s of stack items + * @param constantPool the constant pool + * @deprecated Since 6.0, use {@link #StackMapEntry(int, int, StackMapType[], StackMapType[], ConstantPool)} instead + */ + @java.lang.Deprecated + public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, final StackMapType[] typesOfLocals, final int numberOfStackItems, + final StackMapType[] typesOfStackItems, final ConstantPool constantPool) { + this.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY; + this.constantPool = constantPool; + if (numberOfLocals < 0) { + throw new IllegalArgumentException("numberOfLocals < 0"); + } + if (numberOfStackItems < 0) { + throw new IllegalArgumentException("numberOfStackItems < 0"); + } + } + + /** + * Create an instance + * + * @param tag the frameType to use + * @param byteCodeOffset + * @param typesOfLocals array of {@link StackMapType}s of locals + * @param typesOfStackItems array ot {@link StackMapType}s of stack items + * @param constantPool the constant pool + */ + public StackMapEntry(final int tag, final int byteCodeOffset, final StackMapType[] typesOfLocals, final StackMapType[] typesOfStackItems, + final ConstantPool constantPool) { + this.frameType = tag; + this.byteCodeOffset = byteCodeOffset; + this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY; + this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY; + this.constantPool = constantPool; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackMapEntry(this); + } + + /** + * @return deep copy of this object + */ + public StackMapEntry copy() { + StackMapEntry e; + try { + e = (StackMapEntry) clone(); + } catch (final CloneNotSupportedException ex) { + throw new Error("Clone Not Supported"); + } + + e.typesOfLocals = new StackMapType[typesOfLocals.length]; + Arrays.setAll(e.typesOfLocals, i -> typesOfLocals[i].copy()); + e.typesOfStackItems = new StackMapType[typesOfStackItems.length]; + Arrays.setAll(e.typesOfStackItems, i -> typesOfStackItems[i].copy()); + return e; + } + + /** + * Dump stack map entry + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.write(frameType); + if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + typesOfStackItems[0].dump(file); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + typesOfStackItems[0].dump(file); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + file.writeShort(byteCodeOffset); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + file.writeShort(byteCodeOffset); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + file.writeShort(byteCodeOffset); + for (final StackMapType type : typesOfLocals) { + type.dump(file); + } + } else if (frameType == Const.FULL_FRAME) { + file.writeShort(byteCodeOffset); + file.writeShort(typesOfLocals.length); + for (final StackMapType type : typesOfLocals) { + type.dump(file); + } + file.writeShort(typesOfStackItems.length); + for (final StackMapType type : typesOfStackItems) { + type.dump(file); + } + } else if (!(frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX)) { + /* Can't happen */ + throw new ClassFormatException("Invalid Stack map table tag: " + frameType); + } + } + + public int getByteCodeOffset() { + return byteCodeOffset; + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + public int getFrameType() { + return frameType; + } + + /** + * Calculate stack map entry size + */ + int getMapEntrySize() { + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + return 1; + } + if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + return 1 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } + if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + return 3 + (typesOfStackItems[0].hasIndex() ? 3 : 1); + } + if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX || frameType == Const.SAME_FRAME_EXTENDED) { + return 3; + } + if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + int len = 3; + for (final StackMapType typesOfLocal : typesOfLocals) { + len += typesOfLocal.hasIndex() ? 3 : 1; + } + return len; + } + if (frameType != Const.FULL_FRAME) { + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); + } + int len = 7; + for (final StackMapType typesOfLocal : typesOfLocals) { + len += typesOfLocal.hasIndex() ? 3 : 1; + } + for (final StackMapType typesOfStackItem : typesOfStackItems) { + len += typesOfStackItem.hasIndex() ? 3 : 1; + } + return len; + } + + public int getNumberOfLocals() { + return typesOfLocals.length; + } + + public int getNumberOfStackItems() { + return typesOfStackItems.length; + } + + public StackMapType[] getTypesOfLocals() { + return typesOfLocals; + } + + public StackMapType[] getTypesOfStackItems() { + return typesOfStackItems; + } + + private boolean invalidFrameType(final int f) { + // @formatter:off + return f != Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED + && !(f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX) + && f != Const.SAME_FRAME_EXTENDED + && !(f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX) + && f != Const.FULL_FRAME; + // @formatter:on + } + + public void setByteCodeOffset(final int newOffset) { + if (newOffset < 0 || newOffset > 32767) { + throw new IllegalArgumentException("Invalid StackMap offset: " + newOffset); + } + + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + if (newOffset > Const.SAME_FRAME_MAX) { + frameType = Const.SAME_FRAME_EXTENDED; + } else { + frameType = newOffset; + } + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + if (newOffset > Const.SAME_FRAME_MAX) { + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; + } else { + frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + newOffset; + } + } else if (invalidFrameType(frameType)) { + throw new IllegalStateException("Invalid StackMap frameType: " + frameType); + } + byteCodeOffset = newOffset; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + public void setFrameType(final int ft) { + if (ft >= Const.SAME_FRAME && ft <= Const.SAME_FRAME_MAX) { + byteCodeOffset = ft - Const.SAME_FRAME; + } else if (ft >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && ft <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byteCodeOffset = ft - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + } else if (invalidFrameType(ft)) { + throw new IllegalArgumentException("Invalid StackMap frameType"); + } + frameType = ft; + } + + /** + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfLocals(final int n) { // TODO unused + } + + /** + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfStackItems(final int n) { // TODO unused + } + + public void setTypesOfLocals(final StackMapType[] types) { + typesOfLocals = types != null ? types : StackMapType.EMPTY_ARRAY; + } + + public void setTypesOfStackItems(final StackMapType[] types) { + typesOfStackItems = types != null ? types : StackMapType.EMPTY_ARRAY; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(64); + buf.append("("); + if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) { + buf.append("SAME"); + } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + buf.append("SAME_LOCALS_1_STACK"); + } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + buf.append("SAME_LOCALS_1_STACK_EXTENDED"); + } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) { + buf.append("CHOP ").append(String.valueOf(251 - frameType)); + } else if (frameType == Const.SAME_FRAME_EXTENDED) { + buf.append("SAME_EXTENDED"); + } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) { + buf.append("APPEND ").append(String.valueOf(frameType - 251)); + } else if (frameType == Const.FULL_FRAME) { + buf.append("FULL"); + } else { + buf.append("UNKNOWN (").append(frameType).append(")"); + } + buf.append(", offset delta=").append(byteCodeOffset); + if (typesOfLocals.length > 0) { + buf.append(", locals={"); + for (int i = 0; i < typesOfLocals.length; i++) { + buf.append(typesOfLocals[i]); + if (i < typesOfLocals.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + if (typesOfStackItems.length > 0) { + buf.append(", stack items={"); + for (int i = 0; i < typesOfStackItems.length; i++) { + buf.append(typesOfStackItems[i]); + if (i < typesOfStackItems.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + buf.append(")"); + return buf.toString(); + } + + /** + * Update the distance (as an offset delta) from this StackMap entry to the next. Note that this might cause the + * frame type to change. Note also that delta may be negative. + * + * @param delta offset delta + */ + public void updateByteCodeOffset(final int delta) { + setByteCodeOffset(byteCodeOffset + delta); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java new file mode 100644 index 0000000..1b97e2f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/StackMapType.java @@ -0,0 +1,162 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents the type of a local variable or item on stack used in the StackMap entries. + * + * @see StackMapEntry + * @see StackMap + * @see Const + */ +public final class StackMapType implements Cloneable { + + public static final StackMapType[] EMPTY_ARRAY = {}; // must be public because BCELifier code generator writes calls to it + + private byte type; + private int index = -1; // Index to CONSTANT_Class or offset + private ConstantPool constantPool; + + /** + * @param type type tag as defined in the Constants interface + * @param index index to constant pool, or byte code offset + */ + public StackMapType(final byte type, final int index, final ConstantPool constantPool) { + this.type = checkType(type); + this.index = index; + this.constantPool = constantPool; + } + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOException if an I/O error occurs. + */ + StackMapType(final DataInput file, final ConstantPool constantPool) throws IOException { + this(file.readByte(), -1, constantPool); + if (hasIndex()) { + this.index = file.readUnsignedShort(); + } + this.constantPool = constantPool; + } + + private byte checkType(final byte type) { + if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) { + throw new ClassFormatException("Illegal type for StackMapType: " + type); + } + return type; + } + + /** + * @return deep copy of this object + */ + public StackMapType copy() { + try { + return (StackMapType) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + /** + * Dump type entries to file. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + public void dump(final DataOutputStream file) throws IOException { + file.writeByte(type); + if (hasIndex()) { + file.writeShort(getIndex()); + } + } + + /** + * @return Constant pool used by this object. + */ + public ConstantPool getConstantPool() { + return constantPool; + } + + /** + * @return index to constant pool if type == ITEM_Object, or offset in byte code, if type == ITEM_NewObject, and -1 + * otherwise + */ + public int getIndex() { + return index; + } + + public byte getType() { + return type; + } + + /** + * @return true, if type is either ITEM_Object or ITEM_NewObject + */ + public boolean hasIndex() { + return type == Const.ITEM_Object || type == Const.ITEM_NewObject; + } + + private String printIndex() { + if (type == Const.ITEM_Object) { + if (index < 0) { + return ", class="; + } + return ", class=" + constantPool.constantToString(index, Const.CONSTANT_Class); + } + if (type == Const.ITEM_NewObject) { + return ", offset=" + index; + } + return ""; + } + + /** + * @param constantPool Constant pool to be used for this object. + */ + public void setConstantPool(final ConstantPool constantPool) { + this.constantPool = constantPool; + } + + public void setIndex(final int index) { + this.index = index; + } + + public void setType(final byte type) { + this.type = checkType(type); + } + + /** + * @return String representation + */ + @Override + public String toString() { + return "(type=" + Const.getItemName(type) + printIndex() + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java new file mode 100644 index 0000000..6a05f34 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Synthetic.java @@ -0,0 +1,145 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.Args; + +/** + * This class is derived from Attribute and declares this class as 'synthetic', i.e., it needs special + * handling. The JVM specification states "A class member that does not appear in the source code must be marked using a + * Synthetic attribute." It may appear in the ClassFile attribute table, a field_info table or a method_info table. This + * class is intended to be instantiated from the Attribute.readAttribute() method. + * + * @see Attribute + */ +public final class Synthetic extends Attribute { + + private byte[] bytes; + + /** + * @param nameIndex Index in constant pool to CONSTANT_Utf8, which should represent the string "Synthetic". + * @param length Content length in bytes - should be zero. + * @param bytes Attribute contents + * @param constantPool The constant pool this attribute is associated with. + */ + public Synthetic(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_SYNTHETIC, nameIndex, Args.require0(length, "Synthetic attribute length"), constantPool); + this.bytes = bytes; + } + + /** + * Construct object from input stream. + * + * @param nameIndex Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Synthetic(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + println("Synthetic attribute with length > 0"); + } + } + + /** + * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a + * physical copy. + * + * @param c Source to copy. + */ + public Synthetic(final Synthetic c) { + this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitSynthetic(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Synthetic c = (Synthetic) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @param bytes + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder("Synthetic"); + if (super.getLength() > 0) { + buf.append(" ").append(Utility.toHexString(bytes)); + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java new file mode 100644 index 0000000..a46d504 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Unknown.java @@ -0,0 +1,164 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * This class represents a reference to an unknown (i.e., application-specific) attribute of a class. It is instantiated + * from the {@link Attribute#readAttribute(java.io.DataInput, ConstantPool)} method. Applications that need to read in + * application-specific attributes should create an {@link UnknownAttributeReader} implementation and attach it via + * {@link Attribute#addAttributeReader(String, UnknownAttributeReader)}. + * + * @see Attribute + * @see UnknownAttributeReader + */ +public final class Unknown extends Attribute { + + private byte[] bytes; + + private final String name; + + /** + * Constructs a new instance for a non-standard attribute. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param bytes Attribute contents + * @param constantPool Array of constants + */ + public Unknown(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) { + super(Const.ATTR_UNKNOWN, nameIndex, length, constantPool); + this.bytes = bytes; + this.name = constantPool.getConstantUtf8(nameIndex).getBytes(); + } + + /** + * Constructs a new instance from an input stream. + * + * @param nameIndex Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constantPool Array of constants + * @throws IOException if an I/O error occurs. + */ + Unknown(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException { + this(nameIndex, length, (byte[]) null, constantPool); + if (length > 0) { + bytes = new byte[length]; + input.readFully(bytes); + } + } + + /** + * Constructs a new instance from another instance. Note that both objects use the same references (shallow copy). Use clone() for a physical copy. + * + * @param unknown Source. + */ + public Unknown(final Unknown unknown) { + this(unknown.getNameIndex(), unknown.getLength(), unknown.getBytes(), unknown.getConstantPool()); + } + + /** + * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. + * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitUnknown(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constantPool) { + final Unknown c = (Unknown) clone(); + if (bytes != null) { + c.bytes = bytes.clone(); + } + c.setConstantPool(constantPool); + return c; + } + + /** + * Dumps unknown bytes to file stream. + * + * @param file Output file stream + * @throws IOException if an I/O error occurs. + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + /** + * @return data bytes. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * @return name of attribute. + */ + @Override + public String getName() { + return name; + } + + /** + * @param bytes the bytes to set + */ + public void setBytes(final byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + if (super.getLength() == 0 || bytes == null) { + return "(Unknown attribute " + name + ")"; + } + String hex; + final int limit = 10; + if (super.getLength() > limit) { + final byte[] tmp = Arrays.copyOf(bytes, limit); + hex = Utility.toHexString(tmp) + "... (truncated)"; + } else { + hex = Utility.toHexString(bytes); + } + return "(Unknown attribute " + name + ": " + hex + ")"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java new file mode 100644 index 0000000..18360d6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the + * Attribute.addAttributeReader method. These factory objects should implement this interface. + * + * @see Attribute + * @since 6.0 + */ +public interface UnknownAttributeReader { + + /** + * When this attribute reader is added via the static method Attribute.addAttributeReader, an attribute name is + * associated with it. As the class file parser parses attributes, it will call various AttributeReaders based on the + * name of the attributes it is constructing. + * + * @param nameIndex An index into the constant pool, indexing a ConstantUtf8 that represents the name of the attribute. + * @param length The length of the data contained in the attribute. This is written into the constant pool and should + * agree with what the factory expects the length to be. + * @param file This is the data input that the factory needs to read its data from. + * @param constantPool This is the constant pool associated with the Attribute that we are constructing. + * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of + * errors, a null can be returned which will cause the parsing of the class file to fail. + * @see Attribute#addAttributeReader(String, UnknownAttributeReader) + */ + Attribute createAttribute(int nameIndex, int length, java.io.DataInput file, ConstantPool constantPool); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java new file mode 100644 index 0000000..37ae317 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Utility.java @@ -0,0 +1,1553 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.classfile; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.CharArrayReader; +import java.io.CharArrayWriter; +import java.io.FilterReader; +import java.io.FilterWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Utility functions that do not really belong to any class in particular. + * + * @LastModified: Feb 2023 + */ +// @since 6.0 methods are no longer final +public abstract class Utility { + + /** + * Decode characters into bytes. Used by decode() + */ + private static class JavaReader extends FilterReader { + + public JavaReader(final Reader in) { + super(in); + } + + @Override + public int read() throws IOException { + final int b = in.read(); + if (b != ESCAPE_CHAR) { + return b; + } + final int i = in.read(); + if (i < 0) { + return -1; + } + if (i >= '0' && i <= '9' || i >= 'a' && i <= 'f') { // Normal escape + final int j = in.read(); + if (j < 0) { + return -1; + } + final char[] tmp = {(char) i, (char) j}; + return Integer.parseInt(new String(tmp), 16); + } + return MAP_CHAR[i]; + } + + @Override + public int read(final char[] cbuf, final int off, final int len) throws IOException { + for (int i = 0; i < len; i++) { + cbuf[off + i] = (char) read(); + } + return len; + } + } + + /** + * Encode bytes into valid java identifier characters. Used by + * encode() + */ + private static class JavaWriter extends FilterWriter { + + public JavaWriter(final Writer out) { + super(out); + } + + @Override + public void write(final char[] cbuf, final int off, final int len) throws IOException { + for (int i = 0; i < len; i++) { + write(cbuf[off + i]); + } + } + + @Override + public void write(final int b) throws IOException { + if (isJavaIdentifierPart((char) b) && b != ESCAPE_CHAR) { + out.write(b); + } else { + out.write(ESCAPE_CHAR); // Escape character + // Special escape + if (b >= 0 && b < FREE_CHARS) { + out.write(CHAR_MAP[b]); + } else { // Normal escape + final char[] tmp = Integer.toHexString(b).toCharArray(); + if (tmp.length == 1) { + out.write('0'); + out.write(tmp[0]); + } else { + out.write(tmp[0]); + out.write(tmp[1]); + } + } + } + } + + @Override + public void write(final String str, final int off, final int len) throws IOException { + write(str.toCharArray(), off, len); + } + } + + /* + * How many chars have been consumed during parsing in typeSignatureToString(). Read by methodSignatureToString(). Set + * by side effect, but only internally. + */ + private static final ThreadLocal CONSUMER_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0)); + + /* + * The 'WIDE' instruction is used in the byte code to allow 16-bit wide indices for local variables. This opcode + * precedes an 'ILOAD', e.g.. The opcode immediately following takes an extra byte which is combined with the following + * byte to form a 16-bit value. + */ + private static boolean wide; + + // A-Z, g-z, _, $ + private static final int FREE_CHARS = 48; + + private static final int[] CHAR_MAP = new int[FREE_CHARS]; + + private static final int[] MAP_CHAR = new int[256]; // Reverse map + + private static final char ESCAPE_CHAR = '$'; + + static { + int j = 0; + for (int i = 'A'; i <= 'Z'; i++) { + CHAR_MAP[j] = i; + MAP_CHAR[i] = j; + j++; + } + for (int i = 'g'; i <= 'z'; i++) { + CHAR_MAP[j] = i; + MAP_CHAR[i] = j; + j++; + } + CHAR_MAP[j] = '$'; + MAP_CHAR['$'] = j; + j++; + CHAR_MAP[j] = '_'; + MAP_CHAR['_'] = j; + } + + /** + * Convert bit field of flags into string such as 'static final'. + * + * @param accessFlags Access flags + * @return String representation of flags + */ + public static String accessToString(final int accessFlags) { + return accessToString(accessFlags, false); + } + + /** + * Convert bit field of flags into string such as 'static final'. + *

+ * Special case: Classes compiled with new compilers and with the 'ACC_SUPER' flag would be said to be "synchronized". + * This is because SUN used the same value for the flags 'ACC_SUPER' and 'ACC_SYNCHRONIZED'. + * + * @param accessFlags Access flags + * @param forClass access flags are for class qualifiers ? + * @return String representation of flags + */ + public static String accessToString(final int accessFlags, final boolean forClass) { + final StringBuilder buf = new StringBuilder(); + int p = 0; + for (int i = 0; p < Const.MAX_ACC_FLAG_I; i++) { // Loop through known flags + p = pow2(i); + if ((accessFlags & p) != 0) { + /* + * Special case: Classes compiled with new compilers and with the 'ACC_SUPER' flag would be said to be "synchronized". + * This is because SUN used the same value for the flags 'ACC_SUPER' and 'ACC_SYNCHRONIZED'. + */ + if (forClass && (p == Const.ACC_SUPER || p == Const.ACC_INTERFACE)) { + continue; + } + buf.append(Const.getAccessName(i)).append(" "); + } + } + return buf.toString().trim(); + } + + /** + * Convert (signed) byte to (unsigned) short value, i.e., all negative values become positive. + */ + private static short byteToShort(final byte b) { + return b < 0 ? (short) (256 + b) : (short) b; + } + + /** + * @param accessFlags the class flags + * @return "class" or "interface", depending on the ACC_INTERFACE flag + */ + public static String classOrInterface(final int accessFlags) { + return (accessFlags & Const.ACC_INTERFACE) != 0 ? "interface" : "class"; + } + + /** + * @return 'flag' with bit 'i' set to 0 + */ + public static int clearBit(final int flag, final int i) { + final int bit = pow2(i); + return (flag & bit) == 0 ? flag : flag ^ bit; + } + + public static String codeToString(final byte[] code, final ConstantPool constantPool, final int index, final int length) { + return codeToString(code, constantPool, index, length, true); + } + + /** + * Disassemble a byte array of JVM byte codes starting from code line 'index' and return the disassembled string + * representation. Decode only 'num' opcodes (including their operands), use -1 if you want to decompile everything. + * + * @param code byte code array + * @param constantPool Array of constants + * @param index offset in 'code' array (number of opcodes, not bytes!) + * @param length number of opcodes to decompile, -1 for all + * @param verbose be verbose, e.g. print constant pool index + * @return String representation of byte codes + */ + public static String codeToString(final byte[] code, final ConstantPool constantPool, final int index, final int length, final boolean verbose) { + final StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient // CHECKSTYLE IGNORE MagicNumber + try (ByteSequence stream = new ByteSequence(code)) { + for (int i = 0; i < index; i++) { + codeToString(stream, constantPool, verbose); + } + for (int i = 0; stream.available() > 0; i++) { + if (length < 0 || i < length) { + final String indices = fillup(stream.getIndex() + ":", 6, true, ' '); + buf.append(indices).append(codeToString(stream, constantPool, verbose)).append('\n'); + } + } + } catch (final IOException e) { + throw new ClassFormatException("Byte code error: " + buf.toString(), e); + } + return buf.toString(); + } + + public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool) throws IOException { + return codeToString(bytes, constantPool, true); + } + + /** + * Disassemble a stream of byte codes and return the string representation. + * + * @param bytes stream of bytes + * @param constantPool Array of constants + * @param verbose be verbose, e.g. print constant pool index + * @return String representation of byte code + * @throws IOException if a failure from reading from the bytes argument occurs + */ + @SuppressWarnings("fallthrough") // by design for case Const.INSTANCEOF + public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool, + final boolean verbose) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + int defaultOffset = 0; + int low; + int high; + int npairs; + int index; + int vindex; + int constant; + int[] match; + int[] jumpTable; + int noPadBytes = 0; + int offset; + final StringBuilder buf = new StringBuilder(Const.getOpcodeName(opcode)); + /* + * Special case: Skip (0-3) padding bytes, i.e., the following bytes are 4-byte-aligned + */ + if (opcode == Const.TABLESWITCH || opcode == Const.LOOKUPSWITCH) { + final int remainder = bytes.getIndex() % 4; + noPadBytes = remainder == 0 ? 0 : 4 - remainder; + for (int i = 0; i < noPadBytes; i++) { + byte b; + if ((b = bytes.readByte()) != 0) { + System.err.println("Warning: Padding byte != 0 in " + Const.getOpcodeName(opcode) + ":" + b); + } + } + // Both cases have a field default_offset in common + defaultOffset = bytes.readInt(); + } + switch (opcode) { + /* + * Table switch has variable length arguments. + */ + case Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + buf.append("\tdefault = ").append(defaultOffset).append(", low = ").append(low).append(", high = ").append(high).append("("); + jumpTable = new int[high - low + 1]; + for (int i = 0; i < jumpTable.length; i++) { + jumpTable[i] = offset + bytes.readInt(); + buf.append(jumpTable[i]); + if (i < jumpTable.length - 1) { + buf.append(", "); + } + } + buf.append(")"); + break; + /* + * Lookup switch has variable length arguments. + */ + case Const.LOOKUPSWITCH: { + npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + match = new int[npairs]; + jumpTable = new int[npairs]; + defaultOffset += offset; + buf.append("\tdefault = ").append(defaultOffset).append(", npairs = ").append(npairs).append(" ("); + for (int i = 0; i < npairs; i++) { + match[i] = bytes.readInt(); + jumpTable[i] = offset + bytes.readInt(); + buf.append("(").append(match[i]).append(", ").append(jumpTable[i]).append(")"); + if (i < npairs - 1) { + buf.append(", "); + } + } + buf.append(")"); + } + break; + /* + * Two address bytes + offset from start of byte stream form the jump target + */ + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.JSR: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + buf.append("\t\t#").append(bytes.getIndex() - 1 + bytes.readShort()); + break; + /* + * 32-bit wide jumps + */ + case Const.GOTO_W: + case Const.JSR_W: + buf.append("\t\t#").append(bytes.getIndex() - 1 + bytes.readInt()); + break; + /* + * Index byte references local variable (register) + */ + case Const.ALOAD: + case Const.ASTORE: + case Const.DLOAD: + case Const.DSTORE: + case Const.FLOAD: + case Const.FSTORE: + case Const.ILOAD: + case Const.ISTORE: + case Const.LLOAD: + case Const.LSTORE: + case Const.RET: + if (wide) { + vindex = bytes.readUnsignedShort(); + wide = false; // Clear flag + } else { + vindex = bytes.readUnsignedByte(); + } + buf.append("\t\t%").append(vindex); + break; + /* + * Remember wide byte which is used to form a 16-bit address in the following instruction. Relies on that the method is + * called again with the following opcode. + */ + case Const.WIDE: + wide = true; + buf.append("\t(wide)"); + break; + /* + * Array of basic type. + */ + case Const.NEWARRAY: + buf.append("\t\t<").append(Const.getTypeName(bytes.readByte())).append(">"); + break; + /* + * Access object/class fields. + */ + case Const.GETFIELD: + case Const.GETSTATIC: + case Const.PUTFIELD: + case Const.PUTSTATIC: + index = bytes.readUnsignedShort(); + buf.append("\t\t").append(constantPool.constantToString(index, Const.CONSTANT_Fieldref)).append(verbose ? " (" + index + ")" : ""); + break; + /* + * Operands are references to classes in constant pool + */ + case Const.NEW: + case Const.CHECKCAST: + buf.append("\t"); + //$FALL-THROUGH$ + case Const.INSTANCEOF: + index = bytes.readUnsignedShort(); + buf.append("\t<").append(constantPool.constantToString(index, Const.CONSTANT_Class)).append(">").append(verbose ? " (" + index + ")" : ""); + break; + /* + * Operands are references to methods in constant pool + */ + case Const.INVOKESPECIAL: + case Const.INVOKESTATIC: + index = bytes.readUnsignedShort(); + final Constant c = constantPool.getConstant(index); + // With Java8 operand may be either a CONSTANT_Methodref + // or a CONSTANT_InterfaceMethodref. (markro) + buf.append("\t").append(constantPool.constantToString(index, c.getTag())).append(verbose ? " (" + index + ")" : ""); + break; + case Const.INVOKEVIRTUAL: + index = bytes.readUnsignedShort(); + buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_Methodref)).append(verbose ? " (" + index + ")" : ""); + break; + case Const.INVOKEINTERFACE: + index = bytes.readUnsignedShort(); + final int nargs = bytes.readUnsignedByte(); // historical, redundant + buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_InterfaceMethodref)).append(verbose ? " (" + index + ")\t" : "") + .append(nargs).append("\t").append(bytes.readUnsignedByte()); // Last byte is a reserved space + break; + case Const.INVOKEDYNAMIC: + index = bytes.readUnsignedShort(); + buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_InvokeDynamic)).append(verbose ? " (" + index + ")\t" : "") + .append(bytes.readUnsignedByte()) // Thrid byte is a reserved space + .append(bytes.readUnsignedByte()); // Last byte is a reserved space + break; + /* + * Operands are references to items in constant pool + */ + case Const.LDC_W: + case Const.LDC2_W: + index = bytes.readUnsignedShort(); + buf.append("\t\t").append(constantPool.constantToString(index, constantPool.getConstant(index).getTag())) + .append(verbose ? " (" + index + ")" : ""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("\t\t").append(constantPool.constantToString(index, constantPool.getConstant(index).getTag())) + .append(verbose ? " (" + index + ")" : ""); + break; + /* + * Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readUnsignedShort(); + buf.append("\t\t<").append(compactClassName(constantPool.getConstantString(index, Const.CONSTANT_Class), false)).append(">") + .append(verbose ? " (" + index + ")" : ""); + break; + /* + * Multidimensional array of references. + */ + case Const.MULTIANEWARRAY: { + index = bytes.readUnsignedShort(); + final int dimensions = bytes.readUnsignedByte(); + buf.append("\t<").append(compactClassName(constantPool.getConstantString(index, Const.CONSTANT_Class), false)).append(">\t").append(dimensions) + .append(verbose ? " (" + index + ")" : ""); + } + break; + /* + * Increment local variable. + */ + case Const.IINC: + if (wide) { + vindex = bytes.readUnsignedShort(); + constant = bytes.readShort(); + wide = false; + } else { + vindex = bytes.readUnsignedByte(); + constant = bytes.readByte(); + } + buf.append("\t\t%").append(vindex).append("\t").append(constant); + break; + default: + if (Const.getNoOfOperands(opcode) > 0) { + for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) { + buf.append("\t\t"); + switch (Const.getOperandType(opcode, i)) { + case Const.T_BYTE: + buf.append(bytes.readByte()); + break; + case Const.T_SHORT: + buf.append(bytes.readShort()); + break; + case Const.T_INT: + buf.append(bytes.readInt()); + break; + default: // Never reached + throw new IllegalStateException("Unreachable default case reached!"); + } + } + } + } + return buf.toString(); + } + + /** + * Shorten long class names, java/lang/String becomes String. + * + * @param str The long class name + * @return Compacted class name + */ + public static String compactClassName(final String str) { + return compactClassName(str, true); + } + + /** + * Shorten long class names, java/lang/String becomes java.lang.String, e.g.. If chopit is + * true the prefix java.lang is also removed. + * + * @param str The long class name + * @param chopit flag that determines whether chopping is executed or not + * @return Compacted class name + */ + public static String compactClassName(final String str, final boolean chopit) { + return compactClassName(str, "java.lang.", chopit); + } + + /** + * Shorten long class name str, i.e., chop off the prefix, if the class name starts with this string + * and the flag chopit is true. Slashes / are converted to dots .. + * + * @param str The long class name + * @param prefix The prefix the get rid off + * @param chopit flag that determines whether chopping is executed or not + * @return Compacted class name + */ + public static String compactClassName(String str, final String prefix, final boolean chopit) { + final int len = prefix.length(); + str = pathToPackage(str); // Is '/' on all systems, even DOS + // If string starts with 'prefix' and contains no further dots + if (chopit && str.startsWith(prefix) && str.substring(len).indexOf('.') == -1) { + str = str.substring(len); + } + return str; + } + + /** + * Escape all occurrences of newline chars '\n', quotes \", etc. + */ + public static String convertString(final String label) { + final char[] ch = label.toCharArray(); + final StringBuilder buf = new StringBuilder(); + for (final char element : ch) { + switch (element) { + case '\n': + buf.append("\\n"); + break; + case '\r': + buf.append("\\r"); + break; + case '\"': + buf.append("\\\""); + break; + case '\'': + buf.append("\\'"); + break; + case '\\': + buf.append("\\\\"); + break; + default: + buf.append(element); + break; + } + } + return buf.toString(); + } + + private static int countBrackets(final String brackets) { + final char[] chars = brackets.toCharArray(); + int count = 0; + boolean open = false; + for (final char c : chars) { + switch (c) { + case '[': + if (open) { + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); + } + open = true; + break; + case ']': + if (!open) { + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); + } + open = false; + count++; + break; + default: + // Don't care + break; + } + } + if (open) { + throw new IllegalArgumentException("Illegally nested brackets:" + brackets); + } + return count; + } + + /** + * Decode a string back to a byte array. + * + * @param s the string to convert + * @param uncompress use gzip to uncompress the stream of bytes + * @throws IOException if there's a gzip exception + */ + public static byte[] decode(final String s, final boolean uncompress) throws IOException { + byte[] bytes; + try (JavaReader jr = new JavaReader(new CharArrayReader(s.toCharArray())); ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + int ch; + while ((ch = jr.read()) >= 0) { + bos.write(ch); + } + bytes = bos.toByteArray(); + } + if (uncompress) { + final GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); + final byte[] tmp = new byte[bytes.length * 3]; // Rough estimate + int count = 0; + int b; + while ((b = gis.read()) >= 0) { + tmp[count++] = (byte) b; + } + bytes = Arrays.copyOf(tmp, count); + } + return bytes; + } + + /** + * Encode byte array it into Java identifier string, i.e., a string that only contains the following characters: (a, ... + * z, A, ... Z, 0, ... 9, _, $). The encoding algorithm itself is not too clever: if the current byte's ASCII value + * already is a valid Java identifier part, leave it as it is. Otherwise it writes the escape character($) followed by: + * + *

    + *
  • the ASCII value as a hexadecimal string, if the value is not in the range 200..247
  • + *
  • a Java identifier char not used in a lowercase hexadecimal string, if the value is in the range 200..247
  • + *
+ * + *

+ * This operation inflates the original byte array by roughly 40-50% + *

+ * + * @param bytes the byte array to convert + * @param compress use gzip to minimize string + * @throws IOException if there's a gzip exception + */ + public static String encode(byte[] bytes, final boolean compress) throws IOException { + if (compress) { + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(baos)) { + gos.write(bytes, 0, bytes.length); + gos.finish(); + bytes = baos.toByteArray(); + } + } + final CharArrayWriter caw = new CharArrayWriter(); + try (JavaWriter jw = new JavaWriter(caw)) { + for (final byte b : bytes) { + final int in = b & 0x000000ff; // Normalize to unsigned + jw.write(in); + } + } + return caw.toString(); + } + + /** + * Fillup char with up to length characters with char 'fill' and justify it left or right. + * + * @param str string to format + * @param length length of desired string + * @param leftJustify format left or right + * @param fill fill character + * @return formatted string + */ + public static String fillup(final String str, final int length, final boolean leftJustify, final char fill) { + final int len = length - str.length(); + final char[] buf = new char[Math.max(len, 0)]; + Arrays.fill(buf, fill); + if (leftJustify) { + return str + new String(buf); + } + return new String(buf) + str; + } + + /** + * Return a string for an integer justified left or right and filled up with 'fill' characters if necessary. + * + * @param i integer to format + * @param length length of desired string + * @param leftJustify format left or right + * @param fill fill character + * @return formatted int + */ + public static String format(final int i, final int length, final boolean leftJustify, final char fill) { + return fillup(Integer.toString(i), length, leftJustify, fill); + } + + /** + * WARNING: + * + * There is some nomenclature confusion through much of the BCEL code base with respect to the terms Descriptor and + * Signature. For the offical definitions see: + * + * @see Descriptors in The Java + * Virtual Machine Specification + * + * @see Signatures in The Java + * Virtual Machine Specification + * + * In brief, a descriptor is a string representing the type of a field or method. Signatures are similar, but more + * complex. Signatures are used to encode declarations written in the Java programming language that use types + * outside the type system of the Java Virtual Machine. They are used to describe the type of any class, interface, + * constructor, method or field whose declaration uses type variables or parameterized types. + * + * To parse a descriptor, call typeSignatureToString. To parse a signature, call signatureToString. + * + * Note that if the signature string is a single, non-generic item, the call to signatureToString reduces to a call + * to typeSignatureToString. Also note, that if you only wish to parse the first item in a longer signature string, + * you should call typeSignatureToString directly. + */ + + /** + * Parse Java type such as "char", or "java.lang.String[]" and return the signature in byte code format, e.g. "C" or + * "[Ljava/lang/String;" respectively. + * + * @param type Java type + * @return byte code signature + */ + public static String getSignature(String type) { + final StringBuilder buf = new StringBuilder(); + final char[] chars = type.toCharArray(); + boolean charFound = false; + boolean delim = false; + int index = -1; + loop: + for (int i = 0; i < chars.length; i++) { + switch (chars[i]) { + case ' ': + case '\t': + case '\n': + case '\r': + case '\f': + if (charFound) { + delim = true; + } + break; + case '[': + if (!charFound) { + throw new IllegalArgumentException("Illegal type: " + type); + } + index = i; + break loop; + default: + charFound = true; + if (!delim) { + buf.append(chars[i]); + } + } + } + int brackets = 0; + if (index > 0) { + brackets = countBrackets(type.substring(index)); + } + type = buf.toString(); + buf.setLength(0); + for (int i = 0; i < brackets; i++) { + buf.append('['); + } + boolean found = false; + for (int i = Const.T_BOOLEAN; i <= Const.T_VOID && !found; i++) { + if (Const.getTypeName(i).equals(type)) { + found = true; + buf.append(Const.getShortTypeName(i)); + } + } + if (!found) { + buf.append('L').append(packageToPath(type)).append(';'); + } + return buf.toString(); + } + + /** + * @param ch the character to test if it's part of an identifier + * @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _) + */ + public static boolean isJavaIdentifierPart(final char ch) { + return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '_'; + } + + /** + * @return true, if bit 'i' in 'flag' is set + */ + public static boolean isSet(final int flag, final int i) { + return (flag & pow2(i)) != 0; + } + + /** + * Converts argument list portion of method signature to string with all class names compacted. + * + * @param signature Method signature + * @return String Array of argument types + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String[] methodSignatureArgumentTypes(final String signature) throws ClassFormatException { + return methodSignatureArgumentTypes(signature, true); + } + + /** + * Converts argument list portion of method signature to string. + * + * @param signature Method signature + * @param chopit flag that determines whether chopping is executed or not + * @return String Array of argument types + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String[] methodSignatureArgumentTypes(final String signature, final boolean chopit) throws ClassFormatException { + final List vec = new ArrayList<>(); + int index; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + vec.add(typeSignatureToString(signature.substring(index), chopit)); + // corrected concurrent private static field acess + index += unwrap(CONSUMER_CHARS); // update position + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return vec.toArray(Const.EMPTY_STRING_ARRAY); + } + + /** + * Converts return type portion of method signature to string with all class names compacted. + * + * @param signature Method signature + * @return String representation of method return type + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String methodSignatureReturnType(final String signature) throws ClassFormatException { + return methodSignatureReturnType(signature, true); + } + + /** + * Converts return type portion of method signature to string. + * + * @param signature Method signature + * @param chopit flag that determines whether chopping is executed or not + * @return String representation of method return type + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String methodSignatureReturnType(final String signature, final boolean chopit) throws ClassFormatException { + int index; + String type; + try { + // Read return type after ')' + index = signature.lastIndexOf(')') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + type = typeSignatureToString(signature.substring(index), chopit); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return type; + } + + /** + * Converts method signature to string with all class names compacted. + * + * @param signature to convert + * @param name of method + * @param access flags of method + * @return Human readable signature + */ + public static String methodSignatureToString(final String signature, final String name, final String access) { + return methodSignatureToString(signature, name, access, true); + } + + /** + * Converts method signature to string. + * + * @param signature to convert + * @param name of method + * @param access flags of method + * @param chopit flag that determines whether chopping is executed or not + * @return Human readable signature + */ + public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit) { + return methodSignatureToString(signature, name, access, chopit, null); + } + + /** + * This method converts a method signature string into a Java type declaration like 'void main(String[])' and throws a + * 'ClassFormatException' when the parsed type is invalid. + * + * @param signature Method signature + * @param name Method name + * @param access Method access rights + * @param chopit flag that determines whether chopping is executed or not + * @param vars the LocalVariableTable for the method + * @return Java type declaration + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + */ + public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit, + final LocalVariableTable vars) throws ClassFormatException { + final StringBuilder buf = new StringBuilder("("); + String type; + int index; + int varIndex = access.contains("static") ? 0 : 1; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + final String paramType = typeSignatureToString(signature.substring(index), chopit); + buf.append(paramType); + if (vars != null) { + final LocalVariable l = vars.getLocalVariable(varIndex, 0); + if (l != null) { + buf.append(" ").append(l.getName()); + } + } else { + buf.append(" arg").append(varIndex); + } + if ("double".equals(paramType) || "long".equals(paramType)) { + varIndex += 2; + } else { + varIndex++; + } + buf.append(", "); + // corrected concurrent private static field acess + index += unwrap(CONSUMER_CHARS); // update position + } + index++; // update position + // Read return type after ')' + type = typeSignatureToString(signature.substring(index), chopit); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + // ignore any throws information in the signature + if (buf.length() > 1) { + buf.setLength(buf.length() - 2); + } + buf.append(")"); + return access + (!access.isEmpty() ? " " : "") + // May be an empty string + type + " " + name + buf.toString(); + } + + /** + * Converts string containing the method return and argument types to a byte code method signature. + * + * @param ret Return type of method + * @param argv Types of method arguments + * @return Byte code representation of method signature + * @throws ClassFormatException if the signature is for Void + */ + public static String methodTypeToSignature(final String ret, final String[] argv) throws ClassFormatException { + final StringBuilder buf = new StringBuilder("("); + String str; + if (argv != null) { + for (final String element : argv) { + str = getSignature(element); + if (str.endsWith("V")) { + throw new ClassFormatException("Invalid type: " + element); + } + buf.append(str); + } + } + str = getSignature(ret); + buf.append(")").append(str); + return buf.toString(); + } + + /** + * Converts '.'s to '/'s. + * + * @param name Source + * @return converted value + * @since 6.7.0 + */ + public static String packageToPath(final String name) { + return name.replace('.', '/'); + } + + /** + * Converts a path to a package name. + * + * @param str the source path. + * @return a package name. + * @since 6.6.0 + */ + public static String pathToPackage(final String str) { + return str.replace('/', '.'); + } + + private static int pow2(final int n) { + return 1 << n; + } + + public static String printArray(final Object[] obj) { + return printArray(obj, true); + } + + public static String printArray(final Object[] obj, final boolean braces) { + return printArray(obj, braces, false); + } + + public static String printArray(final Object[] obj, final boolean braces, final boolean quote) { + if (obj == null) { + return null; + } + final StringBuilder buf = new StringBuilder(); + if (braces) { + buf.append('{'); + } + for (int i = 0; i < obj.length; i++) { + if (obj[i] != null) { + buf.append(quote ? "\"" : "").append(obj[i]).append(quote ? "\"" : ""); + } else { + buf.append("null"); + } + if (i < obj.length - 1) { + buf.append(", "); + } + } + if (braces) { + buf.append('}'); + } + return buf.toString(); + } + + public static void printArray(final PrintStream out, final Object[] obj) { + out.println(printArray(obj, true)); + } + + public static void printArray(final PrintWriter out, final Object[] obj) { + out.println(printArray(obj, true)); + } + + /** + * Replace all occurrences of old in str with new. + * + * @param str String to permute + * @param old String to be replaced + * @param new_ Replacement string + * @return new String object + */ + public static String replace(String str, final String old, final String new_) { + int index; + int oldIndex; + try { + if (str.contains(old)) { // 'old' found in str + final StringBuilder buf = new StringBuilder(); + oldIndex = 0; // String start offset + // While we have something to replace + while ((index = str.indexOf(old, oldIndex)) != -1) { + buf.append(str, oldIndex, index); // append prefix + buf.append(new_); // append replacement + oldIndex = index + old.length(); // Skip 'old'.length chars + } + buf.append(str.substring(oldIndex)); // append rest of string + str = buf.toString(); + } + } catch (final StringIndexOutOfBoundsException e) { // Should not occur + System.err.println(e); + } + return str; + } + + /** + * Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload" + */ + public static short searchOpcode(String name) { + name = name.toLowerCase(Locale.ENGLISH); + for (short i = 0; i < Const.OPCODE_NAMES_LENGTH; i++) { + if (Const.getOpcodeName(i).equals(name)) { + return i; + } + } + return -1; + } + + /** + * @return 'flag' with bit 'i' set to 1 + */ + public static int setBit(final int flag, final int i) { + return flag | pow2(i); + } + + /** + * Converts a signature to a string with all class names compacted. Class, Method and Type signatures are supported. + * Enum and Interface signatures are not supported. + * + * @param signature signature to convert + * @return String containg human readable signature + */ + public static String signatureToString(final String signature) { + return signatureToString(signature, true); + } + + /** + * Converts a signature to a string. Class, Method and Type signatures are supported. Enum and Interface signatures are + * not supported. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + public static String signatureToString(final String signature, final boolean chopit) { + String type = ""; + String typeParams = ""; + int index = 0; + if (signature.charAt(0) == '<') { + // we have type paramters + typeParams = typeParamTypesToString(signature, chopit); + index += unwrap(CONSUMER_CHARS); // update position + } + if (signature.charAt(index) == '(') { + // We have a Method signature. + // add types of arguments + type = typeParams + typeSignaturesToString(signature.substring(index), chopit, ')'); + index += unwrap(CONSUMER_CHARS); // update position + // add return type + type = type + typeSignatureToString(signature.substring(index), chopit); + index += unwrap(CONSUMER_CHARS); // update position + // ignore any throws information in the signature + return type; + } + // Could be Class or Type... + type = typeSignatureToString(signature.substring(index), chopit); + index += unwrap(CONSUMER_CHARS); // update position + if (typeParams.isEmpty() && index == signature.length()) { + // We have a Type signature. + return type; + } + // We have a Class signature. + final StringBuilder typeClass = new StringBuilder(typeParams); + typeClass.append(" extends "); + typeClass.append(type); + if (index < signature.length()) { + typeClass.append(" implements "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + while (index < signature.length()) { + typeClass.append(", "); + typeClass.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + return typeClass.toString(); + } + + /** + * Convert bytes into hexadecimal string + * + * @param bytes an array of bytes to convert to hexadecimal + * @return bytes as hexadecimal string, e.g. 00 fa 12 ... + */ + public static String toHexString(final byte[] bytes) { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + final short b = byteToShort(bytes[i]); + final String hex = Integer.toHexString(b); + if (b < 0x10) { + buf.append('0'); + } + buf.append(hex); + if (i < bytes.length - 1) { + buf.append(' '); + } + } + return buf.toString(); + } + + /** + * Return type of method signature as a byte value as defined in Constants + * + * @param signature in format described above + * @return type of method signature + * @throws ClassFormatException if signature is not a method signature + * @see Const + */ + public static byte typeOfMethodSignature(final String signature) throws ClassFormatException { + int index; + try { + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = signature.lastIndexOf(')') + 1; + return typeOfSignature(signature.substring(index)); + } catch (final StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + /** + * Return type of signature as a byte value as defined in Constants + * + * @param signature in format described above + * @return type of signature + * @throws ClassFormatException if signature isn't a known type + * @see Const + */ + public static byte typeOfSignature(final String signature) throws ClassFormatException { + try { + switch (signature.charAt(0)) { + case 'B': + return Const.T_BYTE; + case 'C': + return Const.T_CHAR; + case 'D': + return Const.T_DOUBLE; + case 'F': + return Const.T_FLOAT; + case 'I': + return Const.T_INT; + case 'J': + return Const.T_LONG; + case 'L': + case 'T': + return Const.T_REFERENCE; + case '[': + return Const.T_ARRAY; + case 'V': + return Const.T_VOID; + case 'Z': + return Const.T_BOOLEAN; + case 'S': + return Const.T_SHORT; + case '!': + case '+': + case '*': + return typeOfSignature(signature.substring(1)); + default: + throw new ClassFormatException("Invalid method signature: " + signature); + } + } catch (final StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + /** + * Converts a type parameter list signature to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + private static String typeParamTypesToString(final String signature, final boolean chopit) { + // The first character is guranteed to be '<' + final StringBuilder typeParams = new StringBuilder("<"); + int index = 1; // skip the '<' + // get the first TypeParameter + typeParams.append(typeParamTypeToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + // are there more TypeParameters? + while (signature.charAt(index) != '>') { + typeParams.append(", "); + typeParams.append(typeParamTypeToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index + 1); // account for the '>' char + return typeParams.append(">").toString(); + } + + /** + * Converts a type parameter signature to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @return String containg human readable signature + */ + private static String typeParamTypeToString(final String signature, final boolean chopit) { + int index = signature.indexOf(':'); + if (index <= 0) { + throw new ClassFormatException("Invalid type parameter signature: " + signature); + } + // get the TypeParameter identifier + final StringBuilder typeParam = new StringBuilder(signature.substring(0, index)); + index++; // account for the ':' + if (signature.charAt(index) != ':') { + // we have a class bound + typeParam.append(" extends "); + typeParam.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + // look for interface bounds + while (signature.charAt(index) == ':') { + index++; // skip over the ':' + typeParam.append(" & "); + typeParam.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index); + return typeParam.toString(); + } + + /** + * Converts a list of type signatures to a string. + * + * @param signature signature to convert + * @param chopit flag that determines whether chopping is executed or not + * @param term character indicating the end of the list + * @return String containg human readable signature + */ + private static String typeSignaturesToString(final String signature, final boolean chopit, final char term) { + // The first character will be an 'open' that matches the 'close' contained in term. + final StringBuilder typeList = new StringBuilder(signature.substring(0, 1)); + int index = 1; // skip the 'open' character + // get the first Type in the list + if (signature.charAt(index) != term) { + typeList.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + // are there more types in the list? + while (signature.charAt(index) != term) { + typeList.append(", "); + typeList.append(typeSignatureToString(signature.substring(index), chopit)); + index += unwrap(CONSUMER_CHARS); // update position + } + wrap(CONSUMER_CHARS, index + 1); // account for the term char + return typeList.append(term).toString(); + } + + /** + * This method converts a type signature string into a Java type declaration such as 'String[]' and throws a + * 'ClassFormatException' when the parsed type is invalid. + * + * @param signature type signature + * @param chopit flag that determines whether chopping is executed or not + * @return string containing human readable type signature + * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file + * @since 6.4.0 + */ + public static String typeSignatureToString(final String signature, final boolean chopit) throws ClassFormatException { + // corrected concurrent private static field acess + wrap(CONSUMER_CHARS, 1); // This is the default, read just one char like 'B' + try { + switch (signature.charAt(0)) { + case 'B': + return "byte"; + case 'C': + return "char"; + case 'D': + return "double"; + case 'F': + return "float"; + case 'I': + return "int"; + case 'J': + return "long"; + case 'T': { // TypeVariableSignature + final int index = signature.indexOf(';'); // Look for closing ';' + if (index < 0) { + throw new ClassFormatException("Invalid type variable signature: " + signature); + } + // corrected concurrent private static field acess + wrap(CONSUMER_CHARS, index + 1); // "Tblabla;" 'T' and ';' are removed + return compactClassName(signature.substring(1, index), chopit); + } + case 'L': { // Full class name + // should this be a while loop? can there be more than + // one generic clause? (markro) + int fromIndex = signature.indexOf('<'); // generic type? + if (fromIndex < 0) { + fromIndex = 0; + } else { + fromIndex = signature.indexOf('>', fromIndex); + if (fromIndex < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + } + final int index = signature.indexOf(';', fromIndex); // Look for closing ';' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + + // check to see if there are any TypeArguments + final int bracketIndex = signature.substring(0, index).indexOf('<'); + if (bracketIndex < 0) { + // just a class identifier + wrap(CONSUMER_CHARS, index + 1); // "Lblabla;" 'L' and ';' are removed + return compactClassName(signature.substring(1, index), chopit); + } + // but make sure we are not looking past the end of the current item + fromIndex = signature.indexOf(';'); + if (fromIndex < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + if (fromIndex < bracketIndex) { + // just a class identifier + wrap(CONSUMER_CHARS, fromIndex + 1); // "Lblabla;" 'L' and ';' are removed + return compactClassName(signature.substring(1, fromIndex), chopit); + } + + // we have TypeArguments; build up partial result + // as we recurse for each TypeArgument + final StringBuilder type = new StringBuilder(compactClassName(signature.substring(1, bracketIndex), chopit)).append("<"); + int consumedChars = bracketIndex + 1; // Shadows global var + + // check for wildcards + if (signature.charAt(consumedChars) == '+') { + type.append("? extends "); + consumedChars++; + } else if (signature.charAt(consumedChars) == '-') { + type.append("? super "); + consumedChars++; + } + + // get the first TypeArgument + if (signature.charAt(consumedChars) == '*') { + type.append("?"); + consumedChars++; + } else { + type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); + // update our consumed count by the number of characters the for type argument + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + } + + // are there more TypeArguments? + while (signature.charAt(consumedChars) != '>') { + type.append(", "); + // check for wildcards + if (signature.charAt(consumedChars) == '+') { + type.append("? extends "); + consumedChars++; + } else if (signature.charAt(consumedChars) == '-') { + type.append("? super "); + consumedChars++; + } + if (signature.charAt(consumedChars) == '*') { + type.append("?"); + consumedChars++; + } else { + type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); + // update our consumed count by the number of characters the for type argument + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + } + } + + // process the closing ">" + consumedChars++; + type.append(">"); + + if (signature.charAt(consumedChars) == '.') { + // we have a ClassTypeSignatureSuffix + type.append("."); + // convert SimpleClassTypeSignature to fake ClassTypeSignature + // and then recurse to parse it + type.append(typeSignatureToString("L" + signature.substring(consumedChars + 1), chopit)); + // update our consumed count by the number of characters the for type argument + // note that this count includes the "L" we added, but that is ok + // as it accounts for the "." we didn't consume + consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, consumedChars); + return type.toString(); + } + if (signature.charAt(consumedChars) != ';') { + throw new ClassFormatException("Invalid signature: " + signature); + } + wrap(Utility.CONSUMER_CHARS, consumedChars + 1); // remove final ";" + return type.toString(); + } + case 'S': + return "short"; + case 'Z': + return "boolean"; + case '[': { // Array declaration + int n; + StringBuilder brackets; + String type; + int consumedChars; // Shadows global var + brackets = new StringBuilder(); // Accumulate []'s + // Count opening brackets and look for optional size argument + for (n = 0; signature.charAt(n) == '['; n++) { + brackets.append("[]"); + } + consumedChars = n; // Remember value + // The rest of the string denotes a '' + type = typeSignatureToString(signature.substring(n), chopit); + // corrected concurrent private static field acess + // Utility.consumed_chars += consumed_chars; is replaced by: + final int temp = unwrap(Utility.CONSUMER_CHARS) + consumedChars; + wrap(Utility.CONSUMER_CHARS, temp); + return type + brackets.toString(); + } + case 'V': + return "void"; + default: + throw new ClassFormatException("Invalid signature: '" + signature + "'"); + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid signature: " + signature, e); + } + } + + private static int unwrap(final ThreadLocal tl) { + return tl.get(); + } + + private static void wrap(final ThreadLocal tl, final int value) { + tl.set(value); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java new file mode 100644 index 0000000..74cb840 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/Visitor.java @@ -0,0 +1,236 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.classfile; + +/** + * Interface to make use of the Visitor pattern programming style. I.e. a class that implements this interface can + * traverse the contents of a Java class just by calling the 'accept' method which all classes have. + */ +public interface Visitor { + /** + * @since 6.0 + */ + void visitAnnotation(Annotations obj); + + /** + * @since 6.0 + */ + void visitAnnotationDefault(AnnotationDefault obj); + + /** + * @since 6.0 + */ + void visitAnnotationEntry(AnnotationEntry obj); + + /** + * @since 6.0 + */ + void visitBootstrapMethods(BootstrapMethods obj); + + void visitCode(Code obj); + + void visitCodeException(CodeException obj); + + void visitConstantClass(ConstantClass obj); + + void visitConstantDouble(ConstantDouble obj); + + /** + * @since 6.3 + */ + default void visitConstantDynamic(final ConstantDynamic constantDynamic) { + // empty + } + + void visitConstantFieldref(ConstantFieldref obj); + + void visitConstantFloat(ConstantFloat obj); + + void visitConstantInteger(ConstantInteger obj); + + void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj); + + void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); + + void visitConstantLong(ConstantLong obj); + + /** + * @since 6.0 + */ + void visitConstantMethodHandle(ConstantMethodHandle obj); + + void visitConstantMethodref(ConstantMethodref obj); + + /** + * @since 6.0 + */ + void visitConstantMethodType(ConstantMethodType obj); + + /** + * @since 6.1 + */ + void visitConstantModule(ConstantModule constantModule); + + void visitConstantNameAndType(ConstantNameAndType obj); + + /** + * @since 6.1 + */ + void visitConstantPackage(ConstantPackage constantPackage); + + void visitConstantPool(ConstantPool obj); + + void visitConstantString(ConstantString obj); + + void visitConstantUtf8(ConstantUtf8 obj); + + void visitConstantValue(ConstantValue obj); + + void visitDeprecated(Deprecated obj); + + /** + * @since 6.0 + */ + void visitEnclosingMethod(EnclosingMethod obj); + + void visitExceptionTable(ExceptionTable obj); + + void visitField(Field obj); + + void visitInnerClass(InnerClass obj); + + void visitInnerClasses(InnerClasses obj); + + void visitJavaClass(JavaClass obj); + + void visitLineNumber(LineNumber obj); + + void visitLineNumberTable(LineNumberTable obj); + + void visitLocalVariable(LocalVariable obj); + + void visitLocalVariableTable(LocalVariableTable obj); + + /** + * @since 6.0 + */ + void visitLocalVariableTypeTable(LocalVariableTypeTable obj); + + void visitMethod(Method obj); + + /** + * @since 6.4.0 + */ + default void visitMethodParameter(final MethodParameter obj) { + // empty + } + + /** + * @since 6.0 + */ + void visitMethodParameters(MethodParameters obj); + + /** + * @since 6.4.0 + */ + default void visitModule(final Module constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleExports(final ModuleExports constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleMainClass(final ModuleMainClass obj) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleOpens(final ModuleOpens constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModulePackages(final ModulePackages constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleProvides(final ModuleProvides constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitModuleRequires(final ModuleRequires constantModule) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitNestHost(final NestHost obj) { + // empty + } + + /** + * @since 6.4.0 + */ + default void visitNestMembers(final NestMembers obj) { + // empty + } + + /** + * @since 6.0 + */ + void visitParameterAnnotation(ParameterAnnotations obj); + + /** + * @since 6.0 + */ + void visitParameterAnnotationEntry(ParameterAnnotationEntry obj); + + void visitSignature(Signature obj); + + void visitSourceFile(SourceFile obj); + + void visitStackMap(StackMap obj); + + void visitStackMapEntry(StackMapEntry obj); + + void visitSynthetic(Synthetic obj); + + void visitUnknown(Unknown obj); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html new file mode 100644 index 0000000..abbccff --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/classfile/package.html @@ -0,0 +1,30 @@ + + + + + + + +

+ This package contains the classes that describe the structure of a + Java class file and a class file parser. +

+ + diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java new file mode 100644 index 0000000..19bd38d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * AALOAD - Load reference from array + * + *
+ * Stack: ..., arrayref, index -> value
+ * 
+ */ +public class AALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load reference from array + */ + public AALOAD() { + super(com.sun.org.apache.bcel.internal.Const.AALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java new file mode 100644 index 0000000..9561ab4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * AASTORE - Store into reference array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class AASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store into reference array + */ + public AASTORE() { + super(com.sun.org.apache.bcel.internal.Const.AASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java new file mode 100644 index 0000000..95556b9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java @@ -0,0 +1,61 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ACONST_NULL - Push null reference + * + *
+ * Stack: ... -> ..., null
+ * 
+ */ +public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction { + + /** + * Push null reference + */ + public ACONST_NULL() { + super(com.sun.org.apache.bcel.internal.Const.ACONST_NULL, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitACONST_NULL(this); + } + + /** + * @return Type.NULL + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.NULL; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java new file mode 100644 index 0000000..997d04a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ALOAD.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ALOAD - Load reference from local variable + * + *
+ * Stack: ... -> ..., objectref
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class ALOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ALOAD() { + super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.Const.ALOAD_0); + } + + /** + * Load reference from local variable + * + * @param n index of local variable + */ + public ALOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.Const.ALOAD_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java new file mode 100644 index 0000000..eabf15c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java @@ -0,0 +1,75 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ANEWARRAY - Create new array of references + * + *
+ * Stack: ..., count -> ..., arrayref
+ * 
+ */ +public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower, StackConsumer, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ANEWARRAY() { + } + + public ANEWARRAY(final int index) { + super(com.sun.org.apache.bcel.internal.Const.ANEWARRAY, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLoadClass(this); + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitANEWARRAY(this); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION); + } + + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + Type t = getType(cpg); + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + return t instanceof ObjectType ? (ObjectType) t : null; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java new file mode 100644 index 0000000..ff2428d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ARETURN - Return reference from method + * + *
+ * Stack: ..., objectref -> <empty>
+ * 
+ */ +public class ARETURN extends ReturnInstruction { + + /** + * Return reference from method + */ + public ARETURN() { + super(com.sun.org.apache.bcel.internal.Const.ARETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitARETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java new file mode 100644 index 0000000..fc5d5cb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ARRAYLENGTH - Get length of array + * + *
+ * Stack: ..., arrayref -> ..., length
+ * 
+ * + * @LastModified: Feb 2023 + */ +public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ { + + /** + * Get length of array + */ + public ARRAYLENGTH() { + super(com.sun.org.apache.bcel.internal.Const.ARRAYLENGTH, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitARRAYLENGTH(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java new file mode 100644 index 0000000..3526311 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ASTORE.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * ASTORE - Store reference into local variable + * + *
+ * Stack ..., objectref -> ...
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class ASTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ASTORE() { + super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.Const.ASTORE_0); + } + + /** + * Store reference into local variable + * + * @param n index of local variable + */ + public ASTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.Const.ASTORE_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java new file mode 100644 index 0000000..a52d6ea --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ATHROW.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * ATHROW - Throw exception + * + *
+ * Stack: ..., objectref -> objectref
+ * 
+ */ +public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower { + + /** + * Throw exception + */ + public ATHROW() { + super(com.sun.org.apache.bcel.internal.Const.ATHROW, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitUnconditionalBranch(this); + v.visitExceptionThrower(this); + v.visitATHROW(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.THROWABLE}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java new file mode 100644 index 0000000..8e8626d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java @@ -0,0 +1,28 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote family of instructions that allocates space in the heap. + */ +public interface AllocationInstruction { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java new file mode 100644 index 0000000..1ed232d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java @@ -0,0 +1,77 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.AnnotationElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class AnnotationElementValueGen extends ElementValueGen { + // For annotation element values, this is the annotation + private final AnnotationEntryGen a; + + public AnnotationElementValueGen(final AnnotationElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(ANNOTATION, cpool); + a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries); + } + + public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool) { + super(ANNOTATION, cpool); + this.a = a; + } + + public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation, final ConstantPoolGen cpool) { + super(type, cpool); + if (type != ANNOTATION) { + throw new IllegalArgumentException("Only element values of type annotation can be built with this ctor - type specified: " + type); + } + this.a = annotation; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 type of value (ANNOTATION == '@') + a.dump(dos); + } + + public AnnotationEntryGen getAnnotation() { + return a; + } + + /** + * Return immutable variant of this AnnotationElementValueGen + */ + @Override + public ElementValue getElementValue() { + return new AnnotationElementValue(super.getElementValueType(), a.getAnnotation(), getConstantPool().getConstantPool()); + } + + @Override + public String stringifyValue() { + throw new UnsupportedOperationException("Not implemented yet"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java new file mode 100644 index 0000000..f7a2109 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValuePair; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleParameterAnnotations; + +/** + * @LastModified: Jan 2020 + * @since 6.0 + */ +public class AnnotationEntryGen { + + static final AnnotationEntryGen[] EMPTY_ARRAY = {}; + private final ConstantPoolGen cpool; + private int typeIndex; + private List evs; + private boolean isRuntimeVisible; + + /** + * Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object. If the pool + * passed in is for a different class file, then copyPoolEntries should have been passed as true as that will force us + * to do a deep copy of the annotation and move the cpool entries across. We need to copy the type and the element name + * value pairs and the visibility. + */ + public AnnotationEntryGen(final AnnotationEntry a, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + this.cpool = cpool; + if (copyPoolEntries) { + typeIndex = cpool.addUtf8(a.getAnnotationType()); + } else { + typeIndex = a.getAnnotationTypeIndex(); + } + isRuntimeVisible = a.isRuntimeVisible(); + evs = copyValues(a.getElementValuePairs(), cpool, copyPoolEntries); + } + + private AnnotationEntryGen(final ConstantPoolGen cpool) { + this.cpool = cpool; + } + + public AnnotationEntryGen(final ObjectType type, final List elements, final boolean vis, final ConstantPoolGen cpool) { + this.cpool = cpool; + this.typeIndex = cpool.addUtf8(type.getSignature()); + evs = elements; + isRuntimeVisible = vis; + } + + /** + * Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file. + * + * @param cp The constant pool gen where we can create the necessary name refs + * @param annotationEntryGens An array of AnnotationGen objects + */ + static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final AnnotationEntryGen[] annotationEntryGens) { + if (annotationEntryGens.length == 0) { + return Attribute.EMPTY_ARRAY; + } + + try { + int countVisible = 0; + int countInvisible = 0; + + // put the annotations in the right output stream + for (final AnnotationEntryGen a : annotationEntryGens) { + if (a.isRuntimeVisible()) { + countVisible++; + } else { + countInvisible++; + } + } + + final ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + final ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes); DataOutputStream riaDos = new DataOutputStream(riaBytes)) { + + rvaDos.writeShort(countVisible); + riaDos.writeShort(countInvisible); + + // put the annotations in the right output stream + for (final AnnotationEntryGen a : annotationEntryGens) { + if (a.isRuntimeVisible()) { + a.dump(rvaDos); + } else { + a.dump(riaDos); + } + } + } + + final byte[] rvaData = rvaBytes.toByteArray(); + final byte[] riaData = riaBytes.toByteArray(); + + int rvaIndex = -1; + int riaIndex = -1; + + if (rvaData.length > 2) { + rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); + } + if (riaData.length > 2) { + riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); + } + + final List newAttributes = new ArrayList<>(); + if (rvaData.length > 2) { + newAttributes + .add(new RuntimeVisibleAnnotations(rvaIndex, rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); + } + if (riaData.length > 2) { + newAttributes.add( + new RuntimeInvisibleAnnotations(riaIndex, riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); + } + + return newAttributes.toArray(Attribute.EMPTY_ARRAY); + } catch (final IOException e) { + System.err.println("IOException whilst processing annotations"); + e.printStackTrace(); + } + return null; + } + + /** + * Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations - + * RuntimeInvisibleParameterAnnotations + */ + static Attribute[] getParameterAnnotationAttributes(final ConstantPoolGen cp, + final List[] /* Array of lists, array size depends on #params */ vec) { + final int[] visCount = new int[vec.length]; + int totalVisCount = 0; + final int[] invisCount = new int[vec.length]; + int totalInvisCount = 0; + try { + for (int i = 0; i < vec.length; i++) { + if (vec[i] != null) { + for (final AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + visCount[i]++; + totalVisCount++; + } else { + invisCount[i]++; + totalInvisCount++; + } + } + } + } + // Lets do the visible ones + final ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes)) { + rvaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + rvaDos.writeShort(visCount[i]); + if (visCount[i] > 0) { + for (final AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + element.dump(rvaDos); + } + } + } + } + } + // Lets do the invisible ones + final ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + try (DataOutputStream riaDos = new DataOutputStream(riaBytes)) { + riaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + riaDos.writeShort(invisCount[i]); + if (invisCount[i] > 0) { + for (final AnnotationEntryGen element : vec[i]) { + if (!element.isRuntimeVisible()) { + element.dump(riaDos); + } + } + } + } + } + final byte[] rvaData = rvaBytes.toByteArray(); + final byte[] riaData = riaBytes.toByteArray(); + int rvaIndex = -1; + int riaIndex = -1; + if (totalVisCount > 0) { + rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); + } + if (totalInvisCount > 0) { + riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); + } + final List newAttributes = new ArrayList<>(); + if (totalVisCount > 0) { + newAttributes.add(new RuntimeVisibleParameterAnnotations(rvaIndex, rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), + cp.getConstantPool())); + } + if (totalInvisCount > 0) { + newAttributes.add(new RuntimeInvisibleParameterAnnotations(riaIndex, riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), + cp.getConstantPool())); + } + return newAttributes.toArray(Attribute.EMPTY_ARRAY); + } catch (final IOException e) { + System.err.println("IOException whilst processing parameter annotations"); + e.printStackTrace(); + } + return null; + } + + public static AnnotationEntryGen read(final DataInput dis, final ConstantPoolGen cpool, final boolean b) throws IOException { + final AnnotationEntryGen a = new AnnotationEntryGen(cpool); + a.typeIndex = dis.readUnsignedShort(); + final int elemValuePairCount = dis.readUnsignedShort(); + for (int i = 0; i < elemValuePairCount; i++) { + final int nidx = dis.readUnsignedShort(); + a.addElementNameValuePair(new ElementValuePairGen(nidx, ElementValueGen.readElementValue(dis, cpool), cpool)); + } + a.isRuntimeVisible(b); + return a; + } + + public void addElementNameValuePair(final ElementValuePairGen evp) { + if (evs == null) { + evs = new ArrayList<>(); + } + evs.add(evp); + } + + private List copyValues(final ElementValuePair[] in, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + final List out = new ArrayList<>(); + for (final ElementValuePair nvp : in) { + out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries)); + } + return out; + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(typeIndex); // u2 index of type name in cpool + dos.writeShort(evs.size()); // u2 element_value pair count + for (final ElementValuePairGen envp : evs) { + envp.dump(dos); + } + } + + /** + * Retrieve an immutable version of this AnnotationGen + */ + public AnnotationEntry getAnnotation() { + final AnnotationEntry a = new AnnotationEntry(typeIndex, cpool.getConstantPool(), isRuntimeVisible); + for (final ElementValuePairGen element : evs) { + a.addElementNameValuePair(element.getElementNameValuePair()); + } + return a; + } + + public int getTypeIndex() { + return typeIndex; + } + + public final String getTypeName() { + return getTypeSignature();// BCELBUG: Should I use this instead? + // Utility.signatureToString(getTypeSignature()); + } + + public final String getTypeSignature() { + // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); + final ConstantUtf8 utf8 = (ConstantUtf8) cpool.getConstant(typeIndex/* c.getNameIndex() */); + return utf8.getBytes(); + } + + /** + * Returns list of ElementNameValuePair objects + */ + public List getValues() { + return evs; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + private void isRuntimeVisible(final boolean b) { + isRuntimeVisible = b; + } + + public String toShortString() { + final StringBuilder s = new StringBuilder(); + s.append("@").append(getTypeName()).append("("); + for (int i = 0; i < evs.size(); i++) { + s.append(evs.get(i)); + if (i + 1 < evs.size()) { + s.append(","); + } + } + s.append(")"); + return s.toString(); + } + + @Override + public String toString() { + final StringBuilder s = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber + s.append("AnnotationGen:[").append(getTypeName()).append(" #").append(evs.size()).append(" {"); + for (int i = 0; i < evs.size(); i++) { + s.append(evs.get(i)); + if (i + 1 < evs.size()) { + s.append(","); + } + } + s.append("}]"); + return s.toString(); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java new file mode 100644 index 0000000..213cd53 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java @@ -0,0 +1,95 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for the family of arithmetic instructions. + */ +public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ArithmeticInstruction() { + } + + /** + * @param opcode of instruction + */ + protected ArithmeticInstruction(final short opcode) { + super(opcode, (short) 1); + } + + /** + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + final short opcode = super.getOpcode(); + switch (opcode) { + case Const.DADD: + case Const.DDIV: + case Const.DMUL: + case Const.DNEG: + case Const.DREM: + case Const.DSUB: + return Type.DOUBLE; + case Const.FADD: + case Const.FDIV: + case Const.FMUL: + case Const.FNEG: + case Const.FREM: + case Const.FSUB: + return Type.FLOAT; + case Const.IADD: + case Const.IAND: + case Const.IDIV: + case Const.IMUL: + case Const.INEG: + case Const.IOR: + case Const.IREM: + case Const.ISHL: + case Const.ISHR: + case Const.ISUB: + case Const.IUSHR: + case Const.IXOR: + return Type.INT; + case Const.LADD: + case Const.LAND: + case Const.LDIV: + case Const.LMUL: + case Const.LNEG: + case Const.LOR: + case Const.LREM: + case Const.LSHL: + case Const.LSHR: + case Const.LSUB: + case Const.LUSHR: + case Const.LXOR: + return Type.LONG; + default: // Never reached + throw new ClassGenException("Unknown type " + opcode); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java new file mode 100644 index 0000000..7137487 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java @@ -0,0 +1,116 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.sun.org.apache.bcel.internal.classfile.ArrayElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class ArrayElementValueGen extends ElementValueGen { + // J5TODO: Should we make this an array or a list? A list would be easier to + // modify ... + private final List evalues; + + /** + * @param value + * @param cpool + */ + public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(ARRAY, cpool); + evalues = new ArrayList<>(); + final ElementValue[] in = value.getElementValuesArray(); + for (final ElementValue element : in) { + evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries)); + } + } + + public ArrayElementValueGen(final ConstantPoolGen cp) { + super(ARRAY, cp); + evalues = new ArrayList<>(); + } + + public ArrayElementValueGen(final int type, final ElementValue[] datums, final ConstantPoolGen cpool) { + super(type, cpool); + if (type != ARRAY) { + throw new IllegalArgumentException("Only element values of type array can be built with this ctor - type specified: " + type); + } + this.evalues = new ArrayList<>(); + for (final ElementValue datum : datums) { + evalues.add(ElementValueGen.copy(datum, cpool, true)); + } + } + + public void addElement(final ElementValueGen gen) { + evalues.add(gen); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 type of value (ARRAY == '[') + dos.writeShort(evalues.size()); + for (final ElementValueGen element : evalues) { + element.dump(dos); + } + } + + /** + * Return immutable variant of this ArrayElementValueGen + */ + @Override + public ElementValue getElementValue() { + final ElementValue[] immutableData = new ElementValue[evalues.size()]; + int i = 0; + for (final ElementValueGen element : evalues) { + immutableData[i++] = element.getElementValue(); + } + return new ArrayElementValue(super.getElementValueType(), immutableData, getConstantPool().getConstantPool()); + } + + public List getElementValues() { + return evalues; + } + + public int getElementValuesSize() { + return evalues.size(); + } + + @Override + public String stringifyValue() { + final StringBuilder sb = new StringBuilder(); + sb.append("["); + String comma = ""; + for (final ElementValueGen element : evalues) { + sb.append(comma); + comma = ","; + sb.append(element.stringifyValue()); + } + sb.append("]"); + return sb.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java new file mode 100644 index 0000000..00bee61 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * Super class for instructions dealing with array access such as IALOAD. + */ +public abstract class ArrayInstruction extends Instruction implements ExceptionThrower, TypedInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ArrayInstruction() { + } + + /** + * @param opcode of instruction + */ + protected ArrayInstruction(final short opcode) { + super(opcode, (short) 1); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_ARRAY_EXCEPTION); + } + + /** + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + final short opcode = super.getOpcode(); + switch (opcode) { + case com.sun.org.apache.bcel.internal.Const.IALOAD: + case com.sun.org.apache.bcel.internal.Const.IASTORE: + return Type.INT; + case com.sun.org.apache.bcel.internal.Const.CALOAD: + case com.sun.org.apache.bcel.internal.Const.CASTORE: + return Type.CHAR; + case com.sun.org.apache.bcel.internal.Const.BALOAD: + case com.sun.org.apache.bcel.internal.Const.BASTORE: + return Type.BYTE; + case com.sun.org.apache.bcel.internal.Const.SALOAD: + case com.sun.org.apache.bcel.internal.Const.SASTORE: + return Type.SHORT; + case com.sun.org.apache.bcel.internal.Const.LALOAD: + case com.sun.org.apache.bcel.internal.Const.LASTORE: + return Type.LONG; + case com.sun.org.apache.bcel.internal.Const.DALOAD: + case com.sun.org.apache.bcel.internal.Const.DASTORE: + return Type.DOUBLE; + case com.sun.org.apache.bcel.internal.Const.FALOAD: + case com.sun.org.apache.bcel.internal.Const.FASTORE: + return Type.FLOAT; + case com.sun.org.apache.bcel.internal.Const.AALOAD: + case com.sun.org.apache.bcel.internal.Const.AASTORE: + return Type.OBJECT; + default: + throw new ClassGenException("Unknown case in switch" + opcode); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java new file mode 100644 index 0000000..ea40ce4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ArrayType.java @@ -0,0 +1,140 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Denotes array type, such as int[][] + */ +public final class ArrayType extends ReferenceType { + + private final int dimensions; + private final Type basicType; + + /** + * Convenience constructor for array type, e.g. int[] + * + * @param type array type, e.g. T_INT + * @param dimensions array dimensions + */ + public ArrayType(final byte type, final int dimensions) { + this(BasicType.getType(type), dimensions); + } + + /** + * Convenience constructor for reference array type, e.g. Object[] + * + * @param className complete name of class (java.lang.String, e.g.) + * @param dimensions array dimensions + */ + public ArrayType(final String className, final int dimensions) { + this(ObjectType.getInstance(className), dimensions); + } + + /** + * Constructor for array of given type + * + * @param type type of array (may be an array itself) + * @param dimensions array dimensions + */ + public ArrayType(final Type type, final int dimensions) { + super(Const.T_ARRAY, ""); + if (dimensions < 1 || dimensions > Const.MAX_BYTE) { + throw new ClassGenException("Invalid number of dimensions: " + dimensions); + } + switch (type.getType()) { + case Const.T_ARRAY: + final ArrayType array = (ArrayType) type; + this.dimensions = dimensions + array.dimensions; + basicType = array.basicType; + break; + case Const.T_VOID: + throw new ClassGenException("Invalid type: void[]"); + default: // Basic type or reference + this.dimensions = dimensions; + basicType = type; + break; + } + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < this.dimensions; i++) { + buf.append('['); + } + buf.append(basicType.getSignature()); + super.setSignature(buf.toString()); + } + + /** + * @return true if both type objects refer to the same array type. + */ + @Override + public boolean equals(final Object type) { + if (type instanceof ArrayType) { + final ArrayType array = (ArrayType) type; + return array.dimensions == dimensions && array.basicType.equals(basicType); + } + return false; + } + + /** + * @return basic type of array, i.e., for int[][][] the basic type is int + */ + public Type getBasicType() { + return basicType; + } + + /** + * Gets the name of referenced class. + * + * @return name of referenced class. + * @since 6.7.0 + */ + @Override + @Deprecated + public String getClassName() { + return signature; + } + + /** + * @return number of dimensions of array + */ + public int getDimensions() { + return dimensions; + } + + /** + * @return element type of array, i.e., for int[][][] the element type is int[][] + */ + public Type getElementType() { + if (dimensions == 1) { + return basicType; + } + return new ArrayType(basicType, dimensions - 1); + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return basicType.hashCode() ^ dimensions; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java new file mode 100644 index 0000000..dc14c3f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BALOAD.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BALOAD - Load byte or boolean from array + * + *
+ * Stack: ..., arrayref, index -> ..., value
+ * 
+ */ +public class BALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load byte or boolean from array + */ + public BALOAD() { + super(com.sun.org.apache.bcel.internal.Const.BALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java new file mode 100644 index 0000000..da73a50 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BASTORE.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BASTORE - Store into byte or boolean array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class BASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store byte or boolean into array + */ + public BASTORE() { + super(com.sun.org.apache.bcel.internal.Const.BASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java new file mode 100644 index 0000000..264fe1c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BIPUSH.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * BIPUSH - Push byte on stack + * + *
+ * Stack: ... -> ..., value
+ * 
+ */ +public class BIPUSH extends Instruction implements ConstantPushInstruction { + + private byte b; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + BIPUSH() { + } + + /** + * Push byte on stack + */ + public BIPUSH(final byte b) { + super(com.sun.org.apache.bcel.internal.Const.BIPUSH, (short) 2); + this.b = b; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitBIPUSH(this); + } + + /** + * Dump instruction as byte code to stream out. + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + out.writeByte(b); + } + + /** + * @return Type.BYTE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.BYTE; + } + + @Override + public Number getValue() { + return Integer.valueOf(b); + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setLength(2); + b = bytes.readByte(); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + b; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java new file mode 100644 index 0000000..a4fc7be --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java @@ -0,0 +1,42 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BREAKPOINT, JVM dependent, ignored by default + */ +public class BREAKPOINT extends Instruction { + + public BREAKPOINT() { + super(com.sun.org.apache.bcel.internal.Const.BREAKPOINT, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitBREAKPOINT(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java new file mode 100644 index 0000000..66e13e3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BasicType.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Denotes basic type such as int. + */ +public final class BasicType extends Type { + + /** + * Constructor for basic types such as int, long, 'void' + * + * @param type one of T_INT, T_BOOLEAN, ..., T_VOID + * @see Const + */ + BasicType(final byte type) { + super(type, Const.getShortTypeName(type)); + if (type < Const.T_BOOLEAN || type > Const.T_VOID) { + throw new ClassGenException("Invalid type: " + type); + } + } + + // @since 6.0 no longer final + public static BasicType getType(final byte type) { + switch (type) { + case Const.T_VOID: + return VOID; + case Const.T_BOOLEAN: + return BOOLEAN; + case Const.T_BYTE: + return BYTE; + case Const.T_SHORT: + return SHORT; + case Const.T_CHAR: + return CHAR; + case Const.T_INT: + return INT; + case Const.T_LONG: + return LONG; + case Const.T_DOUBLE: + return DOUBLE; + case Const.T_FLOAT: + return FLOAT; + default: + throw new ClassGenException("Invalid type: " + type); + } + } + + /** + * @return true if both type objects refer to the same type + */ + @Override + public boolean equals(final Object type) { + return type instanceof BasicType && ((BasicType) type).getType() == this.getType(); + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return super.getType(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java new file mode 100644 index 0000000..a4dc539 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchHandle.java @@ -0,0 +1,105 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * BranchHandle is returned by specialized InstructionList.append() whenever a BranchInstruction is appended. This is + * useful when the target of this instruction is not known at time of creation and must be set later via setTarget(). + * + * @see InstructionHandle + * @see Instruction + * @see InstructionList + */ +public final class BranchHandle extends InstructionHandle { + + // This is also a cache in case the InstructionHandle#swapInstruction() method is used + // See BCEL-273 + private BranchInstruction bi; // An alias in fact, but saves lots of casts + + private BranchHandle(final BranchInstruction i) { + super(i); + bi = i; + } + + /** + * Factory method. + */ + static BranchHandle getBranchHandle(final BranchInstruction i) { + return new BranchHandle(i); + } + + /* + * Override InstructionHandle methods: delegate to branch instruction. Through this overriding all access to the private + * i_position field should be prevented. + */ + @Override + public int getPosition() { + return bi.getPosition(); + } + + @Override + void setPosition(final int pos) { + // Original code: i_position = bi.position = pos; + bi.setPosition(pos); + super.setPosition(pos); + } + + /** + * @return target of instruction. + */ + public InstructionHandle getTarget() { + return bi.getTarget(); + } + + /** + * Pass new target to instruction. + */ + public void setTarget(final InstructionHandle ih) { + bi.setTarget(ih); + } + + /** + * Set new contents. Old instruction is disposed and may not be used anymore. + */ + @Override + // This is only done in order to apply the additional type check; could be merged with super impl. + public void setInstruction(final Instruction i) { // TODO could be package-protected? + super.setInstruction(i); + if (!(i instanceof BranchInstruction)) { + throw new ClassGenException("Assigning " + i + " to branch handle which is not a branch instruction"); + } + bi = (BranchInstruction) i; + } + + @Override + protected int updatePosition(final int offset, final int maxOffset) { + final int x = bi.updatePosition(offset, maxOffset); + super.setPosition(bi.getPosition()); + return x; + } + + /** + * Update target of instruction. + */ + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + bi.updateTarget(oldIh, newIh); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java new file mode 100644 index 0000000..0092c03 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for branching instructions like GOTO, IFEQ, etc.. Branch instructions may have a variable + * length, namely GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. + * + * @LastModified: Feb 2023 + * @see InstructionList + */ +public abstract class BranchInstruction extends Instruction implements InstructionTargeter { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int index; // Branch target relative to this instruction + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected InstructionHandle target; // Target object in instruction list + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int position; // Byte code offset + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + BranchInstruction() { + } + + /** + * Common super constructor + * + * @param opcode Instruction opcode + * @param target instruction to branch to + */ + protected BranchInstruction(final short opcode, final InstructionHandle target) { + super(opcode, (short) 3); + setTarget(target); + } + + /** + * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen, LineNumberGen + */ + static void notifyTarget(final InstructionHandle oldIh, final InstructionHandle newIh, final InstructionTargeter t) { + if (oldIh != null) { + oldIh.removeTargeter(t); + } + if (newIh != null) { + newIh.addTargeter(t); + } + } + + /** + * @return true, if ih is target of this instruction + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return target == ih; + } + + /** + * Inform target that it's not targeted anymore. + */ + @Override + void dispose() { + setTarget(null); + index = -1; + position = -1; + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + index = getTargetOffset(); + if (!isValidShort(index)) { + throw new ClassGenException("Branch target offset too large for short: " + index); + } + out.writeShort(index); // May be negative, i.e., point backwards + } + + /** + * @return target offset in byte code + */ + public final int getIndex() { + return index; + } + + /** + * @param index the index to set + * @since 6.0 + */ + protected void setIndex(final int index) { + this.index = index; + } + + /** + * @return the position + * @since 6.0 + */ + protected int getPosition() { + return position; + } + + /** + * @param position the position to set + * @since 6.0 + */ + protected void setPosition(final int position) { + this.position = position; + } + + /** + * @return target of branch instruction + */ + public InstructionHandle getTarget() { + return target; + } + + /** + * Set branch target + * + * @param target branch target + */ + public void setTarget(final InstructionHandle target) { + notifyTarget(this.target, target, this); + this.target = target; + } + + /** + * @return the offset to this instruction's target + */ + protected int getTargetOffset() { + return getTargetOffset(target); + } + + /** + * @param target branch target + * @return the offset to 'target' relative to this instruction + */ + protected int getTargetOffset(final InstructionHandle target) { + if (target == null) { + throw new ClassGenException("Target of " + super.toString(true) + " is invalid null handle"); + } + final int t = target.getPosition(); + if (t < 0) { + throw new ClassGenException("Invalid branch target position offset for " + super.toString(true) + ":" + t + ":" + target); + } + return t - position; + } + + /** + * Read needed data (e.g. index) from file. Conversion to a InstructionHandle is done in InstructionList(byte[]). + * + * @param bytes input stream + * @param wide wide prefix? + * @see InstructionList + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setLength(3); + index = bytes.readShort(); + } + + /** + * Updates the opcode. Before changing the opcode, reset the target so that + * the old instruction is removed from the HashSet and the new one then added. + * + * @param opcode the opcode + */ + @Override + void setOpcode(final short opcode) { + if (target == null) { + super.setOpcode(opcode); + } else { + // reset target before changing the opcode + InstructionHandle t = target; + setTarget(null); + super.setOpcode(opcode); + setTarget(t); + } + } + + /** + * Long output format: + *

+ * <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" + * "<"<target instruction>">" "@"<branch target offset> + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + final String s = super.toString(verbose); + String t = "null"; + if (target != null) { + if (verbose) { + if (target.getInstruction() == this) { + t = ""; + } else if (target.getInstruction() == null) { + t = ""; + } else { + // I'm more interested in the address of the target then + // the instruction located there. + // t = target.getInstruction().toString(false); // Avoid circles + t = "" + target.getPosition(); + } + } else { + index = target.getPosition(); + // index = getTargetOffset(); crashes if positions haven't been set + // t = "" + (index + position); + t = "" + index; + } + } + return s + " -> " + t; + } + + /** + * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable + * length instructions 'setPositions' performs multiple passes over the instruction list to calculate the correct (byte) + * positions and offsets by calling this function. + * + * @param offset additional offset caused by preceding (variable length) instructions + * @param maxOffset the maximum offset that may be caused by these instructions + * @return additional offset caused by possible change of this instruction's length + */ + protected int updatePosition(final int offset, final int maxOffset) { + position += offset; + return 0; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + if (target != oldIh) { + throw new ClassGenException("Not targeting " + oldIh + ", but " + target); + } + setTarget(newIh); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java new file mode 100644 index 0000000..02cc46d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * CALOAD - Load char from array + * + *

+ * Stack: ..., arrayref, index -> ..., value
+ * 
+ */ +public class CALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load char from array + */ + public CALOAD() { + super(com.sun.org.apache.bcel.internal.Const.CALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java new file mode 100644 index 0000000..ca4a4e1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * CASTORE - Store into char array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class CASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store char into array + */ + public CASTORE() { + super(com.sun.org.apache.bcel.internal.Const.CASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java new file mode 100644 index 0000000..6983350 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java @@ -0,0 +1,83 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * CHECKCAST - Check whether object is of given type + * + *
+ * Stack: ..., objectref -> ..., objectref
+ * 
+ */ +public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + CHECKCAST() { + } + + /** + * Check whether object is of given type + * + * @param index index to class in constant pool + */ + public CHECKCAST(final int index) { + super(com.sun.org.apache.bcel.internal.Const.CHECKCAST, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLoadClass(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitCHECKCAST(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.CLASS_CAST_EXCEPTION); + } + + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + Type t = getType(cpg); + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + return t instanceof ObjectType ? (ObjectType) t : null; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java new file mode 100644 index 0000000..283923e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CPInstruction.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for instructions that use an index into the constant pool such as LDC, INVOKEVIRTUAL, etc. + * + * @LastModified: Jan 2020 + * @see ConstantPoolGen + * @see LDC + * @see INVOKEVIRTUAL + */ +public abstract class CPInstruction extends Instruction implements TypedInstruction, IndexedInstruction { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int index; // index to constant pool + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + CPInstruction() { + } + + /** + * @param index to constant pool + */ + protected CPInstruction(final short opcode, final int index) { + super(opcode, (short) 3); + setIndex(index); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(index); + } + + /** + * @return index in constant pool referred by this instruction. + */ + @Override + public final int getIndex() { + return index; + } + + /** + * Set the index to constant pool. + * + * @param index in constant pool. + */ + @Override + public void setIndex(final int index) { // TODO could be package-protected? + if (index < 0) { + throw new ClassGenException("Negative index value: " + index); + } + this.index = index; + } + + /** + * @return type related with this instruction. + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + String name = cp.getConstantString(index, com.sun.org.apache.bcel.internal.Const.CONSTANT_Class); + if (!name.startsWith("[")) { + name = "L" + name + ";"; + } + return Type.getType(name); + } + + /** + * Read needed data (i.e., index) from file. + * + * @param bytes input stream + * @param wide wide prefix? + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + setIndex(bytes.readUnsignedShort()); + super.setLength(3); + } + + /** + * Long output format: + *

+ * <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool + * index>">" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + index; + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + final Constant c = cp.getConstant(index); + String str = cp.constantToString(c); + if (c instanceof ConstantClass) { + str = Utility.packageToPath(str); + } + return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + str; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java new file mode 100644 index 0000000..1c1c032 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java @@ -0,0 +1,92 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ClassElementValue; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class ClassElementValueGen extends ElementValueGen { + // For primitive types and string type, this points to the value entry in + // the cpool + // For 'class' this points to the class entry in the cpool + private final int idx; + + public ClassElementValueGen(final ClassElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(CLASS, cpool); + if (copyPoolEntries) { + // idx = cpool.addClass(value.getClassString()); + idx = cpool.addUtf8(value.getClassString()); + } else { + idx = value.getIndex(); + } + } + + protected ClassElementValueGen(final int typeIdx, final ConstantPoolGen cpool) { + super(ElementValueGen.CLASS, cpool); + this.idx = typeIdx; + } + + public ClassElementValueGen(final ObjectType t, final ConstantPoolGen cpool) { + super(ElementValueGen.CLASS, cpool); + // this.idx = cpool.addClass(t); + idx = cpool.addUtf8(t.getSignature()); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 kind of value + dos.writeShort(idx); + } + + public String getClassString() { + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); + return cu8.getBytes(); + // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx); + // ConstantUtf8 utf8 = + // (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex()); + // return utf8.getBytes(); + } + + /** + * Return immutable variant of this ClassElementValueGen + */ + @Override + public ElementValue getElementValue() { + return new ClassElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool()); + } + + public int getIndex() { + return idx; + } + + @Override + public String stringifyValue() { + return getClassString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java new file mode 100644 index 0000000..eb695c3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGen.java @@ -0,0 +1,540 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AccessFlags; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleAnnotations; +import com.sun.org.apache.bcel.internal.classfile.SourceFile; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * Template class for building up a java class. May be initialized with an existing java class (file). + * + * @LastModified: Feb 2023 + * @see JavaClass + */ +public class ClassGen extends AccessFlags implements Cloneable { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final ClassGen THIS = (ClassGen) o1; + final ClassGen THAT = (ClassGen) o2; + return Objects.equals(THIS.getClassName(), THAT.getClassName()); + } + + @Override + public int hashCode(final Object o) { + final ClassGen THIS = (ClassGen) o; + return THIS.getClassName().hashCode(); + } + }; + private final String fileName; + // ArrayLists instead of arrays to gather fields, methods, etc. + private final List fieldList = new ArrayList<>(); + private final List methodList = new ArrayList<>(); + private final List attributeList = new ArrayList<>(); + private final List interfaceList = new ArrayList<>(); + private final List annotationList = new ArrayList<>(); + /* + * Corresponds to the fields found in a JavaClass object. + */ + private String className; + private String superClassName; + private int classNameIndex = -1; + private int superclassNameIndex = -1; + private int major = Const.MAJOR_1_1; + private int minor = Const.MINOR_1_1; + private ConstantPoolGen cp; // Template for building up constant pool + private List observers; + + /** + * Initialize with existing class. + * + * @param clazz JavaClass object (e.g. read from file) + */ + public ClassGen(final JavaClass clazz) { + super(clazz.getAccessFlags()); + classNameIndex = clazz.getClassNameIndex(); + superclassNameIndex = clazz.getSuperclassNameIndex(); + className = clazz.getClassName(); + superClassName = clazz.getSuperclassName(); + fileName = clazz.getSourceFileName(); + cp = new ConstantPoolGen(clazz.getConstantPool()); + major = clazz.getMajor(); + minor = clazz.getMinor(); + final Attribute[] attributes = clazz.getAttributes(); + // J5TODO: Could make unpacking lazy, done on first reference + final AnnotationEntryGen[] annotations = unpackAnnotations(attributes); + Collections.addAll(interfaceList, clazz.getInterfaceNames()); + for (final Attribute attribute : attributes) { + if (!(attribute instanceof Annotations)) { + addAttribute(attribute); + } + } + Collections.addAll(annotationList, annotations); + Collections.addAll(methodList, clazz.getMethods()); + Collections.addAll(fieldList, clazz.getFields()); + } + + /** + * Convenience constructor to set up some important values initially. + * + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers + * @param interfaces implemented interfaces + */ + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces) { + this(className, superClassName, fileName, accessFlags, interfaces, new ConstantPoolGen()); + } + + /** + * Convenience constructor to set up some important values initially. + * + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name + * @param accessFlags access qualifiers + * @param interfaces implemented interfaces + * @param cp constant pool to use + */ + public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces, + final ConstantPoolGen cp) { + super(accessFlags); + this.className = className; + this.superClassName = superClassName; + this.fileName = fileName; + this.cp = cp; + // Put everything needed by default into the constant pool and the vectors + if (fileName != null) { + addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(fileName), cp.getConstantPool())); + } + classNameIndex = cp.addClass(className); + superclassNameIndex = cp.addClass(superClassName); + if (interfaces != null) { + Collections.addAll(interfaceList, interfaces); + } + } + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + public void addAnnotationEntry(final AnnotationEntryGen a) { + annotationList.add(a); + } + + /** + * Add an attribute to this class. + * + * @param a attribute to add + */ + public void addAttribute(final Attribute a) { + attributeList.add(a); + } + + /** + * Convenience method. + *

+ * Add an empty constructor to this class that does nothing but calling super(). + * + * @param accessFlags rights for constructor + */ + public void addEmptyConstructor(final int accessFlags) { + final InstructionList il = new InstructionList(); + il.append(InstructionConst.THIS); // Push 'this' + il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, Const.CONSTRUCTOR_NAME, "()V"))); + il.append(InstructionConst.RETURN); + final MethodGen mg = new MethodGen(accessFlags, Type.VOID, Type.NO_ARGS, null, Const.CONSTRUCTOR_NAME, className, il, cp); + mg.setMaxStack(1); + addMethod(mg.getMethod()); + } + + /** + * Add a field to this class. + * + * @param f field to add + */ + public void addField(final Field f) { + fieldList.add(f); + } + + /** + * Add an interface to this class, i.e., this class has to implement it. + * + * @param name interface to implement (fully qualified class name) + */ + public void addInterface(final String name) { + interfaceList.add(name); + } + + /** + * Add a method to this class. + * + * @param m method to add + */ + public void addMethod(final Method m) { + methodList.add(m); + } + + /** + * Add observer for this object. + */ + public void addObserver(final ClassObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + public boolean containsField(final Field f) { + return fieldList.contains(f); + } + + /** + * @return field object with given name, or null + */ + public Field containsField(final String name) { + for (final Field f : fieldList) { + if (f.getName().equals(name)) { + return f; + } + } + return null; + } + + /** + * @return method object with given name and signature, or null + */ + public Method containsMethod(final String name, final String signature) { + for (final Method m : methodList) { + if (m.getName().equals(name) && m.getSignature().equals(signature)) { + return m; + } + } + return null; + } + + /** + * Return value as defined by given BCELComparator strategy. By default two ClassGen objects are said to be equal when + * their class names are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here? + public AnnotationEntryGen[] getAnnotationEntries() { + return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + public Attribute[] getAttributes() { + return attributeList.toArray(Attribute.EMPTY_ARRAY); + } + + public String getClassName() { + return className; + } + + public void setClassName(final String name) { + className = Utility.pathToPackage(name); + classNameIndex = cp.addClass(name); + } + + public int getClassNameIndex() { + return classNameIndex; + } + + public void setClassNameIndex(final int classNameIndex) { + this.classNameIndex = classNameIndex; + this.className = Utility.pathToPackage(cp.getConstantPool().getConstantString(classNameIndex, Const.CONSTANT_Class)); + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + public void setConstantPool(final ConstantPoolGen constantPool) { + cp = constantPool; + } + + public Field[] getFields() { + return fieldList.toArray(Field.EMPTY_ARRAY); + } + + public String getFileName() { + return fileName; + } + + public String[] getInterfaceNames() { + return interfaceList.toArray(Const.EMPTY_STRING_ARRAY); + } + + public int[] getInterfaces() { + final int size = interfaceList.size(); + final int[] interfaces = new int[size]; + Arrays.setAll(interfaces, i -> cp.addClass(interfaceList.get(i))); + return interfaces; + } + + /** + * @return the (finally) built up Java class object. + */ + public JavaClass getJavaClass() { + final int[] interfaces = getInterfaces(); + final Field[] fields = getFields(); + final Method[] methods = getMethods(); + Attribute[] attributes = null; + if (annotationList.isEmpty()) { + attributes = getAttributes(); + } else { + // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' + final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); + attributes = new Attribute[attributeList.size() + annAttributes.length]; + attributeList.toArray(attributes); + System.arraycopy(annAttributes, 0, attributes, attributeList.size(), annAttributes.length); + } + // Must be last since the above calls may still add something to it + final ConstantPool cp = this.cp.getFinalConstantPool(); + return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, super.getAccessFlags(), cp, interfaces, fields, methods, + attributes); + } + + /** + * @return major version number of class file + */ + public int getMajor() { + return major; + } + + /** + * Set major version number of class file, default value is 45 (JDK 1.1) + * + * @param major major version number + */ + public void setMajor(final int major) { // TODO could be package-protected - only called by test code + this.major = major; + } + + public Method getMethodAt(final int pos) { + return methodList.get(pos); + } + + public Method[] getMethods() { + return methodList.toArray(Method.EMPTY_ARRAY); + } + + public void setMethods(final Method[] methods) { + methodList.clear(); + Collections.addAll(methodList, methods); + } + + /** + * @return minor version number of class file + */ + public int getMinor() { + return minor; + } + + /** + * Set minor version number of class file, default value is 3 (JDK 1.1) + * + * @param minor minor version number + */ + public void setMinor(final int minor) { // TODO could be package-protected - only called by test code + this.minor = minor; + } + + public String getSuperclassName() { + return superClassName; + } + + public void setSuperclassName(final String name) { + superClassName = Utility.pathToPackage(name); + superclassNameIndex = cp.addClass(name); + } + + public int getSuperclassNameIndex() { + return superclassNameIndex; + } + + public void setSuperclassNameIndex(final int superclassNameIndex) { + this.superclassNameIndex = superclassNameIndex; + superClassName = Utility.pathToPackage(cp.getConstantPool().getConstantString(superclassNameIndex, Const.CONSTANT_Class)); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Remove an attribute from this class. + * + * @param a attribute to remove + */ + public void removeAttribute(final Attribute a) { + attributeList.remove(a); + } + + /** + * Remove a field to this class. + * + * @param f field to remove + */ + public void removeField(final Field f) { + fieldList.remove(f); + } + + /** + * Remove an interface from this class. + * + * @param name interface to remove (fully qualified name) + */ + public void removeInterface(final String name) { + interfaceList.remove(name); + } + + /** + * Remove a method from this class. + * + * @param m method to remove + */ + public void removeMethod(final Method m) { + methodList.remove(m); + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final ClassObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * Replace given field with new one. If the old one does not exist add the new_ field to the class anyway. + */ + public void replaceField(final Field old, final Field newField) { + if (newField == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final int i = fieldList.indexOf(old); + if (i < 0) { + fieldList.add(newField); + } else { + fieldList.set(i, newField); + } + } + + /** + * Replace given method with new one. If the old one does not exist add the newMethod method to the class anyway. + */ + public void replaceMethod(final Method old, final Method newMethod) { + if (newMethod == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final int i = methodList.indexOf(old); + if (i < 0) { + methodList.add(newMethod); + } else { + methodList.set(i, newMethod); + } + } + + public void setMethodAt(final Method method, final int pos) { + methodList.set(pos, method); + } + + /** + * Look for attributes representing annotations and unpack them. + */ + private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) { + final List annotationGenObjs = new ArrayList<>(); + for (final Attribute attr : attrs) { + if (attr instanceof RuntimeVisibleAnnotations) { + final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr; + rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false))); + } else if (attr instanceof RuntimeInvisibleAnnotations) { + final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr; + ria.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false))); + } + } + return annotationGenObjs.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + /** + * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but + * has to be called by the user after they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final ClassObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java new file mode 100644 index 0000000..8dfbde8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassGenException.java @@ -0,0 +1,41 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Thrown on internal exceptions. + */ +public class ClassGenException extends RuntimeException { + + private static final long serialVersionUID = 7247369755051242791L; + + public ClassGenException() { + } + + public ClassGenException(final String s) { + super(s); + } + + public ClassGenException(final String s, final Throwable initCause) { + super(s, initCause); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java new file mode 100644 index 0000000..64f2c44 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ClassObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to a ClassGen object and register yourself with + * addObserver(). + */ +public interface ClassObserver { + + void notify(ClassGen clazz); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java new file mode 100644 index 0000000..615b155 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java @@ -0,0 +1,184 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.classfile.CodeException; + +/** + * This class represents an exception handler, i.e., specifies the region where a handler is active and an instruction + * where the actual handling is done. pool as parameters. Opposed to the JVM specification the end of the handled region + * is set to be inclusive, i.e. all instructions between start and end are protected including the start and end + * instructions (handles) themselves. The end of the region is automatically mapped to be exclusive when calling + * getCodeException(), i.e., there is no difference semantically. + * + * @see MethodGen + * @see CodeException + * @see InstructionHandle + */ +public final class CodeExceptionGen implements InstructionTargeter, Cloneable { + + static final CodeExceptionGen[] EMPTY_ARRAY = {}; + + private InstructionHandle startPc; + private InstructionHandle endPc; + private InstructionHandle handlerPc; + private ObjectType catchType; + + /** + * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling + * is done. + * + * @param startPc Start of handled region (inclusive) + * @param endPc End of handled region (inclusive) + * @param handlerPc Where handling is done + * @param catchType which exception is handled, null for ANY + */ + public CodeExceptionGen(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, final ObjectType catchType) { + setStartPC(startPc); + setEndPC(endPc); + setHandlerPC(handlerPc); + this.catchType = catchType; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this handler + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return startPc == ih || endPc == ih || handlerPc == ih; + } + + /** + * Gets the type of the Exception to catch, 'null' for ANY. + */ + public ObjectType getCatchType() { + return catchType; + } + + /** + * Sets the type of the Exception to catch. Set 'null' for ANY. + */ + public void setCatchType(final ObjectType catchType) { + this.catchType = catchType; + } + + /** + * Get CodeException object.
+ *

+ * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods + * has been called for the instruction list. + * + * @param cp constant pool + */ + public CodeException getCodeException(final ConstantPoolGen cp) { + return new CodeException(startPc.getPosition(), endPc.getPosition() + endPc.getInstruction().getLength(), handlerPc.getPosition(), + catchType == null ? 0 : cp.addClass(catchType)); + } + + /** + * @return end of handled region (inclusive) + */ + public InstructionHandle getEndPC() { + return endPc; + } + + /* + * Set end of handler + * + * @param endPc End of handled region (inclusive) + */ + public void setEndPC(final InstructionHandle endPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.endPc, endPc, this); + this.endPc = endPc; + } + + /** + * @return start of handler + */ + public InstructionHandle getHandlerPC() { + return handlerPc; + } + + /* + * Set handler code + * + * @param handlerPc Start of handler + */ + public void setHandlerPC(final InstructionHandle handlerPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.handlerPc, handlerPc, this); + this.handlerPc = handlerPc; + } + + /** + * @return start of handled region (inclusive) + */ + public InstructionHandle getStartPC() { + return startPc; + } + + /* + * Set start of handler + * + * @param startPc Start of handled region (inclusive) + */ + public void setStartPC(final InstructionHandle startPc) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.startPc, startPc, this); + this.startPc = startPc; + } + + @Override + public String toString() { + return "CodeExceptionGen(" + startPc + ", " + endPc + ", " + handlerPc + ")"; + } + + /** + * @param oldIh old target, either start or end + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (startPc == oldIh) { + targeted = true; + setStartPC(newIh); + } + if (endPc == oldIh) { + targeted = true; + setEndPC(newIh); + } + if (handlerPc == oldIh) { + targeted = true; + setHandlerPC(newIh); + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh + ", but {" + startPc + ", " + endPc + ", " + handlerPc + "}"); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java new file mode 100644 index 0000000..4a473f0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Wrapper class for 'compound' operations, virtual instructions that don't exist as byte code, but give a useful + * meaning. For example, the (virtual) PUSH instruction takes an arbitrary argument and produces the appropriate code at + * dump time (ICONST, LDC, BIPUSH, ...). Also you can use the SWITCH instruction as a useful template for either + * LOOKUPSWITCH or TABLESWITCH. + *

+ * The interface provides the possibility for the user to write 'templates' or 'macros' for such reusable code patterns. + * + * @see PUSH + * @see SWITCH + */ +public interface CompoundInstruction { + + InstructionList getInstructionList(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java new file mode 100644 index 0000000..99c77f8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java @@ -0,0 +1,781 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantDouble; +import com.sun.org.apache.bcel.internal.classfile.ConstantDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantFloat; +import com.sun.org.apache.bcel.internal.classfile.ConstantInteger; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantLong; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantString; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * This class is used to build up a constant pool. The user adds constants via 'addXXX' methods, 'addString', + * 'addClass', etc.. These methods return an index into the constant pool. Finally, 'getFinalConstantPool()' returns the + * constant pool built up. Intermediate versions of the constant pool can be obtained with 'getConstantPool()'. A + * constant pool has capacity for Constants.MAX_SHORT entries. Note that the first (0) is used by the JVM and that + * Double and Long constants need two slots. + * + * @LastModified: Feb 2023 + * @see Constant + */ +public class ConstantPoolGen { + + private static final int DEFAULT_BUFFER_SIZE = 256; + + private static final String METHODREF_DELIM = ":"; + + private static final String IMETHODREF_DELIM = "#"; + + private static final String FIELDREF_DELIM = "&"; + + private static final String NAT_DELIM = "%"; // Name and Type + private final Map stringTable = new HashMap<>(); + private final Map classTable = new HashMap<>(); + private final Map utf8Table = new HashMap<>(); + private final Map natTable = new HashMap<>(); + private final Map cpTable = new HashMap<>(); + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int size; + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected Constant[] constants; + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getSize() + */ + @Deprecated + protected int index = 1; // First entry (0) used by JVM + + /** + * Constructs a new empty constant pool. + */ + public ConstantPoolGen() { + size = DEFAULT_BUFFER_SIZE; + constants = new Constant[size]; + } + + /** + * Constructs a new instance with the given array of constants. + * + * @param cs array of given constants, new ones will be appended + */ + public ConstantPoolGen(final Constant[] cs) { + /* + * To be logically/programmatically correct, the size of the constant pool + * shall not exceed the size limit as the code below does a copy and then + * walk through the whole array. + * This is however, not used by XSLT (or the java.xml implementation), + * and only happens when BCELifier is called (see BCELifier). + */ + if (cs.length > Const.MAX_CP_ENTRIES) { + throw new IllegalStateException("The number of constants " + cs.length + + " is over the size limit of the constant pool: " + + Const.MAX_CP_ENTRIES); + } + + final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); + + size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), Const.MAX_CP_ENTRIES); + constants = new Constant[size]; + + System.arraycopy(cs, 0, constants, 0, cs.length); + if (cs.length > 0) { + index = cs.length; + } + + for (int i = 1; i < index; i++) { + final Constant c = constants[i]; + if (c instanceof ConstantString) { + final ConstantString s = (ConstantString) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + final String key = u8.getBytes(); + if (!stringTable.containsKey(key)) { + stringTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantClass) { + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + final String key = u8.getBytes(); + if (!classTable.containsKey(key)) { + classTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantNameAndType) { + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8NameIdx = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8SigIdx = (ConstantUtf8) constants[n.getSignatureIndex()]; + + sb.append(u8NameIdx.getBytes()); + sb.append(NAT_DELIM); + sb.append(u8SigIdx.getBytes()); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!natTable.containsKey(key)) { + natTable.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantUtf8) { + final ConstantUtf8 u = (ConstantUtf8) c; + final String key = u.getBytes(); + if (!utf8Table.containsKey(key)) { + utf8Table.put(key, Integer.valueOf(i)); + } + } else if (c instanceof ConstantCP) { + final ConstantCP m = (ConstantCP) c; + String className; + ConstantUtf8 u8; + + if (c instanceof ConstantInvokeDynamic) { + className = Integer.toString(((ConstantInvokeDynamic) m).getBootstrapMethodAttrIndex()); + } else if (c instanceof ConstantDynamic) { + className = Integer.toString(((ConstantDynamic) m).getBootstrapMethodAttrIndex()); + } else { + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + className = Utility.pathToPackage(u8.getBytes()); + } + + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String methodName = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + + // Since name cannot begin with digit, we can use METHODREF_DELIM without fear of duplicates + String delim = METHODREF_DELIM; + if (c instanceof ConstantInterfaceMethodref) { + delim = IMETHODREF_DELIM; + } else if (c instanceof ConstantFieldref) { + delim = FIELDREF_DELIM; + } + + sb.append(className); + sb.append(delim); + sb.append(methodName); + sb.append(delim); + sb.append(signature); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!cpTable.containsKey(key)) { + cpTable.put(key, Integer.valueOf(i)); + } + } +// else if (c == null) { // entries may be null +// // nothing to do +// } else if (c instanceof ConstantInteger) { +// // nothing to do +// } else if (c instanceof ConstantLong) { +// // nothing to do +// } else if (c instanceof ConstantFloat) { +// // nothing to do +// } else if (c instanceof ConstantDouble) { +// // nothing to do +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodType) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodHandle) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantModule) { +// // TODO should this be handled somehow? +// } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantPackage) { +// // TODO should this be handled somehow? +// } else { +// // Not helpful, should throw an exception. +// assert false : "Unexpected constant type: " + c.getClass().getName(); +// } + } + } + + /** + * Constructs a new instance with the given constant pool. + * + * @param cp the constant pool. + */ + public ConstantPoolGen(final ConstantPool cp) { + this(cp.getConstantPool()); + } + + /** + * Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY instruction, e.g. to the + * ConstantPool. + * + * @param type type of array class + * @return index of entry + */ + public int addArrayClass(final ArrayType type) { + return addClass_(type.getSignature()); + } + + /** + * Add a new Class reference to the ConstantPool for a given type. + * + * @param type Class to add + * @return index of entry + */ + public int addClass(final ObjectType type) { + return addClass(type.getClassName()); + } + + /** + * Add a new Class reference to the ConstantPool, if it is not already in there. + * + * @param str Class to add + * @return index of entry + */ + public int addClass(final String str) { + return addClass_(Utility.packageToPath(str)); + } + + private int addClass_(final String clazz) { + final int cpRet; + if ((cpRet = lookupClass(clazz)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final ConstantClass c = new ConstantClass(addUtf8(clazz)); + final int ret = index; + constants[index++] = c; + return computeIfAbsent(classTable, clazz, ret); + } + + /** + * Adds a constant from another ConstantPool and returns the new index. + * + * @param constant The constant to add. + * @param cpGen Source pool. + * @return index of entry + */ + public int addConstant(final Constant constant, final ConstantPoolGen cpGen) { + final Constant[] constants = cpGen.getConstantPool().getConstantPool(); + switch (constant.getTag()) { + case Const.CONSTANT_String: { + final ConstantString s = (ConstantString) constant; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + return addString(u8.getBytes()); + } + case Const.CONSTANT_Class: { + final ConstantClass s = (ConstantClass) constant; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + return addClass(u8.getBytes()); + } + case Const.CONSTANT_NameAndType: { + final ConstantNameAndType n = (ConstantNameAndType) constant; + final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; + return addNameAndType(u8.getBytes(), u8_2.getBytes()); + } + case Const.CONSTANT_Utf8: + return addUtf8(((ConstantUtf8) constant).getBytes()); + case Const.CONSTANT_Double: + return addDouble(((ConstantDouble) constant).getBytes()); + case Const.CONSTANT_Float: + return addFloat(((ConstantFloat) constant).getBytes()); + case Const.CONSTANT_Long: + return addLong(((ConstantLong) constant).getBytes()); + case Const.CONSTANT_Integer: + return addInteger(((ConstantInteger) constant).getBytes()); + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_Fieldref: { + final ConstantCP m = (ConstantCP) constant; + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + final String className = Utility.pathToPackage(u8.getBytes()); + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String name = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + switch (constant.getTag()) { + case Const.CONSTANT_InterfaceMethodref: + return addInterfaceMethodref(className, name, signature); + case Const.CONSTANT_Methodref: + return addMethodref(className, name, signature); + case Const.CONSTANT_Fieldref: + return addFieldref(className, name, signature); + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + constant); + } + } + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + constant); + } + } + + /** + * Add a new double constant to the ConstantPool, if it is not already in there. + * + * @param n Double number to add + * @return index of entry + */ + public int addDouble(final double n) { + int ret; + if ((ret = lookupDouble(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index] = new ConstantDouble(n); + index += 2; // Wastes one entry according to spec + return ret; + } + + /** + * Add a new Fieldref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param fieldName field name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addFieldref(final String className, final String fieldName, final String signature) { + final int cpRet; + if ((cpRet = lookupFieldref(className, fieldName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int classIndex = addClass(className); + final int nameAndTypeIndex = addNameAndType(fieldName, signature); + final int ret = index; + constants[index++] = new ConstantFieldref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature, ret); + } + + /** + * Add a new Float constant to the ConstantPool, if it is not already in there. + * + * @param n Float number to add + * @return index of entry + */ + public int addFloat(final float n) { + int ret; + if ((ret = lookupFloat(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index++] = new ConstantFloat(n); + return ret; + } + + /** + * Add a new Integer constant to the ConstantPool, if it is not already in there. + * + * @param n integer number to add + * @return index of entry + */ + public int addInteger(final int n) { + int ret; + if ((ret = lookupInteger(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index++] = new ConstantInteger(n); + return ret; + } + + public int addInterfaceMethodref(final MethodGen method) { + return addInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param methodName method name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addInterfaceMethodref(final String className, final String methodName, final String signature) { + final int cpRet; + if ((cpRet = lookupInterfaceMethodref(className, methodName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int classIndex = addClass(className); + final int nameAndTypeIndex = addNameAndType(methodName, signature); + final int ret = index; + constants[index++] = new ConstantInterfaceMethodref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature, ret); + } + + /** + * Add a new long constant to the ConstantPool, if it is not already in there. + * + * @param n Long number to add + * @return index of entry + */ + public int addLong(final long n) { + int ret; + if ((ret = lookupLong(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index] = new ConstantLong(n); + index += 2; // Wastes one entry according to spec + return ret; + } + + public int addMethodref(final MethodGen method) { + return addMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Add a new Methodref constant to the ConstantPool, if it is not already in there. + * + * @param className class name string to add + * @param methodName method name string to add + * @param signature method signature string to add + * @return index of entry + */ + public int addMethodref(final String className, final String methodName, final String signature) { + final int cpRet; + if ((cpRet = lookupMethodref(className, methodName, signature)) != -1) { + return cpRet; // Already in CP + } + adjustSize(); + final int nameAndTypeIndex = addNameAndType(methodName, signature); + final int classIndex = addClass(className); + final int ret = index; + constants[index++] = new ConstantMethodref(classIndex, nameAndTypeIndex); + return computeIfAbsent(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature, ret); + } + + /** + * Add a new NameAndType constant to the ConstantPool if it is not already in there. + * + * @param name Name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addNameAndType(final String name, final String signature) { + int ret; + if ((ret = lookupNameAndType(name, signature)) != -1) { + return ret; // Already in CP + } + adjustSize(); + final int nameIndex = addUtf8(name); + final int signatureIndex = addUtf8(signature); + ret = index; + constants[index++] = new ConstantNameAndType(nameIndex, signatureIndex); + return computeIfAbsent(natTable, name + NAT_DELIM + signature, ret); + } + + /** + * Add a new String constant to the ConstantPool, if it is not already in there. + * + * @param str String to add + * @return index of entry + */ + public int addString(final String str) { + int ret; + if ((ret = lookupString(str)) != -1) { + return ret; // Already in CP + } + final int utf8 = addUtf8(str); + adjustSize(); + final ConstantString s = new ConstantString(utf8); + ret = index; + constants[index++] = s; + return computeIfAbsent(stringTable, str, ret); + } + + /** + * Add a new Utf8 constant to the ConstantPool, if it is not already in there. + * + * @param n Utf8 string to add + * @return index of entry + */ + public int addUtf8(final String n) { + int ret; + if ((ret = lookupUtf8(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index++] = new ConstantUtf8(n); + return computeIfAbsent(utf8Table, n, ret); + } + + /** + * Resize internal array of constants. + */ + protected void adjustSize() { + // 3 extra spaces are needed as some entries may take 3 slots + if (index + 3 >= Const.MAX_CP_ENTRIES) { + throw new IllegalStateException("The number of constants " + (index + 3) + + " is over the size limit of the constant pool: " + + Const.MAX_CP_ENTRIES); + } + + if (index + 3 >= size) { + final Constant[] cs = constants; + size *= 2; + // the constant array shall not exceed the size of the constant pool + size = Math.min(size, Const.MAX_CP_ENTRIES); + constants = new Constant[size]; + System.arraycopy(cs, 0, constants, 0, index); + } + } + + private int computeIfAbsent(final Map map, final String key, final int value) { + return map.computeIfAbsent(key, k -> Integer.valueOf(value)); + } + + /** + * @param i index in constant pool + * @return constant pool entry at index i + */ + public Constant getConstant(final int i) { + return constants[i]; + } + + /** + * @return intermediate constant pool + */ + public ConstantPool getConstantPool() { + return new ConstantPool(constants); + } + + /** + * @return constant pool with proper length + */ + public ConstantPool getFinalConstantPool() { + return new ConstantPool(Arrays.copyOf(constants, index)); + } + + private int getIndex(final Map map, final String key) { + return toIndex(map.get(key)); + } + + /** + * @return current size of constant pool + */ + public int getSize() { + return index; + } + + /** + * Look for ConstantClass in ConstantPool named 'str'. + * + * @param str String to search for + * @return index on success, -1 otherwise + */ + public int lookupClass(final String str) { + return getIndex(classTable, Utility.packageToPath(str)); + } + + /** + * Look for ConstantDouble in ConstantPool. + * + * @param n Double number to look for + * @return index on success, -1 otherwise + */ + public int lookupDouble(final double n) { + final long bits = Double.doubleToLongBits(n); + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantDouble) { + final ConstantDouble c = (ConstantDouble) constants[i]; + if (Double.doubleToLongBits(c.getBytes()) == bits) { + return i; + } + } + } + return -1; + } + + /** + * Look for ConstantFieldref in ConstantPool. + * + * @param className Where to find method + * @param fieldName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupFieldref(final String className, final String fieldName, final String signature) { + return getIndex(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature); + } + + /** + * Look for ConstantFloat in ConstantPool. + * + * @param n Float number to look for + * @return index on success, -1 otherwise + */ + public int lookupFloat(final float n) { + final int bits = Float.floatToIntBits(n); + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantFloat) { + final ConstantFloat c = (ConstantFloat) constants[i]; + if (Float.floatToIntBits(c.getBytes()) == bits) { + return i; + } + } + } + return -1; + } + + /** + * Look for ConstantInteger in ConstantPool. + * + * @param n integer number to look for + * @return index on success, -1 otherwise + */ + public int lookupInteger(final int n) { + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantInteger) { + final ConstantInteger c = (ConstantInteger) constants[i]; + if (c.getBytes() == n) { + return i; + } + } + } + return -1; + } + + public int lookupInterfaceMethodref(final MethodGen method) { + return lookupInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Look for ConstantInterfaceMethodref in ConstantPool. + * + * @param className Where to find method + * @param methodName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupInterfaceMethodref(final String className, final String methodName, final String signature) { + return getIndex(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature); + } + + /** + * Look for ConstantLong in ConstantPool. + * + * @param n Long number to look for + * @return index on success, -1 otherwise + */ + public int lookupLong(final long n) { + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantLong) { + final ConstantLong c = (ConstantLong) constants[i]; + if (c.getBytes() == n) { + return i; + } + } + } + return -1; + } + + public int lookupMethodref(final MethodGen method) { + return lookupMethodref(method.getClassName(), method.getName(), method.getSignature()); + } + + /** + * Look for ConstantMethodref in ConstantPool. + * + * @param className Where to find method + * @param methodName Guess what + * @param signature return and argument types + * @return index on success, -1 otherwise + */ + public int lookupMethodref(final String className, final String methodName, final String signature) { + return getIndex(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature); + } + + /** + * Look for ConstantNameAndType in ConstantPool. + * + * @param name of variable/method + * @param signature of variable/method + * @return index on success, -1 otherwise + */ + public int lookupNameAndType(final String name, final String signature) { + return getIndex(natTable, name + NAT_DELIM + signature); + } + + /** + * Look for ConstantString in ConstantPool containing String 'str'. + * + * @param str String to search for + * @return index on success, -1 otherwise + */ + public int lookupString(final String str) { + return getIndex(stringTable, str); + } + + /** + * Look for ConstantUtf8 in ConstantPool. + * + * @param n Utf8 string to look for + * @return index on success, -1 otherwise + */ + public int lookupUtf8(final String n) { + return getIndex(utf8Table, n); + } + + /** + * Use with care! + * + * @param i index in constant pool + * @param c new constant pool entry at index i + */ + public void setConstant(final int i, final Constant c) { + constants[i] = c; + } + + private int toIndex(final Integer index) { + return index != null ? index.intValue() : -1; + } + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 1; i < index; i++) { + buf.append(i).append(")").append(constants[i]).append("\n"); + } + return buf.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java new file mode 100644 index 0000000..203df25 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes a push instruction that produces a literal on the stack such as SIPUSH, BIPUSH, ICONST, etc. + * + * @see ICONST + * @see SIPUSH + */ +public interface ConstantPushInstruction extends PushInstruction, TypedInstruction { + + Number getValue(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java new file mode 100644 index 0000000..ab146ba --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java @@ -0,0 +1,77 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Super class for the x2y family of instructions. + */ +public abstract class ConversionInstruction extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ConversionInstruction() { + } + + /** + * @param opcode opcode of instruction + */ + protected ConversionInstruction(final short opcode) { + super(opcode, (short) 1); + } + + /** + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + final short opcode = super.getOpcode(); + switch (opcode) { + case Const.D2I: + case Const.F2I: + case Const.L2I: + return Type.INT; + case Const.D2F: + case Const.I2F: + case Const.L2F: + return Type.FLOAT; + case Const.D2L: + case Const.F2L: + case Const.I2L: + return Type.LONG; + case Const.F2D: + case Const.I2D: + case Const.L2D: + return Type.DOUBLE; + case Const.I2B: + return Type.BYTE; + case Const.I2C: + return Type.CHAR; + case Const.I2S: + return Type.SHORT; + default: // Never reached + throw new ClassGenException("Unknown type " + opcode); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java new file mode 100644 index 0000000..45ee715 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2F.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2F - Convert double to float + * + *

+ * Stack: ..., value.word1, value.word2 -> ..., result
+ * 
+ */ +public class D2F extends ConversionInstruction { + + /** + * Convert double to float + */ + public D2F() { + super(com.sun.org.apache.bcel.internal.Const.D2F); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2F(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java new file mode 100644 index 0000000..343076d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2I.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2I - Convert double to int + * + *
+ * Stack: ..., value.word1, value.word2 -> ..., result
+ * 
+ */ +public class D2I extends ConversionInstruction { + + /** + * Convert double to int + */ + public D2I() { + super(com.sun.org.apache.bcel.internal.Const.D2I); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2I(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java new file mode 100644 index 0000000..0a8b09c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/D2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * D2L - Convert double to long + * + *
+ * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
+ * 
+ */ +public class D2L extends ConversionInstruction { + + /** + * Convert double to long + */ + public D2L() { + super(com.sun.org.apache.bcel.internal.Const.D2L); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2L(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java new file mode 100644 index 0000000..60bc4aa --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DADD.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DADD - Add doubles + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result1.word2 + */ +public class DADD extends ArithmeticInstruction { + + /** + * Add doubles + */ + public DADD() { + super(com.sun.org.apache.bcel.internal.Const.DADD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDADD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java new file mode 100644 index 0000000..e875b35 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DALOAD - Load double from array + * + *

+ * Stack: ..., arrayref, index -> ..., result.word1, result.word2
+ * 
+ */ +public class DALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load double from array + */ + public DALOAD() { + super(com.sun.org.apache.bcel.internal.Const.DALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java new file mode 100644 index 0000000..63a8559 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DASTORE - Store into double array + * + *
+ * Stack: ..., arrayref, index, value.word1, value.word2 -> ...
+ * 
+ */ +public class DASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store double into array + */ + public DASTORE() { + super(com.sun.org.apache.bcel.internal.Const.DASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java new file mode 100644 index 0000000..aa1353e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPG.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCMPG - Compare doubles: value1 > value2 + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
+ * 
+ */ +public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPG() { + super(com.sun.org.apache.bcel.internal.Const.DCMPG, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPG(this); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java new file mode 100644 index 0000000..b43380b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCMPL.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCMPL - Compare doubles: value1 < value2 + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
+ * 
+ */ +public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPL() { + super(com.sun.org.apache.bcel.internal.Const.DCMPL, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPL(this); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java new file mode 100644 index 0000000..9842dba --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DCONST.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DCONST - Push 0.0 or 1.0, other values cause an exception + * + *
+ * Stack: ... -> ...,
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class DCONST extends Instruction implements ConstantPushInstruction { + + private final double value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DCONST() { + this(0); + } + + public DCONST(final double f) { + super(com.sun.org.apache.bcel.internal.Const.DCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.DCONST_0); + } else if (f == 1.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.DCONST_1); + } else { + throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); + } + value = f; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitDCONST(this); + } + + /** + * @return Type.DOUBLE + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.DOUBLE; + } + + @Override + public Number getValue() { + return Double.valueOf(value); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java new file mode 100644 index 0000000..2528705 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DDIV.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DDIV - Divide doubles + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class DDIV extends ArithmeticInstruction { + + /** + * Divide doubles + */ + public DDIV() { + super(com.sun.org.apache.bcel.internal.Const.DDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDDIV(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java new file mode 100644 index 0000000..9b61fd6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DLOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DLOAD - Load double from local variable + * + *

+ * Stack ... -> ..., result.word1, result.word2
+ * 
+ */ +public class DLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DLOAD() { + super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.Const.DLOAD_0); + } + + /** + * Load double from local variable + * + * @param n index of local variable + */ + public DLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.Const.DLOAD_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitDLOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java new file mode 100644 index 0000000..f9cc67c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DMUL.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DMUL - Multiply doubles + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class DMUL extends ArithmeticInstruction { + + /** + * Multiply doubles + */ + public DMUL() { + super(com.sun.org.apache.bcel.internal.Const.DMUL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDMUL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java new file mode 100644 index 0000000..8999f6f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DNEG - Negate double + * + *

+ * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
+ * 
+ */ +public class DNEG extends ArithmeticInstruction { + + public DNEG() { + super(com.sun.org.apache.bcel.internal.Const.DNEG); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDNEG(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java new file mode 100644 index 0000000..8f7e393 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DREM.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DREM - Remainder of doubles + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class DREM extends ArithmeticInstruction { + + /** + * Remainder of doubles + */ + public DREM() { + super(com.sun.org.apache.bcel.internal.Const.DREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDREM(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java new file mode 100644 index 0000000..749d922 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DRETURN - Return double from method + * + *

+ * Stack: ..., value.word1, value.word2 -> <empty>
+ * 
+ */ +public class DRETURN extends ReturnInstruction { + + /** + * Return double from method + */ + public DRETURN() { + super(com.sun.org.apache.bcel.internal.Const.DRETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitDRETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java new file mode 100644 index 0000000..bd4e130 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DSTORE - Store double into local variable + * + *
+ * Stack: ..., value.word1, value.word2 -> ...
+ * 
+ */ +public class DSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + DSTORE() { + super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.Const.DSTORE_0); + } + + /** + * Store double into local variable + * + * @param n index of local variable + */ + public DSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.Const.DSTORE_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitDSTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java new file mode 100644 index 0000000..1955537 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DSUB.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DSUB - Substract doubles + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class DSUB extends ArithmeticInstruction { + + /** + * Substract doubles + */ + public DSUB() { + super(com.sun.org.apache.bcel.internal.Const.DSUB); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDSUB(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java new file mode 100644 index 0000000..30cc682 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP - Duplicate top operand stack word + * + *

+ * Stack: ..., word -> ..., word, word
+ * 
+ */ +public class DUP extends StackInstruction implements PushInstruction { + + public DUP() { + super(com.sun.org.apache.bcel.internal.Const.DUP); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java new file mode 100644 index 0000000..8b01a06 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2 - Duplicate two top operand stack words + * + *
+ * Stack: ..., word2, word1 -> ..., word2, word1, word2, word1
+ * 
+ */ +public class DUP2 extends StackInstruction implements PushInstruction { + + public DUP2() { + super(com.sun.org.apache.bcel.internal.Const.DUP2); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP2(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java new file mode 100644 index 0000000..69043ab --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2_X1 - Duplicate two top operand stack words and put three down + * + *
+ * Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1
+ * 
+ */ +public class DUP2_X1 extends StackInstruction { + + public DUP2_X1() { + super(com.sun.org.apache.bcel.internal.Const.DUP2_X1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackInstruction(this); + v.visitDUP2_X1(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java new file mode 100644 index 0000000..e9b807f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP2_X2 - Duplicate two top operand stack words and put four down + * + *
+ * Stack: ..., word4, word3, word2, word1 -> ..., word2, word1, word4, word3, word2, word1
+ * 
+ */ +public class DUP2_X2 extends StackInstruction { + + public DUP2_X2() { + super(com.sun.org.apache.bcel.internal.Const.DUP2_X2); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackInstruction(this); + v.visitDUP2_X2(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java new file mode 100644 index 0000000..ce2316b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X1.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP_X1 - Duplicate top operand stack word and put two down + * + *
+ * Stack: ..., word2, word1 -> ..., word1, word2, word1
+ * 
+ */ +public class DUP_X1 extends StackInstruction { + + public DUP_X1() { + super(com.sun.org.apache.bcel.internal.Const.DUP_X1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackInstruction(this); + v.visitDUP_X1(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java new file mode 100644 index 0000000..735437e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/DUP_X2.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * DUP_X2 - Duplicate top operand stack word and put three down + * + *
+ * Stack: ..., word3, word2, word1 -> ..., word1, word3, word2, word1
+ * 
+ */ +public class DUP_X2 extends StackInstruction { + + public DUP_X2() { + super(com.sun.org.apache.bcel.internal.Const.DUP_X2); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackInstruction(this); + v.visitDUP_X2(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java new file mode 100644 index 0000000..4938c03 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.AnnotationElementValue; +import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.ArrayElementValue; +import com.sun.org.apache.bcel.internal.classfile.ClassElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.EnumElementValue; +import com.sun.org.apache.bcel.internal.classfile.SimpleElementValue; + +/** + * @LastModified: May 2021 + * @since 6.0 + */ +public abstract class ElementValueGen { + public static final int STRING = 's'; + + public static final int ENUM_CONSTANT = 'e'; + + public static final int CLASS = 'c'; + + public static final int ANNOTATION = '@'; + + public static final int ARRAY = '['; + + public static final int PRIMITIVE_INT = 'I'; + + public static final int PRIMITIVE_BYTE = 'B'; + + public static final int PRIMITIVE_CHAR = 'C'; + + public static final int PRIMITIVE_DOUBLE = 'D'; + + public static final int PRIMITIVE_FLOAT = 'F'; + + public static final int PRIMITIVE_LONG = 'J'; + + public static final int PRIMITIVE_SHORT = 'S'; + + public static final int PRIMITIVE_BOOLEAN = 'Z'; + + /** + * Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct. + */ + public static ElementValueGen copy(final ElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + switch (value.getElementValueType()) { + case 'B': // byte + case 'C': // char + case 'D': // double + case 'F': // float + case 'I': // int + case 'J': // long + case 'S': // short + case 'Z': // boolean + case 's': // String + return new SimpleElementValueGen((SimpleElementValue) value, cpool, copyPoolEntries); + case 'e': // Enum constant + return new EnumElementValueGen((EnumElementValue) value, cpool, copyPoolEntries); + case '@': // Annotation + return new AnnotationElementValueGen((AnnotationElementValue) value, cpool, copyPoolEntries); + case '[': // Array + return new ArrayElementValueGen((ArrayElementValue) value, cpool, copyPoolEntries); + case 'c': // Class + return new ClassElementValueGen((ClassElementValue) value, cpool, copyPoolEntries); + default: + throw new UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")"); + } + } + + public static ElementValueGen readElementValue(final DataInput dis, final ConstantPoolGen cpGen) throws IOException { + final int type = dis.readUnsignedByte(); + switch (type) { + case 'B': // byte + return new SimpleElementValueGen(PRIMITIVE_BYTE, dis.readUnsignedShort(), cpGen); + case 'C': // char + return new SimpleElementValueGen(PRIMITIVE_CHAR, dis.readUnsignedShort(), cpGen); + case 'D': // double + return new SimpleElementValueGen(PRIMITIVE_DOUBLE, dis.readUnsignedShort(), cpGen); + case 'F': // float + return new SimpleElementValueGen(PRIMITIVE_FLOAT, dis.readUnsignedShort(), cpGen); + case 'I': // int + return new SimpleElementValueGen(PRIMITIVE_INT, dis.readUnsignedShort(), cpGen); + case 'J': // long + return new SimpleElementValueGen(PRIMITIVE_LONG, dis.readUnsignedShort(), cpGen); + case 'S': // short + return new SimpleElementValueGen(PRIMITIVE_SHORT, dis.readUnsignedShort(), cpGen); + case 'Z': // boolean + return new SimpleElementValueGen(PRIMITIVE_BOOLEAN, dis.readUnsignedShort(), cpGen); + case 's': // String + return new SimpleElementValueGen(STRING, dis.readUnsignedShort(), cpGen); + case 'e': // Enum constant + return new EnumElementValueGen(dis.readUnsignedShort(), dis.readUnsignedShort(), cpGen); + case 'c': // Class + return new ClassElementValueGen(dis.readUnsignedShort(), cpGen); + case '@': // Annotation + // TODO: isRuntimeVisible ?????????? + // FIXME + return new AnnotationElementValueGen(ANNOTATION, new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen.getConstantPool(), true), cpGen, false), + cpGen); + case '[': // Array + final int numArrayVals = dis.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; + for (int j = 0; j < numArrayVals; j++) { + evalues[j] = ElementValue.readElementValue(dis, cpGen.getConstantPool()); + } + return new ArrayElementValueGen(ARRAY, evalues, cpGen); + default: + throw new IllegalArgumentException("Unexpected element value kind in annotation: " + type); + } + } + + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @Deprecated + protected int type; + + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @Deprecated + protected ConstantPoolGen cpGen; + + protected ElementValueGen(final int type, final ConstantPoolGen cpGen) { + this.type = type; + this.cpGen = cpGen; + } + + public abstract void dump(DataOutputStream dos) throws IOException; + + protected ConstantPoolGen getConstantPool() { + return cpGen; + } + + /** + * Subtypes return an immutable variant of the ElementValueGen + */ + public abstract ElementValue getElementValue(); + + public int getElementValueType() { + return type; + } + + public abstract String stringifyValue(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java new file mode 100644 index 0000000..bdc9c51 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.ElementValuePair; + +/** + * @since 6.0 + */ +public class ElementValuePairGen { + private final int nameIdx; + + private final ElementValueGen value; + + private final ConstantPoolGen constantPoolGen; + + public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + this.constantPoolGen = cpool; + // J5ASSERT: + // Could assert nvp.getNameString() points to the same thing as + // constantPoolGen.getConstant(nvp.getNameIndex()) + // if + // (!nvp.getNameString().equals(((ConstantUtf8)constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) + // { + // throw new IllegalArgumentException("envp buggered"); + // } + if (copyPoolEntries) { + nameIdx = cpool.addUtf8(nvp.getNameString()); + } else { + nameIdx = nvp.getNameIndex(); + } + value = ElementValueGen.copy(nvp.getValue(), cpool, copyPoolEntries); + } + + protected ElementValuePairGen(final int idx, final ElementValueGen value, final ConstantPoolGen cpool) { + this.nameIdx = idx; + this.value = value; + this.constantPoolGen = cpool; + } + + public ElementValuePairGen(final String name, final ElementValueGen value, final ConstantPoolGen cpool) { + this.nameIdx = cpool.addUtf8(name); + this.value = value; + this.constantPoolGen = cpool; + } + + protected void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(nameIdx); // u2 name of the element + value.dump(dos); + } + + /** + * Retrieve an immutable version of this ElementNameValuePairGen + */ + public ElementValuePair getElementNameValuePair() { + final ElementValue immutableValue = value.getElementValue(); + return new ElementValuePair(nameIdx, immutableValue, constantPoolGen.getConstantPool()); + } + + public int getNameIndex() { + return nameIdx; + } + + public final String getNameString() { + // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx); + return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes(); + } + + public final ElementValueGen getValue() { + return value; + } + + @Override + public String toString() { + return "ElementValuePair:[" + getNameString() + "=" + value.stringifyValue() + "]"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java new file mode 100644 index 0000000..b769444 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java @@ -0,0 +1,755 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Supplies empty method bodies to be overridden by subclasses. + */ +public abstract class EmptyVisitor implements Visitor { + + @Override + public void visitAALOAD(final AALOAD obj) { + } + + @Override + public void visitAASTORE(final AASTORE obj) { + } + + @Override + public void visitACONST_NULL(final ACONST_NULL obj) { + } + + @Override + public void visitAllocationInstruction(final AllocationInstruction obj) { + } + + @Override + public void visitALOAD(final ALOAD obj) { + } + + @Override + public void visitANEWARRAY(final ANEWARRAY obj) { + } + + @Override + public void visitARETURN(final ARETURN obj) { + } + + @Override + public void visitArithmeticInstruction(final ArithmeticInstruction obj) { + } + + @Override + public void visitArrayInstruction(final ArrayInstruction obj) { + } + + @Override + public void visitARRAYLENGTH(final ARRAYLENGTH obj) { + } + + @Override + public void visitASTORE(final ASTORE obj) { + } + + @Override + public void visitATHROW(final ATHROW obj) { + } + + @Override + public void visitBALOAD(final BALOAD obj) { + } + + @Override + public void visitBASTORE(final BASTORE obj) { + } + + @Override + public void visitBIPUSH(final BIPUSH obj) { + } + + @Override + public void visitBranchInstruction(final BranchInstruction obj) { + } + + @Override + public void visitBREAKPOINT(final BREAKPOINT obj) { + } + + @Override + public void visitCALOAD(final CALOAD obj) { + } + + @Override + public void visitCASTORE(final CASTORE obj) { + } + + @Override + public void visitCHECKCAST(final CHECKCAST obj) { + } + + @Override + public void visitConstantPushInstruction(final ConstantPushInstruction obj) { + } + + @Override + public void visitConversionInstruction(final ConversionInstruction obj) { + } + + @Override + public void visitCPInstruction(final CPInstruction obj) { + } + + @Override + public void visitD2F(final D2F obj) { + } + + @Override + public void visitD2I(final D2I obj) { + } + + @Override + public void visitD2L(final D2L obj) { + } + + @Override + public void visitDADD(final DADD obj) { + } + + @Override + public void visitDALOAD(final DALOAD obj) { + } + + @Override + public void visitDASTORE(final DASTORE obj) { + } + + @Override + public void visitDCMPG(final DCMPG obj) { + } + + @Override + public void visitDCMPL(final DCMPL obj) { + } + + @Override + public void visitDCONST(final DCONST obj) { + } + + @Override + public void visitDDIV(final DDIV obj) { + } + + @Override + public void visitDLOAD(final DLOAD obj) { + } + + @Override + public void visitDMUL(final DMUL obj) { + } + + @Override + public void visitDNEG(final DNEG obj) { + } + + @Override + public void visitDREM(final DREM obj) { + } + + @Override + public void visitDRETURN(final DRETURN obj) { + } + + @Override + public void visitDSTORE(final DSTORE obj) { + } + + @Override + public void visitDSUB(final DSUB obj) { + } + + @Override + public void visitDUP(final DUP obj) { + } + + @Override + public void visitDUP_X1(final DUP_X1 obj) { + } + + @Override + public void visitDUP_X2(final DUP_X2 obj) { + } + + @Override + public void visitDUP2(final DUP2 obj) { + } + + @Override + public void visitDUP2_X1(final DUP2_X1 obj) { + } + + @Override + public void visitDUP2_X2(final DUP2_X2 obj) { + } + + @Override + public void visitExceptionThrower(final ExceptionThrower obj) { + } + + @Override + public void visitF2D(final F2D obj) { + } + + @Override + public void visitF2I(final F2I obj) { + } + + @Override + public void visitF2L(final F2L obj) { + } + + @Override + public void visitFADD(final FADD obj) { + } + + @Override + public void visitFALOAD(final FALOAD obj) { + } + + @Override + public void visitFASTORE(final FASTORE obj) { + } + + @Override + public void visitFCMPG(final FCMPG obj) { + } + + @Override + public void visitFCMPL(final FCMPL obj) { + } + + @Override + public void visitFCONST(final FCONST obj) { + } + + @Override + public void visitFDIV(final FDIV obj) { + } + + @Override + public void visitFieldInstruction(final FieldInstruction obj) { + } + + @Override + public void visitFieldOrMethod(final FieldOrMethod obj) { + } + + @Override + public void visitFLOAD(final FLOAD obj) { + } + + @Override + public void visitFMUL(final FMUL obj) { + } + + @Override + public void visitFNEG(final FNEG obj) { + } + + @Override + public void visitFREM(final FREM obj) { + } + + @Override + public void visitFRETURN(final FRETURN obj) { + } + + @Override + public void visitFSTORE(final FSTORE obj) { + } + + @Override + public void visitFSUB(final FSUB obj) { + } + + @Override + public void visitGETFIELD(final GETFIELD obj) { + } + + @Override + public void visitGETSTATIC(final GETSTATIC obj) { + } + + @Override + public void visitGOTO(final GOTO obj) { + } + + @Override + public void visitGOTO_W(final GOTO_W obj) { + } + + @Override + public void visitGotoInstruction(final GotoInstruction obj) { + } + + @Override + public void visitI2B(final I2B obj) { + } + + @Override + public void visitI2C(final I2C obj) { + } + + @Override + public void visitI2D(final I2D obj) { + } + + @Override + public void visitI2F(final I2F obj) { + } + + @Override + public void visitI2L(final I2L obj) { + } + + @Override + public void visitI2S(final I2S obj) { + } + + @Override + public void visitIADD(final IADD obj) { + } + + @Override + public void visitIALOAD(final IALOAD obj) { + } + + @Override + public void visitIAND(final IAND obj) { + } + + @Override + public void visitIASTORE(final IASTORE obj) { + } + + @Override + public void visitICONST(final ICONST obj) { + } + + @Override + public void visitIDIV(final IDIV obj) { + } + + @Override + public void visitIF_ACMPEQ(final IF_ACMPEQ obj) { + } + + @Override + public void visitIF_ACMPNE(final IF_ACMPNE obj) { + } + + @Override + public void visitIF_ICMPEQ(final IF_ICMPEQ obj) { + } + + @Override + public void visitIF_ICMPGE(final IF_ICMPGE obj) { + } + + @Override + public void visitIF_ICMPGT(final IF_ICMPGT obj) { + } + + @Override + public void visitIF_ICMPLE(final IF_ICMPLE obj) { + } + + @Override + public void visitIF_ICMPLT(final IF_ICMPLT obj) { + } + + @Override + public void visitIF_ICMPNE(final IF_ICMPNE obj) { + } + + @Override + public void visitIFEQ(final IFEQ obj) { + } + + @Override + public void visitIFGE(final IFGE obj) { + } + + @Override + public void visitIFGT(final IFGT obj) { + } + + @Override + public void visitIfInstruction(final IfInstruction obj) { + } + + @Override + public void visitIFLE(final IFLE obj) { + } + + @Override + public void visitIFLT(final IFLT obj) { + } + + @Override + public void visitIFNE(final IFNE obj) { + } + + @Override + public void visitIFNONNULL(final IFNONNULL obj) { + } + + @Override + public void visitIFNULL(final IFNULL obj) { + } + + @Override + public void visitIINC(final IINC obj) { + } + + @Override + public void visitILOAD(final ILOAD obj) { + } + + @Override + public void visitIMPDEP1(final IMPDEP1 obj) { + } + + @Override + public void visitIMPDEP2(final IMPDEP2 obj) { + } + + @Override + public void visitIMUL(final IMUL obj) { + } + + @Override + public void visitINEG(final INEG obj) { + } + + @Override + public void visitINSTANCEOF(final INSTANCEOF obj) { + } + + /** + * @since 6.0 + */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC obj) { + } + + @Override + public void visitInvokeInstruction(final InvokeInstruction obj) { + } + + @Override + public void visitINVOKEINTERFACE(final INVOKEINTERFACE obj) { + } + + @Override + public void visitINVOKESPECIAL(final INVOKESPECIAL obj) { + } + + @Override + public void visitINVOKESTATIC(final INVOKESTATIC obj) { + } + + @Override + public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL obj) { + } + + @Override + public void visitIOR(final IOR obj) { + } + + @Override + public void visitIREM(final IREM obj) { + } + + @Override + public void visitIRETURN(final IRETURN obj) { + } + + @Override + public void visitISHL(final ISHL obj) { + } + + @Override + public void visitISHR(final ISHR obj) { + } + + @Override + public void visitISTORE(final ISTORE obj) { + } + + @Override + public void visitISUB(final ISUB obj) { + } + + @Override + public void visitIUSHR(final IUSHR obj) { + } + + @Override + public void visitIXOR(final IXOR obj) { + } + + @Override + public void visitJSR(final JSR obj) { + } + + @Override + public void visitJSR_W(final JSR_W obj) { + } + + @Override + public void visitJsrInstruction(final JsrInstruction obj) { + } + + @Override + public void visitL2D(final L2D obj) { + } + + @Override + public void visitL2F(final L2F obj) { + } + + @Override + public void visitL2I(final L2I obj) { + } + + @Override + public void visitLADD(final LADD obj) { + } + + @Override + public void visitLALOAD(final LALOAD obj) { + } + + @Override + public void visitLAND(final LAND obj) { + } + + @Override + public void visitLASTORE(final LASTORE obj) { + } + + @Override + public void visitLCMP(final LCMP obj) { + } + + @Override + public void visitLCONST(final LCONST obj) { + } + + @Override + public void visitLDC(final LDC obj) { + } + + @Override + public void visitLDC2_W(final LDC2_W obj) { + } + + @Override + public void visitLDIV(final LDIV obj) { + } + + @Override + public void visitLLOAD(final LLOAD obj) { + } + + @Override + public void visitLMUL(final LMUL obj) { + } + + @Override + public void visitLNEG(final LNEG obj) { + } + + @Override + public void visitLoadClass(final LoadClass obj) { + } + + @Override + public void visitLoadInstruction(final LoadInstruction obj) { + } + + @Override + public void visitLocalVariableInstruction(final LocalVariableInstruction obj) { + } + + @Override + public void visitLOOKUPSWITCH(final LOOKUPSWITCH obj) { + } + + @Override + public void visitLOR(final LOR obj) { + } + + @Override + public void visitLREM(final LREM obj) { + } + + @Override + public void visitLRETURN(final LRETURN obj) { + } + + @Override + public void visitLSHL(final LSHL obj) { + } + + @Override + public void visitLSHR(final LSHR obj) { + } + + @Override + public void visitLSTORE(final LSTORE obj) { + } + + @Override + public void visitLSUB(final LSUB obj) { + } + + @Override + public void visitLUSHR(final LUSHR obj) { + } + + @Override + public void visitLXOR(final LXOR obj) { + } + + @Override + public void visitMONITORENTER(final MONITORENTER obj) { + } + + @Override + public void visitMONITOREXIT(final MONITOREXIT obj) { + } + + @Override + public void visitMULTIANEWARRAY(final MULTIANEWARRAY obj) { + } + + @Override + public void visitNEW(final NEW obj) { + } + + @Override + public void visitNEWARRAY(final NEWARRAY obj) { + } + + @Override + public void visitNOP(final NOP obj) { + } + + @Override + public void visitPOP(final POP obj) { + } + + @Override + public void visitPOP2(final POP2 obj) { + } + + @Override + public void visitPopInstruction(final PopInstruction obj) { + } + + @Override + public void visitPushInstruction(final PushInstruction obj) { + } + + @Override + public void visitPUTFIELD(final PUTFIELD obj) { + } + + @Override + public void visitPUTSTATIC(final PUTSTATIC obj) { + } + + @Override + public void visitRET(final RET obj) { + } + + @Override + public void visitRETURN(final RETURN obj) { + } + + @Override + public void visitReturnInstruction(final ReturnInstruction obj) { + } + + @Override + public void visitSALOAD(final SALOAD obj) { + } + + @Override + public void visitSASTORE(final SASTORE obj) { + } + + @Override + public void visitSelect(final Select obj) { + } + + @Override + public void visitSIPUSH(final SIPUSH obj) { + } + + @Override + public void visitStackConsumer(final StackConsumer obj) { + } + + @Override + public void visitStackInstruction(final StackInstruction obj) { + } + + @Override + public void visitStackProducer(final StackProducer obj) { + } + + @Override + public void visitStoreInstruction(final StoreInstruction obj) { + } + + @Override + public void visitSWAP(final SWAP obj) { + } + + @Override + public void visitTABLESWITCH(final TABLESWITCH obj) { + } + + @Override + public void visitTypedInstruction(final TypedInstruction obj) { + } + + @Override + public void visitUnconditionalBranch(final UnconditionalBranch obj) { + } + + @Override + public void visitVariableLengthInstruction(final VariableLengthInstruction obj) { + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java new file mode 100644 index 0000000..618c5fb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java @@ -0,0 +1,125 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.EnumElementValue; + +/** + * @since 6.0 + */ +public class EnumElementValueGen extends ElementValueGen { + // For enum types, these two indices point to the type and value + private final int typeIdx; + + private final int valueIdx; + + public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(ENUM_CONSTANT, cpool); + if (copyPoolEntries) { + typeIdx = cpool.addUtf8(value.getEnumTypeString());// was + // addClass(value.getEnumTypeString()); + valueIdx = cpool.addUtf8(value.getEnumValueString()); // was + // addString(value.getEnumValueString()); + } else { + typeIdx = value.getTypeIndex(); + valueIdx = value.getValueIndex(); + } + } + + /** + * This ctor assumes the constant pool already contains the right type and value - as indicated by typeIdx and valueIdx. + * This ctor is used for deserialization + */ + protected EnumElementValueGen(final int typeIdx, final int valueIdx, final ConstantPoolGen cpool) { + super(ElementValueGen.ENUM_CONSTANT, cpool); + if (super.getElementValueType() != ENUM_CONSTANT) { + throw new IllegalArgumentException("Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType()); + } + this.typeIdx = typeIdx; + this.valueIdx = valueIdx; + } + + public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool) { + super(ElementValueGen.ENUM_CONSTANT, cpool); + typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t); + valueIdx = cpool.addUtf8(value);// was addString(value); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 type of value (ENUM_CONSTANT == 'e') + dos.writeShort(typeIdx); // u2 + dos.writeShort(valueIdx); // u2 + } + + /** + * Return immutable variant of this EnumElementValue + */ + @Override + public ElementValue getElementValue() { + System.err.println("Duplicating value: " + getEnumTypeString() + ":" + getEnumValueString()); + return new EnumElementValue(super.getElementValueType(), typeIdx, valueIdx, getConstantPool().getConstantPool()); + } + + // BCELBUG: Should we need to call utility.signatureToString() on the output + // here? + public String getEnumTypeString() { + // Constant cc = getConstantPool().getConstant(typeIdx); + // ConstantClass cu8 = + // (ConstantClass)getConstantPool().getConstant(typeIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes(); + return ((ConstantUtf8) getConstantPool().getConstant(typeIdx)).getBytes(); + // return Utility.signatureToString(cu8.getBytes()); + } + + public String getEnumValueString() { + return ((ConstantUtf8) getConstantPool().getConstant(valueIdx)).getBytes(); + // ConstantString cu8 = + // (ConstantString)getConstantPool().getConstant(valueIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + } + + public int getTypeIndex() { + return typeIdx; + } + + public int getValueIndex() { + return valueIdx; + } + + @Override + public String stringifyValue() { + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx); + return cu8.getBytes(); + // ConstantString cu8 = + // (ConstantString)getConstantPool().getConstant(valueIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java new file mode 100644 index 0000000..d4c1164 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote an instruction that may throw a run-time or a linking exception (or both) during execution. This is not quite + * the truth as such; because all instructions may throw an java.lang.VirtualMachineError. These exceptions are omitted. + *

+ * The Lava Language Specification specifies exactly which RUN-TIME and which LINKING exceptions each + * instruction may throw which is reflected by the implementers. Due to the structure of the JVM specification, it may + * be possible that an Instruction implementing this interface returns a Class[] of size 0. + *

+ * Please note that we speak of an "exception" here when we mean any "Throwable" object; so this term is equally used + * for "Exception" and "Error" objects. + */ +public interface ExceptionThrower { + + Class[] getExceptions(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java new file mode 100644 index 0000000..3697ae3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2D.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2D - Convert float to double + * + *

+ * Stack: ..., value -> ..., result.word1, result.word2
+ * 
+ */ +public class F2D extends ConversionInstruction { + + /** + * Convert float to double + */ + public F2D() { + super(com.sun.org.apache.bcel.internal.Const.F2D); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2D(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java new file mode 100644 index 0000000..552ab17 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2I.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2I - Convert float to int + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class F2I extends ConversionInstruction { + + /** + * Convert float to int + */ + public F2I() { + super(com.sun.org.apache.bcel.internal.Const.F2I); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2I(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java new file mode 100644 index 0000000..73b4edf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/F2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * F2L - Convert float to long + * + *
+ * Stack: ..., value -> ..., result.word1, result.word2
+ * 
+ */ +public class F2L extends ConversionInstruction { + + /** + * Convert float to long + */ + public F2L() { + super(com.sun.org.apache.bcel.internal.Const.F2L); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2L(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java new file mode 100644 index 0000000..a1e4e46 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FADD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FADD - Add floats + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class FADD extends ArithmeticInstruction { + + /** + * Add floats + */ + public FADD() { + super(com.sun.org.apache.bcel.internal.Const.FADD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFADD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java new file mode 100644 index 0000000..7d00b4c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FALOAD - Load float from array + * + *
+ * Stack: ..., arrayref, index -> ..., value
+ * 
+ */ +public class FALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load float from array + */ + public FALOAD() { + super(com.sun.org.apache.bcel.internal.Const.FALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java new file mode 100644 index 0000000..0215fd7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FASTORE - Store into float array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class FASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store float into array + */ + public FASTORE() { + super(com.sun.org.apache.bcel.internal.Const.FASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java new file mode 100644 index 0000000..bbeb1e2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPG.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCMPG - Compare floats: value1 > value2 + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPG() { + super(com.sun.org.apache.bcel.internal.Const.FCMPG, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPG(this); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java new file mode 100644 index 0000000..0b7cec0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCMPL.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCMPL - Compare floats: value1 < value2 + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPL() { + super(com.sun.org.apache.bcel.internal.Const.FCMPL, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPL(this); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java new file mode 100644 index 0000000..fcd6f6d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FCONST.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception + * + *
+ * Stack: ... -> ...,
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class FCONST extends Instruction implements ConstantPushInstruction { + + private final float value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FCONST() { + this(0); + } + + public FCONST(final float f) { + super(com.sun.org.apache.bcel.internal.Const.FCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_0); + } else if (f == 1.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_1); + } else if (f == 2.0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_2); + } else { + throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); + } + value = f; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitFCONST(this); + } + + /** + * @return Type.FLOAT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.FLOAT; + } + + @Override + public Number getValue() { + return Float.valueOf(value); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java new file mode 100644 index 0000000..010c9d9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FDIV.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FDIV - Divide floats + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class FDIV extends ArithmeticInstruction { + + /** + * Divide floats + */ + public FDIV() { + super(com.sun.org.apache.bcel.internal.Const.FDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFDIV(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java new file mode 100644 index 0000000..e8abc13 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FLOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FLOAD - Load float from local variable + * + *
+ * Stack ... -> ..., result
+ * 
+ */ +public class FLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FLOAD() { + super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.Const.FLOAD_0); + } + + /** + * Load float from local variable + * + * @param n index of local variable + */ + public FLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.Const.FLOAD_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitFLOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java new file mode 100644 index 0000000..a1d6714 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FMUL.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FMUL - Multiply floats + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class FMUL extends ArithmeticInstruction { + + /** + * Multiply floats + */ + public FMUL() { + super(com.sun.org.apache.bcel.internal.Const.FMUL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFMUL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java new file mode 100644 index 0000000..eb134d9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FNEG - Negate float + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class FNEG extends ArithmeticInstruction { + + public FNEG() { + super(com.sun.org.apache.bcel.internal.Const.FNEG); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFNEG(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java new file mode 100644 index 0000000..39e0740 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FREM.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FREM - Remainder of floats + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class FREM extends ArithmeticInstruction { + + /** + * Remainder of floats + */ + public FREM() { + super(com.sun.org.apache.bcel.internal.Const.FREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFREM(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java new file mode 100644 index 0000000..3f7ba0c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FRETURN - Return float from method + * + *
+ * Stack: ..., value -> <empty>
+ * 
+ */ +public class FRETURN extends ReturnInstruction { + + /** + * Return float from method + */ + public FRETURN() { + super(com.sun.org.apache.bcel.internal.Const.FRETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitFRETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java new file mode 100644 index 0000000..868f921 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FSTORE - Store float into local variable + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class FSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FSTORE() { + super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.Const.FSTORE_0); + } + + /** + * Store float into local variable + * + * @param n index of local variable + */ + public FSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.Const.FSTORE_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitFSTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java new file mode 100644 index 0000000..9f2a360 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FSUB.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * FSUB - Substract floats + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class FSUB extends ArithmeticInstruction { + + /** + * Substract floats + */ + public FSUB() { + super(com.sun.org.apache.bcel.internal.Const.FSUB); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFSUB(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java new file mode 100644 index 0000000..e43ac1d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGen.java @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantObject; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * Template class for building up a field. The only extraordinary thing one can do is to add a constant value attribute + * to a field (which must of course be compatible with to the declared type). + * + * @LastModified: May 2021 + * @see Field + */ +public class FieldGen extends FieldGenOrMethodGen { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final FieldGen THIS = (FieldGen) o1; + final FieldGen THAT = (FieldGen) o2; + return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final FieldGen THIS = (FieldGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private Object value; + + private List observers; + + /** + * Instantiate from existing field. + * + * @param field Field object + * @param cp constant pool (must contain the same entries as the field's constant pool) + */ + public FieldGen(final Field field, final ConstantPoolGen cp) { + this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp); + final Attribute[] attrs = field.getAttributes(); + for (final Attribute attr : attrs) { + if (attr instanceof ConstantValue) { + setValue(((ConstantValue) attr).getConstantValueIndex()); + } else if (attr instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations) attr; + runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false))); + } else { + addAttribute(attr); + } + } + } + + /** + * Declare a field. If it is static (isStatic() == true) and has a basic type like int or String it may have an initial + * value associated with it as defined by setInitValue(). + * + * @param accessFlags access qualifiers + * @param type field type + * @param name field name + * @param cp constant pool + */ + public FieldGen(final int accessFlags, final Type type, final String name, final ConstantPoolGen cp) { + super(accessFlags); + setType(type); + setName(name); + setConstantPool(cp); + } + + private void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + Stream.of(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries())).forEach(this::addAttribute); + } + + private int addConstant() { + switch (super.getType().getType()) { // sic + case Const.T_INT: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_BOOLEAN: + case Const.T_SHORT: + return super.getConstantPool().addInteger(((Integer) value).intValue()); + case Const.T_FLOAT: + return super.getConstantPool().addFloat(((Float) value).floatValue()); + case Const.T_DOUBLE: + return super.getConstantPool().addDouble(((Double) value).doubleValue()); + case Const.T_LONG: + return super.getConstantPool().addLong(((Long) value).longValue()); + case Const.T_REFERENCE: + return super.getConstantPool().addString((String) value); + default: + throw new IllegalStateException("Unhandled : " + super.getType().getType()); // sic + } + } + + /** + * Add observer for this object. + */ + public void addObserver(final FieldObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + /** + * Remove any initial value. + */ + public void cancelInitValue() { + value = null; + } + + private void checkType(final Type atype) { + final Type superType = super.getType(); + if (superType == null) { + throw new ClassGenException("You haven't defined the type of the field yet"); + } + if (!isFinal()) { + throw new ClassGenException("Only final fields may have an initial value!"); + } + if (!superType.equals(atype)) { + throw new ClassGenException("Types are not compatible: " + superType + " vs. " + atype); + } + } + + /** + * @return deep copy of this field + */ + public FieldGen copy(final ConstantPoolGen cp) { + final FieldGen fg = (FieldGen) clone(); + fg.setConstantPool(cp); + return fg; + } + + /** + * Return value as defined by given BCELComparator strategy. By default two FieldGen objects are said to be equal when + * their names and signatures are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + /** + * Get field object after having set up all necessary values. + */ + public Field getField() { + final String signature = getSignature(); + final int nameIndex = super.getConstantPool().addUtf8(super.getName()); + final int signatureIndex = super.getConstantPool().addUtf8(signature); + if (value != null) { + checkType(super.getType()); + final int index = addConstant(); + addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index, super.getConstantPool().getConstantPool())); // sic + } + addAnnotationsAsAttribute(super.getConstantPool()); + return new Field(super.getAccessFlags(), nameIndex, signatureIndex, getAttributes(), super.getConstantPool().getConstantPool()); // sic + } + + public String getInitValue() { + if (value != null) { + return value.toString(); + } + return null; + } + + @Override + public String getSignature() { + return super.getType().getSignature(); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final FieldObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + public void setInitValue(final boolean b) { + checkType(Type.BOOLEAN); + if (b) { + value = Integer.valueOf(1); + } + } + + public void setInitValue(final byte b) { + checkType(Type.BYTE); + if (b != 0) { + value = Integer.valueOf(b); + } + } + + public void setInitValue(final char c) { + checkType(Type.CHAR); + if (c != 0) { + value = Integer.valueOf(c); + } + } + + public void setInitValue(final double d) { + checkType(Type.DOUBLE); + if (d != 0.0) { + value = Double.valueOf(d); + } + } + + public void setInitValue(final float f) { + checkType(Type.FLOAT); + if (f != 0.0) { + value = Float.valueOf(f); + } + } + + public void setInitValue(final int i) { + checkType(Type.INT); + if (i != 0) { + value = Integer.valueOf(i); + } + } + + public void setInitValue(final long l) { + checkType(Type.LONG); + if (l != 0L) { + value = Long.valueOf(l); + } + } + + public void setInitValue(final short s) { + checkType(Type.SHORT); + if (s != 0) { + value = Integer.valueOf(s); + } + } + + /** + * Set (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically. + */ + public void setInitValue(final String str) { + checkType(ObjectType.getInstance("java.lang.String")); + if (str != null) { + value = str; + } + } + + private void setValue(final int index) { + final ConstantPool cp = super.getConstantPool().getConstantPool(); + final Constant c = cp.getConstant(index); + value = ((ConstantObject) c).getConstantValue(cp); + } + + /** + * Return string representation close to declaration format, 'public static final short MAX = 100', e.g.. + * + * @return String representation of field + */ + @Override + public final String toString() { + String name; + String signature; + String access; // Short cuts to constant pool + access = Utility.accessToString(super.getAccessFlags()); + access = access.isEmpty() ? "" : access + " "; + signature = super.getType().toString(); + name = getName(); + final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber + buf.append(access).append(signature).append(" ").append(name); + final String value = getInitValue(); + if (value != null) { + buf.append(" = ").append(value); + } + return buf.toString(); + } + + /** + * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but + * has to be called by the user after they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final FieldObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java new file mode 100644 index 0000000..6555392 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AccessFlags; +import com.sun.org.apache.bcel.internal.classfile.Attribute; + +/** + * Super class for FieldGen and MethodGen objects, since they have some methods in common! + * + * @LastModified: May 2021 + */ +public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected String name; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected Type type; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ConstantPoolGen cp; + + private final List attributeList = new ArrayList<>(); + + // @since 6.0 + private final List annotationList = new ArrayList<>(); + + protected FieldGenOrMethodGen() { + } + + /** + * @since 6.0 + */ + protected FieldGenOrMethodGen(final int accessFlags) { // TODO could this be package protected? + super(accessFlags); + } + + protected void addAll(final Attribute[] attrs) { + Collections.addAll(attributeList, attrs); + } + + /** + * @since 6.0 + */ + public void addAnnotationEntry(final AnnotationEntryGen ag) { + annotationList.add(ag); + } + + /** + * Add an attribute to this method. Currently, the JVM knows about the 'Code', 'ConstantValue', 'Synthetic' and + * 'Exceptions' attributes. Other attributes will be ignored by the JVM but do no harm. + * + * @param a attribute to be added + */ + public void addAttribute(final Attribute a) { + attributeList.add(a); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + public AnnotationEntryGen[] getAnnotationEntries() { + return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY); + } + + /** + * @return all attributes of this method. + */ + public Attribute[] getAttributes() { + return attributeList.toArray(Attribute.EMPTY_ARRAY); + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + /** + * @return name of method/field. + */ + @Override + public String getName() { + return name; + } + + /** + * @return signature of method/field. + */ + public abstract String getSignature(); + + @Override + public Type getType() { + return type; + } + + /** + * @since 6.0 + */ + public void removeAnnotationEntries() { + annotationList.clear(); + } + + /** + * @since 6.0 + */ + public void removeAnnotationEntry(final AnnotationEntryGen ag) { + annotationList.remove(ag); + } + + /** + * Remove an attribute. + */ + public void removeAttribute(final Attribute a) { + attributeList.remove(a); + } + + /** + * Remove all attributes. + */ + public void removeAttributes() { + attributeList.clear(); + } + + public void setConstantPool(final ConstantPoolGen cp) { // TODO could be package-protected? + this.cp = cp; + } + + @Override + public void setName(final String name) { // TODO could be package-protected? + this.name = name; + } + + @Override + public void setType(final Type type) { // TODO could be package-protected? + if (type.getType() == Const.T_ADDRESS) { + throw new IllegalArgumentException("Type can not be " + type); + } + this.type = type; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java new file mode 100644 index 0000000..368d07e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; + +/** + * Super class for the GET/PUTxxx family of instructions. + */ +public abstract class FieldInstruction extends FieldOrMethod { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FieldInstruction() { + } + + /** + * @param index to constant pool + */ + protected FieldInstruction(final short opcode, final int index) { + super(opcode, index); + } + + /** + * @return name of referenced field. + */ + public String getFieldName(final ConstantPoolGen cpg) { + return getName(cpg); + } + + /** + * @return size of field (1 or 2) + */ + protected int getFieldSize(final ConstantPoolGen cpg) { + return Type.size(Type.getTypeSize(getSignature(cpg))); + } + + /** + * @return type of field + */ + public Type getFieldType(final ConstantPoolGen cpg) { + return Type.getType(getSignature(cpg)); + } + + /** + * @return return type of referenced field + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + return getFieldType(cpg); + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + cp.constantToString(super.getIndex(), com.sun.org.apache.bcel.internal.Const.CONSTANT_Fieldref); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java new file mode 100644 index 0000000..a207a09 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Imnplement this interface if you're interested in changes to a FieldGen object and register yourself with + * addObserver(). + */ +public interface FieldObserver { + + void notify(FieldGen field); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java new file mode 100644 index 0000000..99b6485 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java @@ -0,0 +1,131 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Super class for InvokeInstruction and FieldInstruction, since they have some methods in common! + */ +public abstract class FieldOrMethod extends CPInstruction implements LoadClass { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + FieldOrMethod() { + // no init + } + + /** + * @param index to constant pool + */ + protected FieldOrMethod(final short opcode, final int index) { + super(opcode, index); + } + + /** + * @return name of the referenced class/interface + * @deprecated If the instruction references an array class, this method will return "java.lang.Object". For code + * generated by Java 1.5, this answer is sometimes wrong (e.g., if the "clone()" method is called on an + * array). A better idea is to use the {@link #getReferenceType(ConstantPoolGen)} method, which correctly + * distinguishes between class types and array types. + */ + @Deprecated + public String getClassName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + if (className.startsWith("[")) { + // Turn array classes into java.lang.Object. + return "java.lang.Object"; + } + return Utility.pathToPackage(className); + } + + /** + * @return type of the referenced class/interface + * @deprecated If the instruction references an array class, the ObjectType returned will be invalid. Use + * getReferenceType() instead. + */ + @Deprecated + public ObjectType getClassType(final ConstantPoolGen cpg) { + return ObjectType.getInstance(getClassName(cpg)); + } + + /** + * Gets the ObjectType of the method return or field. + * + * @return type of the referenced class/interface + * @throws ClassGenException when the field is (or method returns) an array, + */ + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + final ReferenceType rt = getReferenceType(cpg); + if (rt instanceof ObjectType) { + return (ObjectType) rt; + } + throw new ClassGenException(rt.getClass().getCanonicalName() + " " + rt.getSignature() + " does not represent an ObjectType"); + } + + /** + * @return name of referenced method/field. + */ + public String getName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes(); + } + + /** + * Gets the reference type representing the class, interface, or array class referenced by the instruction. + * + * @param cpg the ConstantPoolGen used to create the instruction + * @return an ObjectType (if the referenced class type is a class or interface), or an ArrayType (if the referenced + * class type is an array class) + */ + public ReferenceType getReferenceType(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + if (className.startsWith("[")) { + return (ArrayType) Type.getType(className); + } + className = Utility.pathToPackage(className); + return ObjectType.getInstance(className); + } + + /** + * @return signature of referenced method/field. + */ + public String getSignature(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java new file mode 100644 index 0000000..1520eb4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETFIELD.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * GETFIELD - Fetch field from object + * + *
+ * Stack: ..., objectref -> ..., value
+ * 
+ *

+ * OR + * + *

+ * Stack: ..., objectref -> ..., value.word1, value.word2
+ * 
+ */ +public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GETFIELD() { + } + + public GETFIELD(final int index) { + super(Const.GETFIELD, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitFieldInstruction(this); + v.visitGETFIELD(this); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + @Override + public int produceStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java new file mode 100644 index 0000000..5fea34f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * GETSTATIC - Fetch static field from class + * + *
+ * Stack: ..., -> ..., value
+ * 
+ *

+ * OR + * + *

+ * Stack: ..., -> ..., value.word1, value.word2
+ * 
+ */ +public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GETSTATIC() { + } + + public GETSTATIC(final int index) { + super(Const.GETSTATIC, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitFieldInstruction(this); + v.visitGETSTATIC(this); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + @Override + public int produceStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java new file mode 100644 index 0000000..51e0944 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO.java @@ -0,0 +1,95 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * GOTO - Branch always (to relative offset, not absolute address) + */ +public class GOTO extends GotoInstruction implements VariableLengthInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GOTO() { + } + + public GOTO(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.GOTO, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitVariableLengthInstruction(this); + v.visitUnconditionalBranch(this); + v.visitBranchInstruction(this); + v.visitGotoInstruction(this); + v.visitGOTO(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.setIndex(getTargetOffset()); + final short opcode = getOpcode(); + if (opcode == com.sun.org.apache.bcel.internal.Const.GOTO) { + super.dump(out); + } else { // GOTO_W + super.setIndex(getTargetOffset()); + out.writeByte(opcode); + out.writeInt(super.getIndex()); + } + } + + /** + * Called in pass 2 of InstructionList.setPositions() in order to update the branch target, that may shift due to + * variable length instructions. + * + * @param offset additional offset caused by preceding (variable length) instructions + * @param maxOffset the maximum offset that may be caused by these instructions + * @return additional offset caused by possible change of this instruction's length + */ + @Override + protected int updatePosition(final int offset, final int maxOffset) { + final int i = getTargetOffset(); // Depending on old position value + setPosition(getPosition() + offset); // Position may be shifted by preceding expansions + if (Math.abs(i) >= Short.MAX_VALUE - maxOffset) { // to large for short (estimate) + super.setOpcode(com.sun.org.apache.bcel.internal.Const.GOTO_W); + final short oldLength = (short) super.getLength(); + super.setLength(5); + return super.getLength() - oldLength; + } + return 0; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java new file mode 100644 index 0000000..df4c06b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GOTO_W.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * GOTO_W - Branch always (to relative offset, not absolute address) + */ +public class GOTO_W extends GotoInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GOTO_W() { + } + + public GOTO_W(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.GOTO_W, target); + super.setLength(5); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitUnconditionalBranch(this); + v.visitBranchInstruction(this); + v.visitGotoInstruction(this); + v.visitGOTO_W(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setIndex(bytes.readInt()); + super.setLength(5); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java new file mode 100644 index 0000000..b261ca5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java @@ -0,0 +1,38 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for GOTO + */ +public abstract class GotoInstruction extends BranchInstruction implements UnconditionalBranch { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + GotoInstruction() { + } + + GotoInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java new file mode 100644 index 0000000..0b8c9dd --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2B.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2B - Convert int to byte + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class I2B extends ConversionInstruction { + + /** + * Convert int to byte + */ + public I2B() { + super(com.sun.org.apache.bcel.internal.Const.I2B); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2B(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java new file mode 100644 index 0000000..b5c6532 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2C.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2C - Convert int to char + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class I2C extends ConversionInstruction { + + /** + * Convert int to char + */ + public I2C() { + super(com.sun.org.apache.bcel.internal.Const.I2C); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2C(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java new file mode 100644 index 0000000..e73270a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2D.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2D - Convert int to double + * + *
+ * Stack: ..., value -> ..., result.word1, result.word2
+ * 
+ */ +public class I2D extends ConversionInstruction { + + /** + * Convert int to double + */ + public I2D() { + super(com.sun.org.apache.bcel.internal.Const.I2D); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2D(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java new file mode 100644 index 0000000..dc7df8c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2F.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2F - Convert int to float + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class I2F extends ConversionInstruction { + + /** + * Convert int to float + */ + public I2F() { + super(com.sun.org.apache.bcel.internal.Const.I2F); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2F(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java new file mode 100644 index 0000000..e0a8e81 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2L.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2L - Convert int to long + * + *
+ * Stack: ..., value -> ..., result.word1, result.word2
+ * 
+ */ +public class I2L extends ConversionInstruction { + + /** + * Convert int to long + */ + public I2L() { + super(com.sun.org.apache.bcel.internal.Const.I2L); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2L(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java new file mode 100644 index 0000000..04fa0e6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/I2S.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * I2S - Convert int to short + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class I2S extends ConversionInstruction { + + public I2S() { + super(com.sun.org.apache.bcel.internal.Const.I2S); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2S(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java new file mode 100644 index 0000000..ad5e109 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IADD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IADD - Add ints + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class IADD extends ArithmeticInstruction { + + /** + * Add ints + */ + public IADD() { + super(com.sun.org.apache.bcel.internal.Const.IADD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIADD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java new file mode 100644 index 0000000..b9f39c1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IALOAD - Load int from array + * + *
+ * Stack: ..., arrayref, index -> ..., value
+ * 
+ */ +public class IALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load int from array + */ + public IALOAD() { + super(com.sun.org.apache.bcel.internal.Const.IALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java new file mode 100644 index 0000000..4fe036c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IAND.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IAND - Bitwise AND int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class IAND extends ArithmeticInstruction { + + public IAND() { + super(com.sun.org.apache.bcel.internal.Const.IAND); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIAND(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java new file mode 100644 index 0000000..62cded2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IASTORE - Store into int array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class IASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store into int array + */ + public IASTORE() { + super(com.sun.org.apache.bcel.internal.Const.IASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java new file mode 100644 index 0000000..b3eb14a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ICONST.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +/** + * ICONST - Push value between -1, ..., 5, other values cause an exception + * + *
+ * Stack: ... -> ...,
+ * 
+ */ +public class ICONST extends Instruction implements ConstantPushInstruction { + + private final int value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ICONST() { + this(0); + } + + public ICONST(final int i) { + super(com.sun.org.apache.bcel.internal.Const.ICONST_0, (short) 1); + if (i < -1 || i > 5) { + throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i); + } + super.setOpcode((short) (com.sun.org.apache.bcel.internal.Const.ICONST_0 + i)); // Even works for i == -1 + value = i; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitICONST(this); + } + + /** + * @return Type.INT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.INT; + } + + @Override + public Number getValue() { + return Integer.valueOf(value); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java new file mode 100644 index 0000000..693bd7a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IDIV.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * IDIV - Divide ints + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class IDIV extends ArithmeticInstruction implements ExceptionThrower { + + /** + * Divide ints + */ + public IDIV() { + super(com.sun.org.apache.bcel.internal.Const.IDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIDIV(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java new file mode 100644 index 0000000..c44d0f5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFEQ - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFEQ() { + } + + public IFEQ(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFEQ, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFEQ(this); + } + + /** + * @return negation of instruction, e.g. IFEQ.negate() == IFNE + */ + @Override + public IfInstruction negate() { + return new IFNE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java new file mode 100644 index 0000000..53e32a5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFGE - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFGE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFGE() { + } + + public IFGE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFGE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLT(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java new file mode 100644 index 0000000..23ab447 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFGT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFGT - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFGT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFGT() { + } + + public IFGT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFGT, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java new file mode 100644 index 0000000..0bd68bd --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFLE - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFLE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFLE() { + } + + public IFLE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFLE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGT(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java new file mode 100644 index 0000000..0c1589e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFLT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFLT - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFLT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFLT() { + } + + public IFLT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFLT, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java new file mode 100644 index 0000000..91075bc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNE - Branch if int comparison with zero succeeds + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class IFNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNE() { + } + + public IFNE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFNE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFEQ(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java new file mode 100644 index 0000000..342779a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNONNULL - Branch if reference is not null + * + *
+ * Stack: ..., reference -> ...
+ * 
+ */ +public class IFNONNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNONNULL() { + } + + public IFNONNULL(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFNONNULL, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNONNULL(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNULL(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java new file mode 100644 index 0000000..b680033 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IFNULL.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IFNULL - Branch if reference is not null + * + *
+ * Stack: ..., reference -> ...
+ * 
+ */ +public class IFNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IFNULL() { + } + + public IFNULL(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IFNULL, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNULL(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNONNULL(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java new file mode 100644 index 0000000..9f14fb5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ACMPEQ - Branch if reference comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ACMPEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ACMPEQ() { + } + + public IF_ACMPEQ(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ACMPEQ, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPEQ(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPNE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java new file mode 100644 index 0000000..536abe4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ACMPNE - Branch if reference comparison doesn't succeed + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ACMPNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ACMPNE() { + } + + public IF_ACMPNE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ACMPNE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPEQ(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java new file mode 100644 index 0000000..a3fa883 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPEQ - Branch if int comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPEQ() { + } + + public IF_ICMPEQ(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPEQ, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPEQ(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPNE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java new file mode 100644 index 0000000..8848da0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPGE - Branch if int comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPGE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPGE() { + } + + public IF_ICMPGE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPGE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLT(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java new file mode 100644 index 0000000..b1145cc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPGT - Branch if int comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPGT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPGT() { + } + + public IF_ICMPGT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPGT, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java new file mode 100644 index 0000000..54eed61 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPLE - Branch if int comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPLE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPLE() { + } + + public IF_ICMPLE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPLE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGT(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java new file mode 100644 index 0000000..7c159f4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPLT - Branch if int comparison succeeds + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPLT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPLT() { + } + + public IF_ICMPLT(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPLT, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLT(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGE(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java new file mode 100644 index 0000000..1c1f980 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IF_ICMPNE - Branch if int comparison doesn't succeed + * + *
+ * Stack: ..., value1, value2 -> ...
+ * 
+ */ +public class IF_ICMPNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IF_ICMPNE() { + } + + public IF_ICMPNE(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.IF_ICMPNE, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPNE(this); + } + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPEQ(super.getTarget()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java new file mode 100644 index 0000000..aeaa2d8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IINC.java @@ -0,0 +1,163 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * IINC - Increment local variable by constant + */ +public class IINC extends LocalVariableInstruction { + + private boolean wide; + private int c; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IINC() { + } + + /** + * @param n index of local variable + * @param c increment factor + */ + public IINC(final int n, final int c) { + // Default behavior of LocalVariableInstruction causes error + super.setOpcode(Const.IINC); + super.setLength((short) 3); + setIndex(n); // May set wide as side effect + setIncrement(c); + } + + /** + * Calls corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLocalVariableInstruction(this); + v.visitIINC(this); + } + + /** + * Dumps instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + if (wide) { + out.writeByte(Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (wide) { + out.writeShort(super.getIndex()); + out.writeShort(c); + } else { + out.writeByte(super.getIndex()); + out.writeByte(c); + } + } + + /** + * @return increment factor + */ + public final int getIncrement() { + return c; + } + + /** + * @return int type + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.INT; + } + + /** + * Reads needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + this.wide = wide; + if (wide) { + super.setLength(6); + super.setIndexOnly(bytes.readUnsignedShort()); + c = bytes.readShort(); + } else { + super.setLength(3); + super.setIndexOnly(bytes.readUnsignedByte()); + c = bytes.readByte(); + } + } + + /** + * Sets increment factor. + */ + public final void setIncrement(final int c) { + this.c = c; + setWide(); + } + + /** + * Sets index of local variable. + */ + @Override + public final void setIndex(final int n) { + if (n < 0) { + throw new ClassGenException("Negative index value: " + n); + } + super.setIndexOnly(n); + setWide(); + } + + private void setWide() { + wide = super.getIndex() > Const.MAX_BYTE; + if (c > 0) { + wide = wide || c > Byte.MAX_VALUE; + } else { + wide = wide || c < Byte.MIN_VALUE; + } + if (wide) { + super.setLength(6); // wide byte included + } else { + super.setLength(3); + } + } + + /** + * Returns mnemonic for instruction. + * + * @return mnemonic for instruction. + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + c; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java new file mode 100644 index 0000000..1ecc3aa --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ILOAD.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ILOAD - Load int from local variable onto stack + * + *
+ * Stack: ... -> ..., result
+ * 
+ */ +public class ILOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ILOAD() { + super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.Const.ILOAD_0); + } + + /** + * Load int from local variable + * + * @param n index of local variable + */ + public ILOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.Const.ILOAD_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitILOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java new file mode 100644 index 0000000..62fc892 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMPDEP1 - Implementation dependent + */ +public class IMPDEP1 extends Instruction { + + public IMPDEP1() { + super(com.sun.org.apache.bcel.internal.Const.IMPDEP1, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitIMPDEP1(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java new file mode 100644 index 0000000..cef4e08 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMPDEP2 - Implementation dependent + */ +public class IMPDEP2 extends Instruction { + + public IMPDEP2() { + super(com.sun.org.apache.bcel.internal.Const.IMPDEP2, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitIMPDEP2(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java new file mode 100644 index 0000000..9f7ff3d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IMUL.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IMUL - Multiply ints + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class IMUL extends ArithmeticInstruction { + + /** + * Multiply ints + */ + public IMUL() { + super(com.sun.org.apache.bcel.internal.Const.IMUL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIMUL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java new file mode 100644 index 0000000..d881260 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * INEG - Negate int + * + *
+ * Stack: ..., value -> ..., result
+ * 
+ */ +public class INEG extends ArithmeticInstruction { + + public INEG() { + super(com.sun.org.apache.bcel.internal.Const.INEG); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitINEG(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java new file mode 100644 index 0000000..10d5f2c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java @@ -0,0 +1,75 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INSTANCEOF - Determine if object is of given type + * + *
+ * Stack: ..., objectref -> ..., result
+ * 
+ */ +public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INSTANCEOF() { + } + + public INSTANCEOF(final int index) { + super(com.sun.org.apache.bcel.internal.Const.INSTANCEOF, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLoadClass(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitINSTANCEOF(this); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION); + } + + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + Type t = getType(cpg); + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + return t instanceof ObjectType ? (ObjectType) t : null; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java new file mode 100644 index 0000000..7f1454b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Class for INVOKEDYNAMIC. Not an instance of InvokeInstruction, since that class expects to be able to get the class + * of the method. Ignores the bootstrap mechanism entirely. + * + * @LastModified: Feb 2023 + * @see The + * invokedynamic instruction in The Java Virtual Machine Specification + * @since 6.0 + */ +public class INVOKEDYNAMIC extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INVOKEDYNAMIC() { + } + + public INVOKEDYNAMIC(final int index) { + super(Const.INVOKEDYNAMIC, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction(this); + v.visitINVOKEDYNAMIC(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(0); + out.writeByte(0); + } + + /** + * Override the parent method because our class name is held elsewhere. + *

+ * Note: Contrary to this method's name it does not return the class name of the invoke target; rather it returns the + * name of the method that will be used to invoke the Lambda method generated by this invoke dynamic instruction. + */ + @Override + @Deprecated + public String getClassName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantInvokeDynamic cid = cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class); + return cp.getConstant(cid.getNameAndTypeIndex(), ConstantNameAndType.class).getName(cp); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.ILLEGAL_ACCESS_ERROR, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + /** + * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object, as that is the only type we can + * say for sure the reference will be. + * + * @param cpg the ConstantPoolGen used to create the instruction + * @return an ObjectType for java.lang.Object + * @since 6.1 + */ + @Override + public ReferenceType getReferenceType(final ConstantPoolGen cpg) { + return new ObjectType(Object.class.getName()); + } + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.initFromFile(bytes, wide); + super.setLength(5); + bytes.readByte(); // Skip 0 byte + bytes.readByte(); // Skip 0 byte + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java new file mode 100644 index 0000000..11807dc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java @@ -0,0 +1,129 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * INVOKEINTERFACE - Invoke interface method + * + *

+ * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
+ * 
+ * + * @see The + * invokeinterface instruction in The Java Virtual Machine Specification + */ +public final class INVOKEINTERFACE extends InvokeInstruction { + + private int nargs; // Number of arguments on stack (number of stack slots), called "count" in vmspec2 + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INVOKEINTERFACE() { + } + + public INVOKEINTERFACE(final int index, final int nargs) { + super(Const.INVOKEINTERFACE, index); + super.setLength(5); + if (nargs < 1) { + throw new ClassGenException("Number of arguments must be > 0 " + nargs); + } + this.nargs = nargs; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction(this); + v.visitINVOKEINTERFACE(this); + } + + @Override + public int consumeStack(final ConstantPoolGen cpg) { // nargs is given in byte-code + return nargs; // nargs includes this reference + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(nargs); + out.writeByte(0); + } + + /** + * The count argument according to the Java Language Specification, Second Edition. + */ + public int getCount() { + return nargs; + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.ILLEGAL_ACCESS_ERROR, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.initFromFile(bytes, wide); + super.setLength(5); + nargs = bytes.readUnsignedByte(); + bytes.readByte(); // Skip 0 byte + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + return super.toString(cp) + " " + nargs; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java new file mode 100644 index 0000000..c5d3f98 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java @@ -0,0 +1,88 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKESPECIAL - Invoke instance method; special handling for superclass, private and instance initialization method + * invocations + * + *
+ * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
+ * 
+ * + * @see The + * invokespecial instruction in The Java Virtual Machine Specification + */ +public class INVOKESPECIAL extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INVOKESPECIAL() { + } + + public INVOKESPECIAL(final int index) { + super(Const.INVOKESPECIAL, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction(this); + v.visitINVOKESPECIAL(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.UNSATISFIED_LINK_ERROR); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java new file mode 100644 index 0000000..a3a05b2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java @@ -0,0 +1,87 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKESTATIC - Invoke a class (static) method + * + *
+ * Stack: ..., [arg1, [arg2 ...]] -> ...
+ * 
+ * + * @see The invokestatic + * instruction in The Java Virtual Machine Specification + */ +public class INVOKESTATIC extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INVOKESTATIC() { + } + + public INVOKESTATIC(final int index) { + super(Const.INVOKESTATIC, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction(this); + v.visitINVOKESTATIC(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java new file mode 100644 index 0000000..35776f6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java @@ -0,0 +1,87 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * INVOKEVIRTUAL - Invoke instance method; dispatch based on class + * + *
+ * Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
+ * 
+ * + * @see The + * invokevirtual instruction in The Java Virtual Machine Specification + */ +public class INVOKEVIRTUAL extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + INVOKEVIRTUAL() { + } + + public INVOKEVIRTUAL(final int index) { + super(Const.INVOKEVIRTUAL, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction(this); + v.visitINVOKEVIRTUAL(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.UNSATISFIED_LINK_ERROR); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java new file mode 100644 index 0000000..9f9ee09 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IOR - Bitwise OR int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class IOR extends ArithmeticInstruction { + + public IOR() { + super(com.sun.org.apache.bcel.internal.Const.IOR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIOR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java new file mode 100644 index 0000000..72574ee --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IREM.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * IREM - Remainder of int + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class IREM extends ArithmeticInstruction implements ExceptionThrower { + + /** + * Remainder of ints + */ + public IREM() { + super(com.sun.org.apache.bcel.internal.Const.IREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIREM(this); + } + + /** + * @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java new file mode 100644 index 0000000..80c3bfb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IRETURN.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IRETURN - Return int from method + * + *
+ * Stack: ..., value -> <empty>
+ * 
+ */ +public class IRETURN extends ReturnInstruction { + + /** + * Return int from method + */ + public IRETURN() { + super(com.sun.org.apache.bcel.internal.Const.IRETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitIRETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java new file mode 100644 index 0000000..2e762db --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHL.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISHL - Arithmetic shift left int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class ISHL extends ArithmeticInstruction { + + public ISHL() { + super(com.sun.org.apache.bcel.internal.Const.ISHL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISHL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java new file mode 100644 index 0000000..c5e3906 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISHR - Arithmetic shift right int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class ISHR extends ArithmeticInstruction { + + public ISHR() { + super(com.sun.org.apache.bcel.internal.Const.ISHR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISHR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java new file mode 100644 index 0000000..76d8f93 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISTORE.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISTORE - Store int from stack into local variable + * + *
+ * Stack: ..., value -> ...
+ * 
+ */ +public class ISTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ISTORE() { + super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.Const.ISTORE_0); + } + + /** + * Store int into local variable + * + * @param n index of local variable + */ + public ISTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.Const.ISTORE_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitISTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java new file mode 100644 index 0000000..571751c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ISUB.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * ISUB - Substract ints + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ */ +public class ISUB extends ArithmeticInstruction { + + /** + * Substract ints + */ + public ISUB() { + super(com.sun.org.apache.bcel.internal.Const.ISUB); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISUB(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java new file mode 100644 index 0000000..89236a0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IUSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IUSHR - Logical shift right int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class IUSHR extends ArithmeticInstruction { + + public IUSHR() { + super(com.sun.org.apache.bcel.internal.Const.IUSHR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIUSHR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java new file mode 100644 index 0000000..1006f3d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IXOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * IXOR - Bitwise XOR int + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class IXOR extends ArithmeticInstruction { + + public IXOR() { + super(com.sun.org.apache.bcel.internal.Const.IXOR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIXOR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java new file mode 100644 index 0000000..b4be83e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IfInstruction.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for the IFxxx family of instructions. + */ +public abstract class IfInstruction extends BranchInstruction implements StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + IfInstruction() { + } + + /** + * @param opcode opcode of instruction + * @param target Target instruction to branch to + */ + protected IfInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + /** + * @return negation of instruction, e.g. IFEQ.negate() == IFNE + */ + public abstract IfInstruction negate(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java new file mode 100644 index 0000000..f984629 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java @@ -0,0 +1,32 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote entity that refers to an index, e.g. local variable instructions, RET, CPInstruction, etc. + */ +public interface IndexedInstruction { + + int getIndex(); + + void setIndex(int index); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java new file mode 100644 index 0000000..9eeed4b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Instruction.java @@ -0,0 +1,602 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for all Java byte codes. + * + * @LastModified: Feb 2023 + */ +public abstract class Instruction implements Cloneable { + + static final Instruction[] EMPTY_ARRAY = {}; + + private static InstructionComparator cmp = InstructionComparator.DEFAULT; + + /** + * Gets Comparator object used in the equals() method to determine equality of instructions. + * + * @return currently used comparator for equals() + * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods + */ + @Deprecated + public static InstructionComparator getComparator() { + return cmp; + } + + /** + * Tests if the value can fit in a byte (signed) + * + * @param value the value to check + * @return true if the value is in range + * @since 6.0 + */ + public static boolean isValidByte(final int value) { + return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE; + } + + /** + * Tests if the value can fit in a short (signed) + * + * @param value the value to check + * @return true if the value is in range + * @since 6.0 + */ + public static boolean isValidShort(final int value) { + return value >= Short.MIN_VALUE && value <= Short.MAX_VALUE; + } + + /** + * Reads an instruction from (byte code) input stream and return the appropriate object. + *

+ * If the Instruction is defined in {@link InstructionConst}, then the singleton instance is returned. + *

+ * + * @param bytes input stream bytes + * @return instruction object being read + * @throws IOException Thrown when an I/O exception of some sort has occurred. + * @see InstructionConst#getInstruction(int) + */ + // @since 6.0 no longer final + public static Instruction readInstruction(final ByteSequence bytes) throws IOException { + boolean wide = false; + short opcode = (short) bytes.readUnsignedByte(); + Instruction obj = null; + if (opcode == Const.WIDE) { // Read next opcode after wide byte + wide = true; + opcode = (short) bytes.readUnsignedByte(); + } + final Instruction instruction = InstructionConst.getInstruction(opcode); + if (instruction != null) { + return instruction; // Used predefined immutable object, if available + } + + switch (opcode) { + case Const.BIPUSH: + obj = new BIPUSH(); + break; + case Const.SIPUSH: + obj = new SIPUSH(); + break; + case Const.LDC: + obj = new LDC(); + break; + case Const.LDC_W: + obj = new LDC_W(); + break; + case Const.LDC2_W: + obj = new LDC2_W(); + break; + case Const.ILOAD: + obj = new ILOAD(); + break; + case Const.LLOAD: + obj = new LLOAD(); + break; + case Const.FLOAD: + obj = new FLOAD(); + break; + case Const.DLOAD: + obj = new DLOAD(); + break; + case Const.ALOAD: + obj = new ALOAD(); + break; + case Const.ILOAD_0: + obj = new ILOAD(0); + break; + case Const.ILOAD_1: + obj = new ILOAD(1); + break; + case Const.ILOAD_2: + obj = new ILOAD(2); + break; + case Const.ILOAD_3: + obj = new ILOAD(3); + break; + case Const.LLOAD_0: + obj = new LLOAD(0); + break; + case Const.LLOAD_1: + obj = new LLOAD(1); + break; + case Const.LLOAD_2: + obj = new LLOAD(2); + break; + case Const.LLOAD_3: + obj = new LLOAD(3); + break; + case Const.FLOAD_0: + obj = new FLOAD(0); + break; + case Const.FLOAD_1: + obj = new FLOAD(1); + break; + case Const.FLOAD_2: + obj = new FLOAD(2); + break; + case Const.FLOAD_3: + obj = new FLOAD(3); + break; + case Const.DLOAD_0: + obj = new DLOAD(0); + break; + case Const.DLOAD_1: + obj = new DLOAD(1); + break; + case Const.DLOAD_2: + obj = new DLOAD(2); + break; + case Const.DLOAD_3: + obj = new DLOAD(3); + break; + case Const.ALOAD_0: + obj = new ALOAD(0); + break; + case Const.ALOAD_1: + obj = new ALOAD(1); + break; + case Const.ALOAD_2: + obj = new ALOAD(2); + break; + case Const.ALOAD_3: + obj = new ALOAD(3); + break; + case Const.ISTORE: + obj = new ISTORE(); + break; + case Const.LSTORE: + obj = new LSTORE(); + break; + case Const.FSTORE: + obj = new FSTORE(); + break; + case Const.DSTORE: + obj = new DSTORE(); + break; + case Const.ASTORE: + obj = new ASTORE(); + break; + case Const.ISTORE_0: + obj = new ISTORE(0); + break; + case Const.ISTORE_1: + obj = new ISTORE(1); + break; + case Const.ISTORE_2: + obj = new ISTORE(2); + break; + case Const.ISTORE_3: + obj = new ISTORE(3); + break; + case Const.LSTORE_0: + obj = new LSTORE(0); + break; + case Const.LSTORE_1: + obj = new LSTORE(1); + break; + case Const.LSTORE_2: + obj = new LSTORE(2); + break; + case Const.LSTORE_3: + obj = new LSTORE(3); + break; + case Const.FSTORE_0: + obj = new FSTORE(0); + break; + case Const.FSTORE_1: + obj = new FSTORE(1); + break; + case Const.FSTORE_2: + obj = new FSTORE(2); + break; + case Const.FSTORE_3: + obj = new FSTORE(3); + break; + case Const.DSTORE_0: + obj = new DSTORE(0); + break; + case Const.DSTORE_1: + obj = new DSTORE(1); + break; + case Const.DSTORE_2: + obj = new DSTORE(2); + break; + case Const.DSTORE_3: + obj = new DSTORE(3); + break; + case Const.ASTORE_0: + obj = new ASTORE(0); + break; + case Const.ASTORE_1: + obj = new ASTORE(1); + break; + case Const.ASTORE_2: + obj = new ASTORE(2); + break; + case Const.ASTORE_3: + obj = new ASTORE(3); + break; + case Const.IINC: + obj = new IINC(); + break; + case Const.IFEQ: + obj = new IFEQ(); + break; + case Const.IFNE: + obj = new IFNE(); + break; + case Const.IFLT: + obj = new IFLT(); + break; + case Const.IFGE: + obj = new IFGE(); + break; + case Const.IFGT: + obj = new IFGT(); + break; + case Const.IFLE: + obj = new IFLE(); + break; + case Const.IF_ICMPEQ: + obj = new IF_ICMPEQ(); + break; + case Const.IF_ICMPNE: + obj = new IF_ICMPNE(); + break; + case Const.IF_ICMPLT: + obj = new IF_ICMPLT(); + break; + case Const.IF_ICMPGE: + obj = new IF_ICMPGE(); + break; + case Const.IF_ICMPGT: + obj = new IF_ICMPGT(); + break; + case Const.IF_ICMPLE: + obj = new IF_ICMPLE(); + break; + case Const.IF_ACMPEQ: + obj = new IF_ACMPEQ(); + break; + case Const.IF_ACMPNE: + obj = new IF_ACMPNE(); + break; + case Const.GOTO: + obj = new GOTO(); + break; + case Const.JSR: + obj = new JSR(); + break; + case Const.RET: + obj = new RET(); + break; + case Const.TABLESWITCH: + obj = new TABLESWITCH(); + break; + case Const.LOOKUPSWITCH: + obj = new LOOKUPSWITCH(); + break; + case Const.GETSTATIC: + obj = new GETSTATIC(); + break; + case Const.PUTSTATIC: + obj = new PUTSTATIC(); + break; + case Const.GETFIELD: + obj = new GETFIELD(); + break; + case Const.PUTFIELD: + obj = new PUTFIELD(); + break; + case Const.INVOKEVIRTUAL: + obj = new INVOKEVIRTUAL(); + break; + case Const.INVOKESPECIAL: + obj = new INVOKESPECIAL(); + break; + case Const.INVOKESTATIC: + obj = new INVOKESTATIC(); + break; + case Const.INVOKEINTERFACE: + obj = new INVOKEINTERFACE(); + break; + case Const.INVOKEDYNAMIC: + obj = new INVOKEDYNAMIC(); + break; + case Const.NEW: + obj = new NEW(); + break; + case Const.NEWARRAY: + obj = new NEWARRAY(); + break; + case Const.ANEWARRAY: + obj = new ANEWARRAY(); + break; + case Const.CHECKCAST: + obj = new CHECKCAST(); + break; + case Const.INSTANCEOF: + obj = new INSTANCEOF(); + break; + case Const.MULTIANEWARRAY: + obj = new MULTIANEWARRAY(); + break; + case Const.IFNULL: + obj = new IFNULL(); + break; + case Const.IFNONNULL: + obj = new IFNONNULL(); + break; + case Const.GOTO_W: + obj = new GOTO_W(); + break; + case Const.JSR_W: + obj = new JSR_W(); + break; + case Const.BREAKPOINT: + obj = new BREAKPOINT(); + break; + case Const.IMPDEP1: + obj = new IMPDEP1(); + break; + case Const.IMPDEP2: + obj = new IMPDEP2(); + break; + default: + throw new ClassGenException("Illegal opcode detected: " + opcode); + + } + + if (wide && !(obj instanceof LocalVariableInstruction || obj instanceof RET)) { + throw new ClassGenException("Illegal opcode after wide: " + opcode); + } + obj.setOpcode(opcode); + obj.initFromFile(bytes, wide); // Do further initializations, if any + return obj; + } + + /** + * Sets comparator to be used for equals(). + * + * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods + */ + @Deprecated + public static void setComparator(final InstructionComparator c) { + cmp = c; + } + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected short length = 1; // Length of instruction in bytes + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected short opcode = -1; // Opcode number + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + Instruction() { + } + + public Instruction(final short opcode, final short length) { + this.length = length; + this.opcode = opcode; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + public abstract void accept(Visitor v); + + /** + * This method also gives right results for instructions whose effect on the stack depends on the constant pool entry + * they reference. + * + * @return Number of words consumed from stack by this instruction, or Constants.UNPREDICTABLE, if this can not be + * computed statically + */ + public int consumeStack(final ConstantPoolGen cpg) { + return Const.getConsumeStack(opcode); + } + + /** + * Use with caution, since 'BranchInstruction's have a 'target' reference which is not copied correctly (only basic + * types are). This also applies for 'Select' instructions with their multiple branch targets. + * + * @return (shallow) copy of an instruction + * @see BranchInstruction + */ + public Instruction copy() { + Instruction i = null; + // "Constant" instruction, no need to duplicate + if (InstructionConst.getInstruction(this.getOpcode()) != null) { + i = this; + } else { + try { + i = (Instruction) clone(); + } catch (final CloneNotSupportedException e) { + System.err.println(e); + } + } + return i; + } + + /** + * Some instructions may be reused, so don't do anything by default. + */ + void dispose() { + } + + /** + * Dumps instruction as byte code to stream out. + * + * @param out Output stream + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(opcode); // Common for all instructions + } + + /** + * Tests for equality, delegated to comparator + * + * @return true if that is an Instruction and has the same opcode + */ + @Override + public boolean equals(final Object that) { + return that instanceof Instruction && cmp.equals(this, (Instruction) that); + } + + /** + * @return length (in bytes) of instruction + */ + public int getLength() { + return length; + } + + /** + * @return name of instruction, i.e., opcode name + */ + public String getName() { + return Const.getOpcodeName(opcode); + } + + /** + * @return this instructions opcode + */ + public short getOpcode() { + return opcode; + } + + /** + * Gets the hashCode of this object. + * + * @return the hashCode + * @since 6.0 + */ + @Override + public int hashCode() { + return opcode; + } + + /** + * Reads needed data (e.g. index) from file. + * + * @param bytes byte sequence to read from + * @param wide "wide" instruction flag + * @throws IOException may be thrown if the implementation needs to read data from the file + */ + @SuppressWarnings("unused") // thrown by subclasses + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + } + + /** + * This method also gives right results for instructions whose effect on the stack depends on the constant pool entry + * they reference. + * + * @return Number of words produced onto stack by this instruction, or Constants.UNPREDICTABLE, if this can not be + * computed statically + */ + public int produceStack(final ConstantPoolGen cpg) { + return Const.getProduceStack(opcode); + } + + /** + * Needed in readInstruction and subclasses in this package + * + * @since 6.0 + */ + final void setLength(final int length) { + this.length = (short) length; // TODO check range? + } + + /** + * Needed in readInstruction and subclasses in this package + */ + void setOpcode(final short opcode) { + this.opcode = opcode; + } + + /** + * @return mnemonic for instruction in verbose format + */ + @Override + public String toString() { + return toString(true); + } + + /** + * Long output format: + *

+ * <name of opcode> "["<opcode number>"]" "("<length of instruction>")" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + public String toString(final boolean verbose) { + if (verbose) { + return getName() + "[" + opcode + "](" + length + ")"; + } + return getName(); + } + + /** + * @return mnemonic for instruction with sumbolic references resolved + */ + public String toString(final ConstantPool cp) { + return toString(false); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java new file mode 100644 index 0000000..9f806a2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Equality of instructions isn't clearly to be defined. You might wish, for example, to compare whether instructions + * have the same meaning. E.g., whether two INVOKEVIRTUALs describe the same call. + *

+ * The DEFAULT comparator however, considers two instructions to be equal if they have same opcode and point to the same + * indexes (if any) in the constant pool or the same local variable index. Branch instructions must have the same + * target. + *

+ * + * @see Instruction + */ +public interface InstructionComparator { + + InstructionComparator DEFAULT = (i1, i2) -> { + if (i1.getOpcode() == i2.getOpcode()) { + if (i1 instanceof BranchInstruction) { + // BIs are never equal to make targeters work correctly (BCEL-195) + return false; +// } else if (i1 == i2) { TODO consider adding this shortcut +// return true; // this must be AFTER the BI test + } + if (i1 instanceof ConstantPushInstruction) { + return ((ConstantPushInstruction) i1).getValue().equals(((ConstantPushInstruction) i2).getValue()); + } + if (i1 instanceof IndexedInstruction) { + return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2).getIndex(); + } + if (i1 instanceof NEWARRAY) { + return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode(); + } + return true; + } + return false; + }; + + boolean equals(Instruction i1, Instruction i2); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java new file mode 100644 index 0000000..21269a2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionConst.java @@ -0,0 +1,299 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Contains shareable instruction objects. + *

+ * In order to save memory you can use some instructions multiply, since they have an immutable state and are directly + * derived from Instruction. I.e. they have no instance fields that could be changed. Since some of these instructions + * like ICONST_0 occur very frequently this can save a lot of time and space. This feature is an adaptation of the + * FlyWeight design pattern, we just use an array instead of a factory. + *

+ *

+ * The Instructions can also accessed directly under their names, so it's possible to write + * il.append(Instruction.ICONST_0); + *

+ */ +public final class InstructionConst { + + /** + * Predefined instruction objects. + *

+ * NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length. + */ + public static final Instruction NOP = new NOP(); + public static final Instruction ACONST_NULL = new ACONST_NULL(); + public static final Instruction ICONST_M1 = new ICONST(-1); + public static final Instruction ICONST_0 = new ICONST(0); + public static final Instruction ICONST_1 = new ICONST(1); + public static final Instruction ICONST_2 = new ICONST(2); + public static final Instruction ICONST_3 = new ICONST(3); + public static final Instruction ICONST_4 = new ICONST(4); + public static final Instruction ICONST_5 = new ICONST(5); + public static final Instruction LCONST_0 = new LCONST(0); + public static final Instruction LCONST_1 = new LCONST(1); + public static final Instruction FCONST_0 = new FCONST(0); + public static final Instruction FCONST_1 = new FCONST(1); + public static final Instruction FCONST_2 = new FCONST(2); + public static final Instruction DCONST_0 = new DCONST(0); + public static final Instruction DCONST_1 = new DCONST(1); + public static final ArrayInstruction IALOAD = new IALOAD(); + public static final ArrayInstruction LALOAD = new LALOAD(); + public static final ArrayInstruction FALOAD = new FALOAD(); + public static final ArrayInstruction DALOAD = new DALOAD(); + public static final ArrayInstruction AALOAD = new AALOAD(); + public static final ArrayInstruction BALOAD = new BALOAD(); + public static final ArrayInstruction CALOAD = new CALOAD(); + public static final ArrayInstruction SALOAD = new SALOAD(); + public static final ArrayInstruction IASTORE = new IASTORE(); + public static final ArrayInstruction LASTORE = new LASTORE(); + public static final ArrayInstruction FASTORE = new FASTORE(); + public static final ArrayInstruction DASTORE = new DASTORE(); + public static final ArrayInstruction AASTORE = new AASTORE(); + public static final ArrayInstruction BASTORE = new BASTORE(); + public static final ArrayInstruction CASTORE = new CASTORE(); + public static final ArrayInstruction SASTORE = new SASTORE(); + public static final StackInstruction POP = new POP(); + public static final StackInstruction POP2 = new POP2(); + public static final StackInstruction DUP = new DUP(); + public static final StackInstruction DUP_X1 = new DUP_X1(); + public static final StackInstruction DUP_X2 = new DUP_X2(); + public static final StackInstruction DUP2 = new DUP2(); + public static final StackInstruction DUP2_X1 = new DUP2_X1(); + public static final StackInstruction DUP2_X2 = new DUP2_X2(); + public static final StackInstruction SWAP = new SWAP(); + public static final ArithmeticInstruction IADD = new IADD(); + public static final ArithmeticInstruction LADD = new LADD(); + public static final ArithmeticInstruction FADD = new FADD(); + public static final ArithmeticInstruction DADD = new DADD(); + public static final ArithmeticInstruction ISUB = new ISUB(); + public static final ArithmeticInstruction LSUB = new LSUB(); + public static final ArithmeticInstruction FSUB = new FSUB(); + public static final ArithmeticInstruction DSUB = new DSUB(); + public static final ArithmeticInstruction IMUL = new IMUL(); + public static final ArithmeticInstruction LMUL = new LMUL(); + public static final ArithmeticInstruction FMUL = new FMUL(); + public static final ArithmeticInstruction DMUL = new DMUL(); + public static final ArithmeticInstruction IDIV = new IDIV(); + public static final ArithmeticInstruction LDIV = new LDIV(); + public static final ArithmeticInstruction FDIV = new FDIV(); + public static final ArithmeticInstruction DDIV = new DDIV(); + public static final ArithmeticInstruction IREM = new IREM(); + public static final ArithmeticInstruction LREM = new LREM(); + public static final ArithmeticInstruction FREM = new FREM(); + public static final ArithmeticInstruction DREM = new DREM(); + public static final ArithmeticInstruction INEG = new INEG(); + public static final ArithmeticInstruction LNEG = new LNEG(); + public static final ArithmeticInstruction FNEG = new FNEG(); + public static final ArithmeticInstruction DNEG = new DNEG(); + public static final ArithmeticInstruction ISHL = new ISHL(); + public static final ArithmeticInstruction LSHL = new LSHL(); + public static final ArithmeticInstruction ISHR = new ISHR(); + public static final ArithmeticInstruction LSHR = new LSHR(); + public static final ArithmeticInstruction IUSHR = new IUSHR(); + public static final ArithmeticInstruction LUSHR = new LUSHR(); + public static final ArithmeticInstruction IAND = new IAND(); + public static final ArithmeticInstruction LAND = new LAND(); + public static final ArithmeticInstruction IOR = new IOR(); + public static final ArithmeticInstruction LOR = new LOR(); + public static final ArithmeticInstruction IXOR = new IXOR(); + public static final ArithmeticInstruction LXOR = new LXOR(); + public static final ConversionInstruction I2L = new I2L(); + public static final ConversionInstruction I2F = new I2F(); + public static final ConversionInstruction I2D = new I2D(); + public static final ConversionInstruction L2I = new L2I(); + public static final ConversionInstruction L2F = new L2F(); + public static final ConversionInstruction L2D = new L2D(); + public static final ConversionInstruction F2I = new F2I(); + public static final ConversionInstruction F2L = new F2L(); + public static final ConversionInstruction F2D = new F2D(); + public static final ConversionInstruction D2I = new D2I(); + public static final ConversionInstruction D2L = new D2L(); + public static final ConversionInstruction D2F = new D2F(); + public static final ConversionInstruction I2B = new I2B(); + public static final ConversionInstruction I2C = new I2C(); + public static final ConversionInstruction I2S = new I2S(); + public static final Instruction LCMP = new LCMP(); + public static final Instruction FCMPL = new FCMPL(); + public static final Instruction FCMPG = new FCMPG(); + public static final Instruction DCMPL = new DCMPL(); + public static final Instruction DCMPG = new DCMPG(); + public static final ReturnInstruction IRETURN = new IRETURN(); + public static final ReturnInstruction LRETURN = new LRETURN(); + public static final ReturnInstruction FRETURN = new FRETURN(); + public static final ReturnInstruction DRETURN = new DRETURN(); + public static final ReturnInstruction ARETURN = new ARETURN(); + public static final ReturnInstruction RETURN = new RETURN(); + public static final Instruction ARRAYLENGTH = new ARRAYLENGTH(); + public static final Instruction ATHROW = new ATHROW(); + public static final Instruction MONITORENTER = new MONITORENTER(); + public static final Instruction MONITOREXIT = new MONITOREXIT(); + + /** + * You can use these constants in multiple places safely, if you can guarantee that you will never alter their internal + * values, e.g. call setIndex(). + */ + public static final LocalVariableInstruction THIS = new ALOAD(0); + public static final LocalVariableInstruction ALOAD_0 = THIS; + public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1); + public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2); + public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0); + public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1); + public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2); + public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0); + public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1); + public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2); + public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0); + public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1); + public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2); + + /** + * Get object via its opcode, for immutable instructions like branch instructions entries are set to null. + */ + static final Instruction[] INSTRUCTIONS = new Instruction[256]; + + static { + INSTRUCTIONS[Const.NOP] = NOP; + INSTRUCTIONS[Const.ACONST_NULL] = ACONST_NULL; + INSTRUCTIONS[Const.ICONST_M1] = ICONST_M1; + INSTRUCTIONS[Const.ICONST_0] = ICONST_0; + INSTRUCTIONS[Const.ICONST_1] = ICONST_1; + INSTRUCTIONS[Const.ICONST_2] = ICONST_2; + INSTRUCTIONS[Const.ICONST_3] = ICONST_3; + INSTRUCTIONS[Const.ICONST_4] = ICONST_4; + INSTRUCTIONS[Const.ICONST_5] = ICONST_5; + INSTRUCTIONS[Const.LCONST_0] = LCONST_0; + INSTRUCTIONS[Const.LCONST_1] = LCONST_1; + INSTRUCTIONS[Const.FCONST_0] = FCONST_0; + INSTRUCTIONS[Const.FCONST_1] = FCONST_1; + INSTRUCTIONS[Const.FCONST_2] = FCONST_2; + INSTRUCTIONS[Const.DCONST_0] = DCONST_0; + INSTRUCTIONS[Const.DCONST_1] = DCONST_1; + INSTRUCTIONS[Const.IALOAD] = IALOAD; + INSTRUCTIONS[Const.LALOAD] = LALOAD; + INSTRUCTIONS[Const.FALOAD] = FALOAD; + INSTRUCTIONS[Const.DALOAD] = DALOAD; + INSTRUCTIONS[Const.AALOAD] = AALOAD; + INSTRUCTIONS[Const.BALOAD] = BALOAD; + INSTRUCTIONS[Const.CALOAD] = CALOAD; + INSTRUCTIONS[Const.SALOAD] = SALOAD; + INSTRUCTIONS[Const.IASTORE] = IASTORE; + INSTRUCTIONS[Const.LASTORE] = LASTORE; + INSTRUCTIONS[Const.FASTORE] = FASTORE; + INSTRUCTIONS[Const.DASTORE] = DASTORE; + INSTRUCTIONS[Const.AASTORE] = AASTORE; + INSTRUCTIONS[Const.BASTORE] = BASTORE; + INSTRUCTIONS[Const.CASTORE] = CASTORE; + INSTRUCTIONS[Const.SASTORE] = SASTORE; + INSTRUCTIONS[Const.POP] = POP; + INSTRUCTIONS[Const.POP2] = POP2; + INSTRUCTIONS[Const.DUP] = DUP; + INSTRUCTIONS[Const.DUP_X1] = DUP_X1; + INSTRUCTIONS[Const.DUP_X2] = DUP_X2; + INSTRUCTIONS[Const.DUP2] = DUP2; + INSTRUCTIONS[Const.DUP2_X1] = DUP2_X1; + INSTRUCTIONS[Const.DUP2_X2] = DUP2_X2; + INSTRUCTIONS[Const.SWAP] = SWAP; + INSTRUCTIONS[Const.IADD] = IADD; + INSTRUCTIONS[Const.LADD] = LADD; + INSTRUCTIONS[Const.FADD] = FADD; + INSTRUCTIONS[Const.DADD] = DADD; + INSTRUCTIONS[Const.ISUB] = ISUB; + INSTRUCTIONS[Const.LSUB] = LSUB; + INSTRUCTIONS[Const.FSUB] = FSUB; + INSTRUCTIONS[Const.DSUB] = DSUB; + INSTRUCTIONS[Const.IMUL] = IMUL; + INSTRUCTIONS[Const.LMUL] = LMUL; + INSTRUCTIONS[Const.FMUL] = FMUL; + INSTRUCTIONS[Const.DMUL] = DMUL; + INSTRUCTIONS[Const.IDIV] = IDIV; + INSTRUCTIONS[Const.LDIV] = LDIV; + INSTRUCTIONS[Const.FDIV] = FDIV; + INSTRUCTIONS[Const.DDIV] = DDIV; + INSTRUCTIONS[Const.IREM] = IREM; + INSTRUCTIONS[Const.LREM] = LREM; + INSTRUCTIONS[Const.FREM] = FREM; + INSTRUCTIONS[Const.DREM] = DREM; + INSTRUCTIONS[Const.INEG] = INEG; + INSTRUCTIONS[Const.LNEG] = LNEG; + INSTRUCTIONS[Const.FNEG] = FNEG; + INSTRUCTIONS[Const.DNEG] = DNEG; + INSTRUCTIONS[Const.ISHL] = ISHL; + INSTRUCTIONS[Const.LSHL] = LSHL; + INSTRUCTIONS[Const.ISHR] = ISHR; + INSTRUCTIONS[Const.LSHR] = LSHR; + INSTRUCTIONS[Const.IUSHR] = IUSHR; + INSTRUCTIONS[Const.LUSHR] = LUSHR; + INSTRUCTIONS[Const.IAND] = IAND; + INSTRUCTIONS[Const.LAND] = LAND; + INSTRUCTIONS[Const.IOR] = IOR; + INSTRUCTIONS[Const.LOR] = LOR; + INSTRUCTIONS[Const.IXOR] = IXOR; + INSTRUCTIONS[Const.LXOR] = LXOR; + INSTRUCTIONS[Const.I2L] = I2L; + INSTRUCTIONS[Const.I2F] = I2F; + INSTRUCTIONS[Const.I2D] = I2D; + INSTRUCTIONS[Const.L2I] = L2I; + INSTRUCTIONS[Const.L2F] = L2F; + INSTRUCTIONS[Const.L2D] = L2D; + INSTRUCTIONS[Const.F2I] = F2I; + INSTRUCTIONS[Const.F2L] = F2L; + INSTRUCTIONS[Const.F2D] = F2D; + INSTRUCTIONS[Const.D2I] = D2I; + INSTRUCTIONS[Const.D2L] = D2L; + INSTRUCTIONS[Const.D2F] = D2F; + INSTRUCTIONS[Const.I2B] = I2B; + INSTRUCTIONS[Const.I2C] = I2C; + INSTRUCTIONS[Const.I2S] = I2S; + INSTRUCTIONS[Const.LCMP] = LCMP; + INSTRUCTIONS[Const.FCMPL] = FCMPL; + INSTRUCTIONS[Const.FCMPG] = FCMPG; + INSTRUCTIONS[Const.DCMPL] = DCMPL; + INSTRUCTIONS[Const.DCMPG] = DCMPG; + INSTRUCTIONS[Const.IRETURN] = IRETURN; + INSTRUCTIONS[Const.LRETURN] = LRETURN; + INSTRUCTIONS[Const.FRETURN] = FRETURN; + INSTRUCTIONS[Const.DRETURN] = DRETURN; + INSTRUCTIONS[Const.ARETURN] = ARETURN; + INSTRUCTIONS[Const.RETURN] = RETURN; + INSTRUCTIONS[Const.ARRAYLENGTH] = ARRAYLENGTH; + INSTRUCTIONS[Const.ATHROW] = ATHROW; + INSTRUCTIONS[Const.MONITORENTER] = MONITORENTER; + INSTRUCTIONS[Const.MONITOREXIT] = MONITOREXIT; + } + + /** + * Gets the Instruction. + * + * @param index the index, e.g. {@link Const#RETURN} + * @return the entry from the private INSTRUCTIONS table + */ + public static Instruction getInstruction(final int index) { + return INSTRUCTIONS[index]; + } + + private InstructionConst() { + } // non-instantiable +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java new file mode 100644 index 0000000..585287f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java @@ -0,0 +1,739 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Instances of this class may be used, e.g., to generate typed versions of instructions. Its main purpose is to be used + * as the byte code generating backend of a compiler. You can subclass it to add your own create methods. + *

+ * Note: The static createXXX methods return singleton instances from the {@link InstructionConst} class. + *

+ * + * @LastModified: Feb 2023 + * @see Const + * @see InstructionConst + */ +public class InstructionFactory { + + private static class MethodObject { + + final Type[] argTypes; + final Type resultType; + final String className; + final String name; + + MethodObject(final String c, final String n, final Type r, final Type[] a) { + this.className = c; + this.name = n; + this.resultType = r; + this.argTypes = a; + } + } + + private static final String APPEND = "append"; + + private static final String FQCN_STRING_BUFFER = "java.lang.StringBuffer"; + + // N.N. These must agree with the order of Constants.T_CHAR through T_LONG + private static final String[] shortNames = {"C", "F", "D", "B", "S", "I", "L"}; + + private static final MethodObject[] appendMethodObjects = { + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.STRING}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.OBJECT}), null, null, // indices 2, 3 + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.BOOLEAN}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.CHAR}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.FLOAT}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.DOUBLE}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.INT}), + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.INT}), // No append(byte) + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.INT}), // No append(short) + new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[]{Type.LONG})}; + + /** + * @param type type of elements of array, i.e., array.getElementType() + */ + public static ArrayInstruction createArrayLoad(final Type type) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_BYTE: + return InstructionConst.BALOAD; + case Const.T_CHAR: + return InstructionConst.CALOAD; + case Const.T_SHORT: + return InstructionConst.SALOAD; + case Const.T_INT: + return InstructionConst.IALOAD; + case Const.T_FLOAT: + return InstructionConst.FALOAD; + case Const.T_DOUBLE: + return InstructionConst.DALOAD; + case Const.T_LONG: + return InstructionConst.LALOAD; + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.AALOAD; + default: + throw new IllegalArgumentException("Invalid type " + type); + } + } + + /** + * @param type type of elements of array, i.e., array.getElementType() + */ + public static ArrayInstruction createArrayStore(final Type type) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_BYTE: + return InstructionConst.BASTORE; + case Const.T_CHAR: + return InstructionConst.CASTORE; + case Const.T_SHORT: + return InstructionConst.SASTORE; + case Const.T_INT: + return InstructionConst.IASTORE; + case Const.T_FLOAT: + return InstructionConst.FASTORE; + case Const.T_DOUBLE: + return InstructionConst.DASTORE; + case Const.T_LONG: + return InstructionConst.LASTORE; + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.AASTORE; + default: + throw new IllegalArgumentException("Invalid type " + type); + } + } + + private static ArithmeticInstruction createBinaryDoubleOp(final char op) { + switch (op) { + case '-': + return InstructionConst.DSUB; + case '+': + return InstructionConst.DADD; + case '*': + return InstructionConst.DMUL; + case '/': + return InstructionConst.DDIV; + case '%': + return InstructionConst.DREM; + default: + throw new IllegalArgumentException("Invalid operand " + op); + } + } + + private static ArithmeticInstruction createBinaryFloatOp(final char op) { + switch (op) { + case '-': + return InstructionConst.FSUB; + case '+': + return InstructionConst.FADD; + case '*': + return InstructionConst.FMUL; + case '/': + return InstructionConst.FDIV; + case '%': + return InstructionConst.FREM; + default: + throw new IllegalArgumentException("Invalid operand " + op); + } + } + + private static ArithmeticInstruction createBinaryIntOp(final char first, final String op) { + switch (first) { + case '-': + return InstructionConst.ISUB; + case '+': + return InstructionConst.IADD; + case '%': + return InstructionConst.IREM; + case '*': + return InstructionConst.IMUL; + case '/': + return InstructionConst.IDIV; + case '&': + return InstructionConst.IAND; + case '|': + return InstructionConst.IOR; + case '^': + return InstructionConst.IXOR; + case '<': + return InstructionConst.ISHL; + case '>': + return op.equals(">>>") ? InstructionConst.IUSHR : InstructionConst.ISHR; + default: + throw new IllegalArgumentException("Invalid operand " + op); + } + } + + /** + * Create an invokedynamic instruction. + * + * @param bootstrap_index index into the bootstrap_methods array + * @param name name of the called method + * @param ret_type return type of method + * @param argTypes argument types of method + * @see Const + */ + + /* + * createInvokeDynamic only needed if instrumentation code wants to generate a new invokedynamic instruction. I don't + * think we need. + * + * public InvokeInstruction createInvokeDynamic( int bootstrap_index, String name, Type ret_type, Type[] argTypes) { + * int index; int nargs = 0; String signature = Type.getMethodSignature(ret_type, argTypes); for (int i = 0; i < + * argTypes.length; i++) { nargs += argTypes[i].getSize(); } // UNDONE - needs to be added to ConstantPoolGen //index + * = cp.addInvokeDynamic(bootstrap_index, name, signature); index = 0; return new INVOKEDYNAMIC(index); } + */ + private static ArithmeticInstruction createBinaryLongOp(final char first, final String op) { + switch (first) { + case '-': + return InstructionConst.LSUB; + case '+': + return InstructionConst.LADD; + case '%': + return InstructionConst.LREM; + case '*': + return InstructionConst.LMUL; + case '/': + return InstructionConst.LDIV; + case '&': + return InstructionConst.LAND; + case '|': + return InstructionConst.LOR; + case '^': + return InstructionConst.LXOR; + case '<': + return InstructionConst.LSHL; + case '>': + return op.equals(">>>") ? InstructionConst.LUSHR : InstructionConst.LSHR; + default: + throw new IllegalArgumentException("Invalid operand " + op); + } + } + + /** + * Create binary operation for simple basic types, such as int and float. + * + * @param op operation, such as "+", "*", "<<", etc. + */ + public static ArithmeticInstruction createBinaryOperation(final String op, final Type type) { + final char first = op.charAt(0); + switch (type.getType()) { + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + case Const.T_CHAR: + return createBinaryIntOp(first, op); + case Const.T_LONG: + return createBinaryLongOp(first, op); + case Const.T_FLOAT: + return createBinaryFloatOp(first); + case Const.T_DOUBLE: + return createBinaryDoubleOp(first); + default: + throw new IllegalArgumentException("Invalid type " + type); + } + } + + /** + * Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH. For those you should use the SWITCH + * compound instruction. + */ + public static BranchInstruction createBranchInstruction(final short opcode, final InstructionHandle target) { + switch (opcode) { + case Const.IFEQ: + return new IFEQ(target); + case Const.IFNE: + return new IFNE(target); + case Const.IFLT: + return new IFLT(target); + case Const.IFGE: + return new IFGE(target); + case Const.IFGT: + return new IFGT(target); + case Const.IFLE: + return new IFLE(target); + case Const.IF_ICMPEQ: + return new IF_ICMPEQ(target); + case Const.IF_ICMPNE: + return new IF_ICMPNE(target); + case Const.IF_ICMPLT: + return new IF_ICMPLT(target); + case Const.IF_ICMPGE: + return new IF_ICMPGE(target); + case Const.IF_ICMPGT: + return new IF_ICMPGT(target); + case Const.IF_ICMPLE: + return new IF_ICMPLE(target); + case Const.IF_ACMPEQ: + return new IF_ACMPEQ(target); + case Const.IF_ACMPNE: + return new IF_ACMPNE(target); + case Const.GOTO: + return new GOTO(target); + case Const.JSR: + return new JSR(target); + case Const.IFNULL: + return new IFNULL(target); + case Const.IFNONNULL: + return new IFNONNULL(target); + case Const.GOTO_W: + return new GOTO_W(target); + case Const.JSR_W: + return new JSR_W(target); + default: + throw new IllegalArgumentException("Invalid opcode: " + opcode); + } + } + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup(final int size) { + return size == 2 ? InstructionConst.DUP2 : InstructionConst.DUP; + } + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup_1(final int size) { + return size == 2 ? InstructionConst.DUP2_X1 : InstructionConst.DUP_X1; + } + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup_2(final int size) { + return size == 2 ? InstructionConst.DUP2_X2 : InstructionConst.DUP_X2; + } + + /** + * @param index index of local variable + */ + public static LocalVariableInstruction createLoad(final Type type, final int index) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + return new ILOAD(index); + case Const.T_FLOAT: + return new FLOAD(index); + case Const.T_DOUBLE: + return new DLOAD(index); + case Const.T_LONG: + return new LLOAD(index); + case Const.T_ARRAY: + case Const.T_OBJECT: + return new ALOAD(index); + default: + throw new IllegalArgumentException("Invalid type " + type); + } + } + + /** + * Create "null" value for reference types, 0 for basic types like int + */ + public static Instruction createNull(final Type type) { + switch (type.getType()) { + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.ACONST_NULL; + case Const.T_INT: + case Const.T_SHORT: + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + return InstructionConst.ICONST_0; + case Const.T_FLOAT: + return InstructionConst.FCONST_0; + case Const.T_DOUBLE: + return InstructionConst.DCONST_0; + case Const.T_LONG: + return InstructionConst.LCONST_0; + case Const.T_VOID: + return InstructionConst.NOP; + default: + throw new IllegalArgumentException("Invalid type: " + type); + } + } + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createPop(final int size) { + return size == 2 ? InstructionConst.POP2 : InstructionConst.POP; + } + + /** + * Create typed return + */ + public static ReturnInstruction createReturn(final Type type) { + switch (type.getType()) { + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.ARETURN; + case Const.T_INT: + case Const.T_SHORT: + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + return InstructionConst.IRETURN; + case Const.T_FLOAT: + return InstructionConst.FRETURN; + case Const.T_DOUBLE: + return InstructionConst.DRETURN; + case Const.T_LONG: + return InstructionConst.LRETURN; + case Const.T_VOID: + return InstructionConst.RETURN; + default: + throw new IllegalArgumentException("Invalid type: " + type); + } + } + + /** + * @param index index of local variable + */ + public static LocalVariableInstruction createStore(final Type type, final int index) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + return new ISTORE(index); + case Const.T_FLOAT: + return new FSTORE(index); + case Const.T_DOUBLE: + return new DSTORE(index); + case Const.T_LONG: + return new LSTORE(index); + case Const.T_ARRAY: + case Const.T_OBJECT: + return new ASTORE(index); + default: + throw new IllegalArgumentException("Invalid type " + type); + } + } + + /** + * Create reference to 'this' + */ + public static Instruction createThis() { + return new ALOAD(0); + } + + private static boolean isString(final Type type) { + return type instanceof ObjectType && ((ObjectType) type).getClassName().equals("java.lang.String"); + } + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ClassGen cg; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ConstantPoolGen cp; + + /** + * Initialize with ClassGen object + */ + public InstructionFactory(final ClassGen cg) { + this(cg, cg.getConstantPool()); + } + + public InstructionFactory(final ClassGen cg, final ConstantPoolGen cp) { + this.cg = cg; + this.cp = cp; + } + + /** + * Initialize just with ConstantPoolGen object + */ + public InstructionFactory(final ConstantPoolGen cp) { + this(null, cp); + } + + public Instruction createAppend(final Type type) { + final byte t = type.getType(); + if (isString(type)) { + return createInvoke(appendMethodObjects[0], Const.INVOKEVIRTUAL); + } + switch (t) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_FLOAT: + case Const.T_DOUBLE: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + case Const.T_LONG: + return createInvoke(appendMethodObjects[t], Const.INVOKEVIRTUAL); + case Const.T_ARRAY: + case Const.T_OBJECT: + return createInvoke(appendMethodObjects[1], Const.INVOKEVIRTUAL); + default: + throw new IllegalArgumentException("No append for this type? " + type); + } + } + + /** + * Create conversion operation for two stack operands, this may be an I2C, instruction, e.g., if the operands are basic + * types and CHECKCAST if they are reference types. + */ + public Instruction createCast(final Type srcType, final Type destType) { + if (srcType instanceof BasicType && destType instanceof BasicType) { + final byte dest = destType.getType(); + byte src = srcType.getType(); + if (dest == Const.T_LONG && (src == Const.T_CHAR || src == Const.T_BYTE || src == Const.T_SHORT)) { + src = Const.T_INT; + } + final String name = "com.sun.org.apache.bcel.internal.generic." + shortNames[src - Const.T_CHAR] + "2" + shortNames[dest - Const.T_CHAR]; + Instruction i = null; + try { + i = (Instruction) Class.forName(name).getDeclaredConstructor().newInstance(); + ; + } catch (final Exception e) { + throw new IllegalArgumentException("Could not find instruction: " + name, e); + } + return i; + } + if (!(srcType instanceof ReferenceType) || !(destType instanceof ReferenceType)) { + throw new IllegalArgumentException("Cannot cast " + srcType + " to " + destType); + } + if (destType instanceof ArrayType) { + return new CHECKCAST(cp.addArrayClass((ArrayType) destType)); + } + return new CHECKCAST(cp.addClass(((ObjectType) destType).getClassName())); + } + + public CHECKCAST createCheckCast(final ReferenceType t) { + if (t instanceof ArrayType) { + return new CHECKCAST(cp.addArrayClass((ArrayType) t)); + } + return new CHECKCAST(cp.addClass((ObjectType) t)); + } + + /** + * Uses PUSH to push a constant value onto the stack. + * + * @param value must be of type Number, Boolean, Character or String + */ + public Instruction createConstant(final Object value) { + PUSH push; + if (value instanceof Number) { + push = new PUSH(cp, (Number) value); + } else if (value instanceof String) { + push = new PUSH(cp, (String) value); + } else if (value instanceof Boolean) { + push = new PUSH(cp, (Boolean) value); + } else if (value instanceof Character) { + push = new PUSH(cp, (Character) value); + } else { + throw new ClassGenException("Illegal type: " + value.getClass()); + } + return push.getInstruction(); + } + + /** + * Create a field instruction. + * + * @param className name of the accessed class + * @param name name of the referenced field + * @param type type of field + * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC + * @see Const + */ + public FieldInstruction createFieldAccess(final String className, final String name, final Type type, final short kind) { + int index; + final String signature = type.getSignature(); + index = cp.addFieldref(className, name, signature); + switch (kind) { + case Const.GETFIELD: + return new GETFIELD(index); + case Const.PUTFIELD: + return new PUTFIELD(index); + case Const.GETSTATIC: + return new GETSTATIC(index); + case Const.PUTSTATIC: + return new PUTSTATIC(index); + default: + throw new IllegalArgumentException("Unknown getfield kind:" + kind); + } + } + + public GETFIELD createGetField(final String className, final String name, final Type t) { + return new GETFIELD(cp.addFieldref(className, name, t.getSignature())); + } + + public GETSTATIC createGetStatic(final String className, final String name, final Type t) { + return new GETSTATIC(cp.addFieldref(className, name, t.getSignature())); + } + + public INSTANCEOF createInstanceOf(final ReferenceType t) { + if (t instanceof ArrayType) { + return new INSTANCEOF(cp.addArrayClass((ArrayType) t)); + } + return new INSTANCEOF(cp.addClass((ObjectType) t)); + } + + private InvokeInstruction createInvoke(final MethodObject m, final short kind) { + return createInvoke(m.className, m.name, m.resultType, m.argTypes, kind); + } + + /** + * Create an invoke instruction. (Except for invokedynamic.) + * + * @param className name of the called class + * @param name name of the called method + * @param retType return type of method + * @param argTypes argument types of method + * @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL + * @see Const + */ + public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind) { + return createInvoke(className, name, retType, argTypes, kind, kind == Const.INVOKEINTERFACE); + } + + /** + * Create an invoke instruction. (Except for invokedynamic.) + * + * @param className name of the called class + * @param name name of the called method + * @param retType return type of method + * @param argTypes argument types of method + * @param kind how to invoke: INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL + * @param useInterface force use of InterfaceMethodref + * @return A new InvokeInstruction. + * @since 6.5.0 + */ + public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind, + final boolean useInterface) { + if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC && kind != Const.INVOKEINTERFACE + && kind != Const.INVOKEDYNAMIC) { + throw new IllegalArgumentException("Unknown invoke kind: " + kind); + } + int index; + int nargs = 0; + final String signature = Type.getMethodSignature(retType, argTypes); + for (final Type argType : argTypes) { + nargs += argType.getSize(); + } + if (useInterface) { + index = cp.addInterfaceMethodref(className, name, signature); + } else { + index = cp.addMethodref(className, name, signature); + } + switch (kind) { + case Const.INVOKESPECIAL: + return new INVOKESPECIAL(index); + case Const.INVOKEVIRTUAL: + return new INVOKEVIRTUAL(index); + case Const.INVOKESTATIC: + return new INVOKESTATIC(index); + case Const.INVOKEINTERFACE: + return new INVOKEINTERFACE(index, nargs + 1); + case Const.INVOKEDYNAMIC: + return new INVOKEDYNAMIC(index); + default: + // Can't happen + throw new IllegalStateException("Unknown invoke kind: " + kind); + } + } + + public NEW createNew(final ObjectType t) { + return new NEW(cp.addClass(t)); + } + + public NEW createNew(final String s) { + return createNew(ObjectType.getInstance(s)); + } + + /** + * Create new array of given size and type. + * + * @return an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction + */ + public Instruction createNewArray(final Type t, final short dim) { + if (dim == 1) { + if (t instanceof ObjectType) { + return new ANEWARRAY(cp.addClass((ObjectType) t)); + } + if (t instanceof ArrayType) { + return new ANEWARRAY(cp.addArrayClass((ArrayType) t)); + } + return new NEWARRAY(t.getType()); + } + ArrayType at; + if (t instanceof ArrayType) { + at = (ArrayType) t; + } else { + at = new ArrayType(t, dim); + } + return new MULTIANEWARRAY(cp.addArrayClass(at), dim); + } + + /** + * Create a call to the most popular System.out.println() method. + * + * @param s the string to print + */ + public InstructionList createPrintln(final String s) { + final InstructionList il = new InstructionList(); + il.append(createGetStatic("java.lang.System", "out", Type.getType("Ljava/io/PrintStream;"))); + il.append(new PUSH(cp, s)); + final MethodObject methodObject = new MethodObject("java.io.PrintStream", "println", Type.VOID, new Type[]{Type.getType("Ljava/lang/String;")}); + il.append(createInvoke(methodObject, Const.INVOKEVIRTUAL)); + return il; + } + + public PUTFIELD createPutField(final String className, final String name, final Type t) { + return new PUTFIELD(cp.addFieldref(className, name, t.getSignature())); + } + + public PUTSTATIC createPutStatic(final String className, final String name, final Type t) { + return new PUTSTATIC(cp.addFieldref(className, name, t.getSignature())); + } + + public ClassGen getClassGen() { + return cg; + } + + public ConstantPoolGen getConstantPool() { + return cp; + } + + public void setClassGen(final ClassGen c) { + cg = c; + } + + public void setConstantPool(final ConstantPoolGen c) { + cp = c; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java new file mode 100644 index 0000000..3187232 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Instances of this class give users a handle to the instructions contained in an InstructionList. Instruction objects + * may be used more than once within a list, this is useful because it saves memory and may be much faster. + *

+ * Within an InstructionList an InstructionHandle object is wrapped around all instructions, i.e., it implements a cell + * in a doubly-linked list. From the outside only the next and the previous instruction (handle) are accessible. One can + * traverse the list via an Enumeration returned by InstructionList.elements(). + * + * @LastModified: May 2021 + * @see Instruction + * @see BranchHandle + * @see InstructionList + */ +public class InstructionHandle { + + /** + * Empty array. + * + * @since 6.6.0 + */ + public static final InstructionHandle[] EMPTY_ARRAY = {}; + + /** + * Empty array. + */ + static final InstructionTargeter[] EMPTY_INSTRUCTION_TARGETER_ARRAY = {}; + + /** + * Factory method. + */ + static InstructionHandle getInstructionHandle(final Instruction i) { + return new InstructionHandle(i); + } + + private InstructionHandle next; + private InstructionHandle prev; + + private Instruction instruction; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int i_position = -1; // byte code offset of instruction + private Set targeters; + + private Map attributes; + + protected InstructionHandle(final Instruction i) { + setInstruction(i); + } + + /** + * Convenience method, simply calls accept() on the contained instruction. + * + * @param v Visitor object + */ + public void accept(final Visitor v) { + instruction.accept(v); + } + + /** + * Add an attribute to an instruction handle. + * + * @param key the key object to store/retrieve the attribute + * @param attr the attribute to associate with this handle + */ + public void addAttribute(final Object key, final Object attr) { + if (attributes == null) { + attributes = new HashMap<>(3); + } + attributes.put(key, attr); + } + + /** + * Does nothing. + * + * @deprecated Does nothing as of 6.3.1. + */ + @Deprecated + protected void addHandle() { + // noop + } + + /** + * Denote this handle is being referenced by t. + */ + public void addTargeter(final InstructionTargeter t) { + if (targeters == null) { + targeters = new HashSet<>(); + } + // if(!targeters.contains(t)) + targeters.add(t); + } + + /** + * Delete contents, i.e., remove user access. + */ + void dispose() { + next = prev = null; + instruction.dispose(); + instruction = null; + i_position = -1; + attributes = null; + removeAllTargeters(); + } + + /** + * Get attribute of an instruction handle. + * + * @param key the key object to store/retrieve the attribute + */ + public Object getAttribute(final Object key) { + if (attributes != null) { + return attributes.get(key); + } + return null; + } + + /** + * @return all attributes associated with this handle + */ + public Collection getAttributes() { + if (attributes == null) { + attributes = new HashMap<>(3); + } + return attributes.values(); + } + + public final Instruction getInstruction() { + return instruction; + } + + public final InstructionHandle getNext() { + return next; + } + + /** + * @return the position, i.e., the byte code offset of the contained instruction. This is accurate only after + * InstructionList.setPositions() has been called. + */ + public int getPosition() { + return i_position; + } + + public final InstructionHandle getPrev() { + return prev; + } + + /** + * @return null, if there are no targeters + */ + public InstructionTargeter[] getTargeters() { + if (!hasTargeters()) { + return EMPTY_INSTRUCTION_TARGETER_ARRAY; + } + final InstructionTargeter[] t = new InstructionTargeter[targeters.size()]; + targeters.toArray(t); + return t; + } + + public boolean hasTargeters() { + return targeters != null && !targeters.isEmpty(); + } + + /** + * Remove all targeters, if any. + */ + public void removeAllTargeters() { + if (targeters != null) { + targeters.clear(); + } + } + + /** + * Delete an attribute of an instruction handle. + * + * @param key the key object to retrieve the attribute + */ + public void removeAttribute(final Object key) { + if (attributes != null) { + attributes.remove(key); + } + } + + /** + * Denote this handle isn't referenced anymore by t. + */ + public void removeTargeter(final InstructionTargeter t) { + if (targeters != null) { + targeters.remove(t); + } + } + + /** + * Replace current instruction contained in this handle. Old instruction is disposed using Instruction.dispose(). + */ + public void setInstruction(final Instruction i) { // Overridden in BranchHandle TODO could be package-protected? + if (i == null) { + throw new ClassGenException("Assigning null to handle"); + } + if (this.getClass() != BranchHandle.class && i instanceof BranchInstruction) { + throw new ClassGenException("Assigning branch instruction " + i + " to plain handle"); + } + if (instruction != null) { + instruction.dispose(); + } + instruction = i; + } + + /** + * @param next the next to set + * @since 6.0 + */ + final InstructionHandle setNext(final InstructionHandle next) { + this.next = next; + return next; + } + + /** + * Set the position, i.e., the byte code offset of the contained instruction. + */ + void setPosition(final int pos) { + i_position = pos; + } + + /** + * @param prev the prev to set + * @since 6.0 + */ + final InstructionHandle setPrev(final InstructionHandle prev) { + this.prev = prev; + return prev; + } + + /** + * Temporarily swap the current instruction, without disturbing anything. Meant to be used by a debugger, implementing + * breakpoints. Current instruction is returned. + *

+ * Warning: if this is used on a BranchHandle then some methods such as getPosition() will still refer to the original + * cached instruction, whereas other BH methods may affect the cache and the replacement instruction. + */ + // See BCEL-273 + // TODO remove this method in any redesign of BCEL + public Instruction swapInstruction(final Instruction i) { + final Instruction oldInstruction = instruction; + instruction = i; + return oldInstruction; + } + + /** + * @return a string representation of the contained instruction. + */ + @Override + public String toString() { + return toString(true); + } + + /** + * @return a (verbose) string representation of the contained instruction. + */ + public String toString(final boolean verbose) { + return Utility.format(i_position, 4, false, ' ') + ": " + instruction.toString(verbose); + } + + /** + * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable + * length instructions 'setPositions()' performs multiple passes over the instruction list to calculate the correct + * (byte) positions and offsets by calling this function. + * + * @param offset additional offset caused by preceding (variable length) instructions + * @param maxOffset the maximum offset that may be caused by these instructions + * @return additional offset caused by possible change of this instruction's length + */ + protected int updatePosition(final int offset, final int maxOffset) { + i_position += offset; + return 0; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java new file mode 100644 index 0000000..ebf2067 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionList.java @@ -0,0 +1,1194 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * This class is a container for a list of Instruction objects. Instructions can be + * appended, inserted, moved, deleted, etc.. Instructions are being wrapped into + * InstructionHandles objects that are returned upon append/insert operations. They + * give the user (read only) access to the list structure, such that it can be traversed and manipulated in a controlled + * way. + *

+ * A list is finally dumped to a byte code array with getByteCode. + * + * @LastModified: Feb 2023 + * @see Instruction + * @see InstructionHandle + * @see BranchHandle + */ +public class InstructionList implements Iterable { + + /** + * Find the target instruction (handle) that corresponds to the given target position (byte code offset). + * + * @param ihs array of instruction handles, i.e. il.getInstructionHandles() + * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions() + * @param count length of arrays + * @param target target position to search for + * @return target position's instruction handle if available + */ + public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) { + int l = 0; + int r = count - 1; + /* + * Do a binary search since the pos array is orderd. + */ + do { + final int i = l + r >>> 1; + final int j = pos[i]; + if (j == target) { + return ihs[i]; + } + if (target < j) { + r = i - 1; + } else { + l = i + 1; + } + } while (l <= r); + return null; + } + + private InstructionHandle start; + private InstructionHandle end; + private int length; // number of elements in list + + private int[] bytePositions; // byte code offsets corresponding to instructions + + private List observers; + + /** + * Create (empty) instruction list. + */ + public InstructionList() { + } + + /** + * Create instruction list containing one instruction. + * + * @param i initial instruction + */ + public InstructionList(final BranchInstruction i) { + append(i); + } + + /** + * Initialize instruction list from byte array. + * + * @param code byte array containing the instructions + */ + public InstructionList(final byte[] code) { + int count = 0; // Contains actual length + int[] pos; + InstructionHandle[] ihs; + try (ByteSequence bytes = new ByteSequence(code)) { + ihs = new InstructionHandle[code.length]; + pos = new int[code.length]; // Can't be more than that + /* + * Pass 1: Create an object for each byte code and append them to the list. + */ + while (bytes.available() > 0) { + // Remember byte offset and associate it with the instruction + final int off = bytes.getIndex(); + pos[count] = off; + /* + * Read one instruction from the byte stream, the byte position is set accordingly. + */ + final Instruction i = Instruction.readInstruction(bytes); + InstructionHandle ih; + if (i instanceof BranchInstruction) { + ih = append((BranchInstruction) i); + } else { + ih = append(i); + } + ih.setPosition(off); + ihs[count] = ih; + count++; + } + } catch (final IOException e) { + throw new ClassGenException(e.toString(), e); + } + bytePositions = Arrays.copyOf(pos, count); // Trim to proper size + /* + * Pass 2: Look for BranchInstruction and update their targets, i.e., convert offsets to instruction handles. + */ + for (int i = 0; i < count; i++) { + if (ihs[i] instanceof BranchHandle) { + final BranchInstruction bi = (BranchInstruction) ihs[i].getInstruction(); + int target = bi.getPosition() + bi.getIndex(); /* + * Byte code position: relative -> absolute. + */ + // Search for target position + InstructionHandle ih = findHandle(ihs, pos, count, target); + if (ih == null) { + throw new ClassGenException("Couldn't find target for branch: " + bi); + } + bi.setTarget(ih); // Update target + // If it is a Select instruction, update all branch targets + if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH + final Select s = (Select) bi; + final int[] indices = s.getIndices(); + for (int j = 0; j < indices.length; j++) { + target = bi.getPosition() + indices[j]; + ih = findHandle(ihs, pos, count, target); + if (ih == null) { + throw new ClassGenException("Couldn't find target for switch: " + bi); + } + s.setTarget(j, ih); // Update target + } + } + } + } + } + + /** + * Initialize list with (nonnull) compound instruction. Consumes argument list, i.e., it becomes empty. + * + * @param c compound instruction (list) + */ + public InstructionList(final CompoundInstruction c) { + append(c.getInstructionList()); + } + + /** + * Create instruction list containing one instruction. + * + * @param i initial instruction + */ + public InstructionList(final Instruction i) { + append(i); + } + + /** + * Add observer for this object. + */ + public void addObserver(final InstructionListObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + /** + * Append a branch instruction to the end of this list. + * + * @param i branch instruction to append + * @return branch instruction handle of the appended instruction + */ + public BranchHandle append(final BranchInstruction i) { + final BranchHandle ih = BranchHandle.getBranchHandle(i); + append(ih); + return ih; + } + + /** + * Append a compound instruction. + * + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first appended instruction + */ + public InstructionHandle append(final CompoundInstruction c) { + return append(c.getInstructionList()); + } + + /** + * Append an instruction to the end of this list. + * + * @param i instruction to append + * @return instruction handle of the appended instruction + */ + public InstructionHandle append(final Instruction i) { + final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); + append(ih); + return ih; + } + + /** + * Append a compound instruction, after instruction i. + * + * @param i Instruction in list + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first appended instruction + */ + public InstructionHandle append(final Instruction i, final CompoundInstruction c) { + return append(i, c.getInstructionList()); + } + + /** + * Append a single instruction j after another instruction i, which must be in this list of course! + * + * @param i Instruction in list + * @param j Instruction to append after i in list + * @return instruction handle of the first appended instruction + */ + public InstructionHandle append(final Instruction i, final Instruction j) { + return append(i, new InstructionList(j)); + } + + /** + * Append another list after instruction i contained in this list. Consumes argument list, i.e., it becomes empty. + * + * @param i where to append the instruction list + * @param il Instruction list to append to this one + * @return instruction handle pointing to the first appended instruction + */ + public InstructionHandle append(final Instruction i, final InstructionList il) { + InstructionHandle ih; + if ((ih = findInstruction2(i)) == null) { + throw new ClassGenException("Instruction " + i + " is not contained in this list."); + } + return append(ih, il); + } + + /** + * Append an instruction to the end of this list. + * + * @param ih instruction to append + */ + private void append(final InstructionHandle ih) { + if (isEmpty()) { + start = end = ih; + ih.setNext(ih.setPrev(null)); + } else { + end.setNext(ih); + ih.setPrev(end); + ih.setNext(null); + end = ih; + } + length++; // Update length + } + + /** + * Append an instruction after instruction (handle) ih contained in this list. + * + * @param ih where to append the instruction list + * @param i Instruction to append + * @return instruction handle pointing to the first appended instruction + */ + public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) { + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final InstructionList il = new InstructionList(); + il.append(bh); + append(ih, il); + return bh; + } + + /** + * Append a compound instruction. + * + * @param ih where to append the instruction list + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first appended instruction + */ + public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c) { + return append(ih, c.getInstructionList()); + } + + /** + * Append an instruction after instruction (handle) ih contained in this list. + * + * @param ih where to append the instruction list + * @param i Instruction to append + * @return instruction handle pointing to the first appended instruction + */ + public InstructionHandle append(final InstructionHandle ih, final Instruction i) { + return append(ih, new InstructionList(i)); + } + + /** + * Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e., it becomes + * empty. + * + * @param ih where to append the instruction list + * @param il Instruction list to append to this one + * @return instruction handle pointing to the first appended instruction + */ + public InstructionHandle append(final InstructionHandle ih, final InstructionList il) { + if (il == null) { + throw new ClassGenException("Appending null InstructionList"); + } + if (il.isEmpty()) { + return ih; + } + final InstructionHandle next = ih.getNext(); + final InstructionHandle ret = il.start; + ih.setNext(il.start); + il.start.setPrev(ih); + il.end.setNext(next); + if (next != null) { + next.setPrev(il.end); + } else { + end = il.end; // Update end ... + } + length += il.length; // Update length + il.clear(); + return ret; + } + + /** + * Append another list to this one. Consumes argument list, i.e., it becomes empty. + * + * @param il list to append to end of this list + * @return instruction handle of the first appended instruction + */ + public InstructionHandle append(final InstructionList il) { + if (il == null) { + throw new ClassGenException("Appending null InstructionList"); + } + if (il.isEmpty()) { + return null; + } + if (isEmpty()) { + start = il.start; + end = il.end; + length = il.length; + il.clear(); + return start; + } + return append(end, il); // was end.instruction + } + + private void clear() { + start = end = null; + length = 0; + } + + public boolean contains(final Instruction i) { + return findInstruction1(i) != null; + } + + public boolean contains(final InstructionHandle i) { + if (i == null) { + return false; + } + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + if (ih == i) { + return true; + } + } + return false; + } + + /** + * @return complete, i.e., deep copy of this list + */ + public InstructionList copy() { + final Map map = new HashMap<>(); + final InstructionList il = new InstructionList(); + /* + * Pass 1: Make copies of all instructions, append them to the new list and associate old instruction references with + * the new ones, i.e., a 1:1 mapping. + */ + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + final Instruction c = i.copy(); // Use clone for shallow copy + if (c instanceof BranchInstruction) { + map.put(ih, il.append((BranchInstruction) c)); + } else { + map.put(ih, il.append(c)); + } + } + /* + * Pass 2: Update branch targets. + */ + InstructionHandle ih = start; + InstructionHandle ch = il.start; + while (ih != null) { + final Instruction i = ih.getInstruction(); + final Instruction c = ch.getInstruction(); + if (i instanceof BranchInstruction) { + final BranchInstruction bi = (BranchInstruction) i; + final BranchInstruction bc = (BranchInstruction) c; + final InstructionHandle itarget = bi.getTarget(); // old target + // New target is in hash map + bc.setTarget(map.get(itarget)); + if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH + final InstructionHandle[] itargets = ((Select) bi).getTargets(); + final InstructionHandle[] ctargets = ((Select) bc).getTargets(); + for (int j = 0; j < itargets.length; j++) { // Update all targets + ctargets[j] = map.get(itargets[j]); + } + } + } + ih = ih.getNext(); + ch = ch.getNext(); + } + return il; + } + + /** + * Remove instruction from this list. The corresponding Instruction handles must not be reused! + * + * @param i instruction to remove + */ + public void delete(final Instruction i) throws TargetLostException { + InstructionHandle ih; + if ((ih = findInstruction1(i)) == null) { + throw new ClassGenException("Instruction " + i + " is not contained in this list."); + } + delete(ih); + } + + /** + * Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that + * 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused! + * + * @param from where to start deleting (inclusive) + * @param to where to end deleting (inclusive) + */ + public void delete(final Instruction from, final Instruction to) throws TargetLostException { + InstructionHandle fromIh; + InstructionHandle toIh; + if ((fromIh = findInstruction1(from)) == null) { + throw new ClassGenException("Instruction " + from + " is not contained in this list."); + } + if ((toIh = findInstruction2(to)) == null) { + throw new ClassGenException("Instruction " + to + " is not contained in this list."); + } + delete(fromIh, toIh); + } + + /** + * Remove instruction from this list. The corresponding Instruction handles must not be reused! + * + * @param ih instruction (handle) to remove + */ + public void delete(final InstructionHandle ih) throws TargetLostException { + remove(ih.getPrev(), ih.getNext()); + } + + /** + * Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that + * 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused! + * + * @param from where to start deleting (inclusive) + * @param to where to end deleting (inclusive) + */ + public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException { + remove(from.getPrev(), to.getNext()); + } + + /** + * Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction + * handles. This method is typically called right after {@link MethodGen#getMethod()}. + */ + public void dispose() { + // Traverse in reverse order, because ih.next is overwritten + for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { + // Causes BranchInstructions to release target and targeters, because it calls dispose() on the contained instruction. + ih.dispose(); + } + clear(); + } + + /** + * Get instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly + * initialized from a byte array or setPositions() has been called before this method. + * + * @param pos byte code position to search for + * @return target position's instruction handle if available + */ + public InstructionHandle findHandle(final int pos) { + final int[] positions = bytePositions; + InstructionHandle ih = start; + for (int i = 0; i < length; i++) { + if (positions[i] == pos) { + return ih; + } + ih = ih.getNext(); + } + return null; + } + + /** + * Search for given Instruction reference, start at beginning of list. + * + * @param i instruction to search for + * @return instruction found on success, null otherwise + */ + private InstructionHandle findInstruction1(final Instruction i) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + if (ih.getInstruction() == i) { + return ih; + } + } + return null; + } + + /** + * Search for given Instruction reference, start at end of list + * + * @param i instruction to search for + * @return instruction found on success, null otherwise + */ + private InstructionHandle findInstruction2(final Instruction i) { + for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { + if (ih.getInstruction() == i) { + return ih; + } + } + return null; + } + + /** + * When everything is finished, use this method to convert the instruction list into an array of bytes. + * + * @return the byte code ready to be dumped + */ + public byte[] getByteCode() { + // Update position indices of instructions + setPositions(); + final ByteArrayOutputStream b = new ByteArrayOutputStream(); + final DataOutputStream out = new DataOutputStream(b); + try { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + i.dump(out); // Traverse list + } + out.flush(); + } catch (final IOException e) { + System.err.println(e); + return Const.EMPTY_BYTE_ARRAY; + } + return b.toByteArray(); + } + + /** + * @return end of list + */ + public InstructionHandle getEnd() { + return end; + } + + /** + * @return array containing all instructions (handles) + */ + public InstructionHandle[] getInstructionHandles() { + final InstructionHandle[] ihs = new InstructionHandle[length]; + InstructionHandle ih = start; + for (int i = 0; i < length; i++) { + ihs[i] = ih; + ih = ih.getNext(); + } + return ihs; + } + + /** + * Get positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from + * an byte code array, or that setPositions() has been called. Otherwise this may be inaccurate. + * + * @return array containing all instruction's offset in byte code + */ + public int[] getInstructionPositions() { + return bytePositions; + } + + /** + * @return an array of instructions without target information for branch instructions. + */ + public Instruction[] getInstructions() { + final List instructions = new ArrayList<>(); + try (ByteSequence bytes = new ByteSequence(getByteCode())) { + while (bytes.available() > 0) { + instructions.add(Instruction.readInstruction(bytes)); + } + } catch (final IOException e) { + throw new ClassGenException(e.toString(), e); + } + return instructions.toArray(Instruction.EMPTY_ARRAY); + } + + /** + * @return length of list (Number of instructions, not bytes) + */ + public int getLength() { + return length; + } + + /** + * @return start of list + */ + public InstructionHandle getStart() { + return start; + } + + /** + * Insert a branch instruction at start of this list. + * + * @param i branch instruction to insert + * @return branch instruction handle of the appended instruction + */ + public BranchHandle insert(final BranchInstruction i) { + final BranchHandle ih = BranchHandle.getBranchHandle(i); + insert(ih); + return ih; + } + + /** + * Insert a compound instruction. + * + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final CompoundInstruction c) { + return insert(c.getInstructionList()); + } + + /** + * Insert an instruction at start of this list. + * + * @param i instruction to insert + * @return instruction handle of the inserted instruction + */ + public InstructionHandle insert(final Instruction i) { + final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); + insert(ih); + return ih; + } + + /** + * Insert a compound instruction before instruction i. + * + * @param i Instruction in list + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final Instruction i, final CompoundInstruction c) { + return insert(i, c.getInstructionList()); + } + + /** + * Insert a single instruction j before another instruction i, which must be in this list of course! + * + * @param i Instruction in list + * @param j Instruction to insert before i in list + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final Instruction i, final Instruction j) { + return insert(i, new InstructionList(j)); + } + + /** + * Insert another list before Instruction i contained in this list. Consumes argument list, i.e., it becomes empty. + * + * @param i where to append the instruction list + * @param il Instruction list to insert + * @return instruction handle pointing to the first inserted instruction, i.e., il.getStart() + */ + public InstructionHandle insert(final Instruction i, final InstructionList il) { + InstructionHandle ih; + if ((ih = findInstruction1(i)) == null) { + throw new ClassGenException("Instruction " + i + " is not contained in this list."); + } + return insert(ih, il); + } + + /** + * Insert an instruction at start of this list. + * + * @param ih instruction to insert + */ + private void insert(final InstructionHandle ih) { + if (isEmpty()) { + start = end = ih; + ih.setNext(ih.setPrev(null)); + } else { + start.setPrev(ih); + ih.setNext(start); + ih.setPrev(null); + start = ih; + } + length++; + } + + /** + * Insert an instruction before instruction (handle) ih contained in this list. + * + * @param ih where to insert to the instruction list + * @param i Instruction to insert + * @return instruction handle of the first inserted instruction + */ + public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) { + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final InstructionList il = new InstructionList(); + il.append(bh); + insert(ih, il); + return bh; + } + + /** + * Insert a compound instruction. + * + * @param ih where to insert the instruction list + * @param c The composite instruction (containing an InstructionList) + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) { + return insert(ih, c.getInstructionList()); + } + + /** + * Insert an instruction before instruction (handle) ih contained in this list. + * + * @param ih where to insert to the instruction list + * @param i Instruction to insert + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final InstructionHandle ih, final Instruction i) { + return insert(ih, new InstructionList(i)); + } + + /** + * Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e., it becomes + * empty. + * + * @param ih where to append the instruction list + * @param il Instruction list to insert + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) { + if (il == null) { + throw new ClassGenException("Inserting null InstructionList"); + } + if (il.isEmpty()) { + return ih; + } + final InstructionHandle prev = ih.getPrev(); + final InstructionHandle ret = il.start; + ih.setPrev(il.end); + il.end.setNext(ih); + il.start.setPrev(prev); + if (prev != null) { + prev.setNext(il.start); + } else { + start = il.start; // Update start ... + } + length += il.length; // Update length + il.clear(); + return ret; + } + + /** + * Insert another list. + * + * @param il list to insert before start of this list + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final InstructionList il) { + if (isEmpty()) { + append(il); // Code is identical for this case + return start; + } + return insert(start, il); + } + + /** + * Test for empty list. + */ + public boolean isEmpty() { + return start == null; + } // && end == null + + /** + * @return iterator that lists all instructions (handles) + */ + @Override + public Iterator iterator() { + return new Iterator() { + + private InstructionHandle ih = start; + + @Override + public boolean hasNext() { + return ih != null; + } + + @Override + public InstructionHandle next() throws NoSuchElementException { + if (ih == null) { + throw new NoSuchElementException(); + } + final InstructionHandle i = ih; + ih = ih.getNext(); + return i; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + /** + * Move a single instruction (handle) to a new location. + * + * @param ih moved instruction + * @param target new location of moved instruction + */ + public void move(final InstructionHandle ih, final InstructionHandle target) { + move(ih, ih, target); + } + + /** + * Take all instructions (handles) from "start" to "end" and append them after the new location "target". Of course, + * "end" must be after "start" and target must not be located withing this range. If you want to move something to the + * start of the list use null as value for target. + *

+ * Any instruction targeters pointing to handles within the block, keep their targets. + *

+ * + * @param start of moved block + * @param end of moved block + * @param target of moved block + */ + public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target) { + // Step 1: Check constraints + if (start == null || end == null) { + throw new ClassGenException("Invalid null handle: From " + start + " to " + end); + } + if (target == start || target == end) { + throw new ClassGenException("Invalid range: From " + start + " to " + end + " contains target " + target); + } + for (InstructionHandle ih = start; ih != end.getNext(); ih = ih.getNext()) { + if (ih == null) { + throw new ClassGenException("Invalid range: From " + start + " to " + end); + } + if (ih == target) { + throw new ClassGenException("Invalid range: From " + start + " to " + end + " contains target " + target); + } + } + // Step 2: Temporarily remove the given instructions from the list + final InstructionHandle prev = start.getPrev(); + InstructionHandle next = end.getNext(); + if (prev != null) { + prev.setNext(next); + } else { + this.start = next; + } + if (next != null) { + next.setPrev(prev); + } else { + this.end = prev; + } + start.setPrev(end.setNext(null)); + // Step 3: append after target + if (target == null) { // append to start of list + if (this.start != null) { + this.start.setPrev(end); + } + end.setNext(this.start); + this.start = start; + } else { + next = target.getNext(); + target.setNext(start); + start.setPrev(target); + end.setNext(next); + if (next != null) { + next.setPrev(end); + } else { + this.end = end; + } + } + } + + /** + * Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions. + * + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + */ + public void redirectBranches(final InstructionHandle oldTarget, final InstructionHandle newTarget) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { + final BranchInstruction b = (BranchInstruction) i; + final InstructionHandle target = b.getTarget(); + if (target == oldTarget) { + b.setTarget(newTarget); + } + if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH + final InstructionHandle[] targets = ((Select) b).getTargets(); + for (int j = 0; j < targets.length; j++) { + if (targets[j] == oldTarget) { + ((Select) b).setTarget(j, newTarget); + } + } + } + } + } + } + + /** + * Redirect all references of exception handlers from oldTarget to newTarget. + * + * @param exceptions array of exception handlers + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + * @see MethodGen + */ + public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget) { + for (final CodeExceptionGen exception : exceptions) { + if (exception.getStartPC() == oldTarget) { + exception.setStartPC(newTarget); + } + if (exception.getEndPC() == oldTarget) { + exception.setEndPC(newTarget); + } + if (exception.getHandlerPC() == oldTarget) { + exception.setHandlerPC(newTarget); + } + } + } + + /** + * Redirect all references of local variables from oldTarget to newTarget. + * + * @param lg array of local variables + * @param oldTarget the old target instruction handle + * @param newTarget the new target instruction handle + * @see MethodGen + */ + public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget) { + for (final LocalVariableGen element : lg) { + final InstructionHandle start = element.getStart(); + final InstructionHandle end = element.getEnd(); + if (start == oldTarget) { + element.setStart(newTarget); + } + if (end == oldTarget) { + element.setEnd(newTarget); + } + } + } + + /** + * Remove from instruction 'prev' to instruction 'next' both contained in this list. Throws TargetLostException when one + * of the removed instruction handles is still being targeted. + * + * @param prev where to start deleting (predecessor, exclusive) + * @param next where to end deleting (successor, exclusive) + */ + private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException { + InstructionHandle first; + InstructionHandle last; // First and last deleted instruction + if (prev == null && next == null) { + first = start; + last = end; + start = end = null; + } else { + if (prev == null) { // At start of list + first = start; + start = next; + } else { + first = prev.getNext(); + prev.setNext(next); + } + if (next == null) { // At end of list + last = end; + end = prev; + } else { + last = next.getPrev(); + next.setPrev(prev); + } + } + first.setPrev(null); // Completely separated from rest of list + last.setNext(null); + final List targetList = new ArrayList<>(); + for (InstructionHandle ih = first; ih != null; ih = ih.getNext()) { + ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets + } + final StringBuilder buf = new StringBuilder("{ "); + for (InstructionHandle ih = first; ih != null; ih = next) { + next = ih.getNext(); + length--; + if (ih.hasTargeters()) { // Still got targeters? + targetList.add(ih); + buf.append(ih.toString(true)).append(" "); + ih.setNext(ih.setPrev(null)); + } else { + ih.dispose(); + } + } + buf.append("}"); + if (!targetList.isEmpty()) { + throw new TargetLostException(targetList.toArray(InstructionHandle.EMPTY_ARRAY), buf.toString()); + } + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final InstructionListObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * Replace all references to the old constant pool with references to the new constant pool + */ + public void replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof CPInstruction) { + final CPInstruction ci = (CPInstruction) i; + final Constant c = oldCp.getConstant(ci.getIndex()); + ci.setIndex(newCp.addConstant(c, oldCp)); + } + } + } + + public void setPositions() { // TODO could be package-protected? (some test code would need to be repackaged) + setPositions(false); + } + + /** + * Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped. + * + * @param check Perform sanity checks, e.g. if all targeted instructions really belong to this list + */ + public void setPositions(final boolean check) { // called by code in other packages + int maxAdditionalBytes = 0; + int additionalBytes = 0; + int index = 0; + int count = 0; + final int[] pos = new int[length]; + /* + * Pass 0: Sanity checks + */ + if (check) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { // target instruction within list? + Instruction inst = ((BranchInstruction) i).getTarget().getInstruction(); + if (!contains(inst)) { + throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); + } + if (i instanceof Select) { + final InstructionHandle[] targets = ((Select) i).getTargets(); + for (final InstructionHandle target : targets) { + inst = target.getInstruction(); + if (!contains(inst)) { + throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); + } + } + } + if (!(ih instanceof BranchHandle)) { + throw new ClassGenException( + "Branch instruction " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not contained in BranchHandle."); + } + } + } + } + /* + * Pass 1: Set position numbers and sum up the maximum number of bytes an instruction may be shifted. + */ + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + ih.setPosition(index); + pos[count++] = index; + /* + * Get an estimate about how many additional bytes may be added, because BranchInstructions may have variable length + * depending on the target offset (short vs. int) or alignment issues (TABLESWITCH and LOOKUPSWITCH). + */ + switch (i.getOpcode()) { + case Const.JSR: + case Const.GOTO: + maxAdditionalBytes += 2; + break; + case Const.TABLESWITCH: + case Const.LOOKUPSWITCH: + maxAdditionalBytes += 3; + break; + } + index += i.getLength(); + } + /* + * Pass 2: Expand the variable-length (Branch)Instructions depending on the target offset (short or int) and ensure that + * branch targets are within this list. + */ + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + additionalBytes += ih.updatePosition(additionalBytes, maxAdditionalBytes); + } + /* + * Pass 3: Update position numbers (which may have changed due to the preceding expansions), like pass 1. + */ + index = count = 0; + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + ih.setPosition(index); + pos[count++] = index; + index += i.getLength(); + } + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); + } + + /** + * @return length of list (Number of instructions, not bytes) + */ + public int size() { + return length; + } + + @Override + public String toString() { + return toString(true); + } + + /** + * @param verbose toggle output format + * @return String containing all instructions in this list. + */ + public String toString(final boolean verbose) { + final StringBuilder buf = new StringBuilder(); + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + buf.append(ih.toString(verbose)).append("\n"); + } + return buf.toString(); + } + + /** + * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but + * has to be called by the user after he has finished editing the object. + */ + public void update() { + if (observers != null) { + for (final InstructionListObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java new file mode 100644 index 0000000..758c455 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to an InstructionList object and register yourself with + * addObserver(). + */ +public interface InstructionListObserver { + + void notify(InstructionList list); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java new file mode 100644 index 0000000..5146408 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote that a class targets InstructionHandles within an InstructionList. Namely the following implementers: + * + * @see BranchHandle + * @see LocalVariableGen + * @see CodeExceptionGen + */ +public interface InstructionTargeter { + + // static final InstructionTargeter[] EMPTY_ARRAY = new InstructionTargeter[0]; + + /** + * Checks whether this targeter targets the specified instruction handle. + */ + boolean containsTarget(InstructionHandle ih); + + /** + * Replaces the target of this targeter from this old handle to the new handle. + * + * @param oldIh the old handle + * @param newIh the new handle + * @throws ClassGenException if oldIh is not targeted by this object + */ + void updateTarget(InstructionHandle oldIh, InstructionHandle newIh) throws ClassGenException; +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java new file mode 100644 index 0000000..c5fac42 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.StringTokenizer; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Super class for the INVOKExxx family of instructions. + * + * @LastModified: Feb 2023 + */ +public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower, StackConsumer, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + InvokeInstruction() { + } + + /** + * @param index to constant pool + */ + protected InvokeInstruction(final short opcode, final int index) { + super(opcode, index); + } + + /** + * Also works for instructions whose stack effect depends on the constant pool entry they reference. + * + * @return Number of words consumed from stack by this instruction + */ + @Override + public int consumeStack(final ConstantPoolGen cpg) { + int sum; + if (super.getOpcode() == Const.INVOKESTATIC || super.getOpcode() == Const.INVOKEDYNAMIC) { + sum = 0; + } else { + sum = 1; // this reference + } + + final String signature = getSignature(cpg); + sum += Type.getArgumentTypesSize(signature); + return sum; + } + + /** + * @return argument types of referenced method. + */ + public Type[] getArgumentTypes(final ConstantPoolGen cpg) { + return Type.getArgumentTypes(getSignature(cpg)); + } + + /** + * This overrides the deprecated version as we know here that the referenced class may legally be an array. + * + * @return name of the referenced class/interface + * @throws IllegalArgumentException if the referenced class is an array (this should not happen) + */ + @Override + @Deprecated + public String getClassName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + return Utility.pathToPackage(className); + } + + /** + * @return name of referenced method. + */ + public String getMethodName(final ConstantPoolGen cpg) { + return getName(cpg); + } + + /** + * @return return type of referenced method. + */ + public Type getReturnType(final ConstantPoolGen cpg) { + return Type.getReturnType(getSignature(cpg)); + } + + /** + * @return return type of referenced method. + */ + @Override + public Type getType(final ConstantPoolGen cpg) { + return getReturnType(cpg); + } + + /** + * Also works for instructions whose stack effect depends on the constant pool entry they reference. + * + * @return Number of words produced onto stack by this instruction + */ + @Override + public int produceStack(final ConstantPoolGen cpg) { + final String signature = getSignature(cpg); + return Type.getReturnTypeSize(signature); + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + final Constant c = cp.getConstant(super.getIndex()); + final StringTokenizer tok = new StringTokenizer(cp.constantToString(c)); + + final String opcodeName = Const.getOpcodeName(super.getOpcode()); + + final StringBuilder sb = new StringBuilder(opcodeName); + if (tok.hasMoreTokens()) { + sb.append(" "); + sb.append(Utility.packageToPath(tok.nextToken())); + if (tok.hasMoreTokens()) { + sb.append(tok.nextToken()); + } + } + + return sb.toString(); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java new file mode 100644 index 0000000..548b321 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR.java @@ -0,0 +1,86 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * JSR - Jump to subroutine + */ +public class JSR extends JsrInstruction implements VariableLengthInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + JSR() { + } + + public JSR(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.JSR, target); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitVariableLengthInstruction(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.setIndex(getTargetOffset()); + if (super.getOpcode() == com.sun.org.apache.bcel.internal.Const.JSR) { + super.dump(out); + } else { // JSR_W + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + } + + @Override + protected int updatePosition(final int offset, final int maxOffset) { + final int i = getTargetOffset(); // Depending on old position value + setPosition(getPosition() + offset); // Position may be shifted by preceding expansions + if (Math.abs(i) >= Short.MAX_VALUE - maxOffset) { // to large for short (estimate) + super.setOpcode(com.sun.org.apache.bcel.internal.Const.JSR_W); + final short oldLength = (short) super.getLength(); + super.setLength(5); + return super.getLength() - oldLength; + } + return 0; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java new file mode 100644 index 0000000..b51d05c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JSR_W.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * JSR_W - Jump to subroutine + */ +public class JSR_W extends JsrInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + JSR_W() { + } + + public JSR_W(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.JSR_W, target); + super.setLength(5); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR_W(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setIndex(bytes.readInt()); + super.setLength(5); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java new file mode 100644 index 0000000..1ecd736 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java @@ -0,0 +1,74 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for JSR - Jump to subroutine + */ +public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch, TypedInstruction, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + JsrInstruction() { + } + + JsrInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + /** + * @return return address type + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return new ReturnaddressType(physicalSuccessor()); + } + + /** + * Returns an InstructionHandle to the physical successor of this JsrInstruction. For this method to work, this + * JsrInstruction object must not be shared between multiple InstructionHandle objects! Formally, there must not be + * InstructionHandle objects i, j where i != j and i.getInstruction() == this == j.getInstruction(). + * + * @return an InstructionHandle to the "next" instruction that will be executed when RETurned from a subroutine. + */ + public InstructionHandle physicalSuccessor() { + InstructionHandle ih = super.getTarget(); + // Rewind! + while (ih.getPrev() != null) { + ih = ih.getPrev(); + } + // Find the handle for "this" JsrInstruction object. + while (ih.getInstruction() != this) { + ih = ih.getNext(); + } + final InstructionHandle toThis = ih; + while (ih != null) { + ih = ih.getNext(); + if (ih != null && ih.getInstruction() == this) { + throw new IllegalStateException("physicalSuccessor() called on a shared JsrInstruction."); + } + } + // Return the physical successor + return toThis.getNext(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java new file mode 100644 index 0000000..b82861f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2D.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2D - Convert long to double + * + *
+ * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
+ * 
+ */ +public class L2D extends ConversionInstruction { + + public L2D() { + super(com.sun.org.apache.bcel.internal.Const.L2D); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2D(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java new file mode 100644 index 0000000..a264f8c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2F.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2F - Convert long to float + * + *
+ * Stack: ..., value.word1, value.word2 -> ..., result
+ * 
+ */ +public class L2F extends ConversionInstruction { + + public L2F() { + super(com.sun.org.apache.bcel.internal.Const.L2F); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2F(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java new file mode 100644 index 0000000..a6fb121 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/L2I.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * L2I - Convert long to int + * + *
+ * Stack: ..., value.word1, value.word2 -> ..., result
+ * 
+ */ +public class L2I extends ConversionInstruction { + + public L2I() { + super(com.sun.org.apache.bcel.internal.Const.L2I); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2I(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java new file mode 100644 index 0000000..4371c1e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LADD.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LADD - Add longs + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class LADD extends ArithmeticInstruction { + + public LADD() { + super(com.sun.org.apache.bcel.internal.Const.LADD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLADD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java new file mode 100644 index 0000000..70fd525 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LALOAD.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LALOAD - Load long from array + * + *

+ * Stack: ..., arrayref, index -> ..., value1, value2
+ * 
+ */ +public class LALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load long from array + */ + public LALOAD() { + super(com.sun.org.apache.bcel.internal.Const.LALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java new file mode 100644 index 0000000..4c80f22 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LAND.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LAND - Bitwise AND longs + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class LAND extends ArithmeticInstruction { + + public LAND() { + super(com.sun.org.apache.bcel.internal.Const.LAND); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLAND(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java new file mode 100644 index 0000000..96f3a95 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LASTORE.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LASTORE - Store into long array + * + *

+ * Stack: ..., arrayref, index, value.word1, value.word2 -> ...
+ * 
+ */ +public class LASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store long into array + */ + public LASTORE() { + super(com.sun.org.apache.bcel.internal.Const.LASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java new file mode 100644 index 0000000..188ac95 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCMP.java @@ -0,0 +1,58 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LCMP - Compare longs: + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result <= -1, 0, 1>
+ * 
+ */ +public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public LCMP() { + super(com.sun.org.apache.bcel.internal.Const.LCMP, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitLCMP(this); + } + + /** + * @return Type.LONG + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.LONG; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java new file mode 100644 index 0000000..76ff4a2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LCONST.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LCONST - Push 0 or 1, other values cause an exception + * + *
+ * Stack: ... -> ...,
+ * 
+ */ +public class LCONST extends Instruction implements ConstantPushInstruction { + + private final long value; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LCONST() { + this(0); + } + + public LCONST(final long l) { + super(com.sun.org.apache.bcel.internal.Const.LCONST_0, (short) 1); + if (l == 0) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LCONST_0); + } else if (l == 1) { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LCONST_1); + } else { + throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); + } + value = l; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitLCONST(this); + } + + /** + * @return Type.LONG + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.LONG; + } + + @Override + public Number getValue() { + return Long.valueOf(value); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java new file mode 100644 index 0000000..7700470 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LDC - Push item from constant pool. + * + *
+ * Stack: ... -> ..., item
+ * 
+ * + * @LastModified: May 2021 + */ +public class LDC extends CPInstruction implements PushInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LDC() { + } + + public LDC(final int index) { + super(com.sun.org.apache.bcel.internal.Const.LDC_W, index); + setSize(); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + if (super.getLength() == 2) { // TODO useless check? + out.writeByte(super.getIndex()); + } else { + out.writeShort(super.getIndex()); + } + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_STRING_RESOLUTION); + } + + @Override + public Type getType(final ConstantPoolGen cpg) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_String: + return Type.STRING; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float: + return Type.FLOAT; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer: + return Type.INT; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class: + return Type.CLASS; + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + public Object getValue(final ConstantPoolGen cpg) { + com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_String: + final int i = ((com.sun.org.apache.bcel.internal.classfile.ConstantString) c).getStringIndex(); + c = cpg.getConstantPool().getConstant(i); + return ((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes(); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float: + return Float.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer: + return Integer.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class: + final int nameIndex = ((com.sun.org.apache.bcel.internal.classfile.ConstantClass) c).getNameIndex(); + c = cpg.getConstantPool().getConstant(nameIndex); + return Type.getType(((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes()); + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setLength(2); + super.setIndex(bytes.readUnsignedByte()); + } + + /** + * Set the index to constant pool and adjust size. + */ + @Override + public final void setIndex(final int index) { + super.setIndex(index); + setSize(); + } + + // Adjust to proper size + protected final void setSize() { + if (super.getIndex() <= com.sun.org.apache.bcel.internal.Const.MAX_BYTE) { // Fits in one byte? + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC); + super.setLength(2); + } else { + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W); + super.setLength(3); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java new file mode 100644 index 0000000..0ba8547 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC2_W.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LDC2_W - Push long or double from constant pool + * + *
+ * Stack: ... -> ..., item.word1, item.word2
+ * 
+ * + * @LastModified: May 2021 + */ +public class LDC2_W extends CPInstruction implements PushInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LDC2_W() { + } + + public LDC2_W(final int index) { + super(com.sun.org.apache.bcel.internal.Const.LDC2_W, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC2_W(this); + } + + @Override + public Type getType(final ConstantPoolGen cpg) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long: + return Type.LONG; + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: + return Type.DOUBLE; + default: // Never reached + throw new IllegalArgumentException("Unknown constant type " + super.getOpcode()); + } + } + + public Number getValue(final ConstantPoolGen cpg) { + final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long: + return Long.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes()); + case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double: + return Double.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes()); + default: // Never reached + throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java new file mode 100644 index 0000000..07ea06e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDC_W.java @@ -0,0 +1,57 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LDC_W - Push item from constant pool (wide index) + * + *
+ * Stack: ... -> ..., item.word1, item.word2
+ * 
+ */ +public class LDC_W extends LDC { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LDC_W() { + } + + public LDC_W(final int index) { + super(index); + } + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + setIndex(bytes.readUnsignedShort()); + // Override just in case it has been changed + super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W); + super.setLength(3); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java new file mode 100644 index 0000000..5231b48 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LDIV.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * LDIV - Divide longs + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + * + * @LastModified: Jan 2020 + */ +public class LDIV extends ArithmeticInstruction implements ExceptionThrower { + + public LDIV() { + super(com.sun.org.apache.bcel.internal.Const.LDIV); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLDIV(this); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java new file mode 100644 index 0000000..7ae6dc5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LLOAD.java @@ -0,0 +1,55 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LLOAD - Load long from local variable + * + *

+ * Stack ... -> ..., result.word1, result.word2
+ * 
+ */ +public class LLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LLOAD() { + super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.Const.LLOAD_0); + } + + public LLOAD(final int n) { + super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.Const.LLOAD_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitLLOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java new file mode 100644 index 0000000..be456ba --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LMUL.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LMUL - Multiply longs + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class LMUL extends ArithmeticInstruction { + + public LMUL() { + super(com.sun.org.apache.bcel.internal.Const.LMUL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLMUL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java new file mode 100644 index 0000000..69c0d35 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LNEG.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LNEG - Negate long + * + *

+ * Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
+ * 
+ */ +public class LNEG extends ArithmeticInstruction { + + public LNEG() { + super(com.sun.org.apache.bcel.internal.Const.LNEG); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLNEG(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java new file mode 100644 index 0000000..b8e153c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java @@ -0,0 +1,101 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * LOOKUPSWITCH - Switch with unordered set of values + * + * @see SWITCH + */ +public class LOOKUPSWITCH extends Select { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LOOKUPSWITCH() { + } + + public LOOKUPSWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + super(com.sun.org.apache.bcel.internal.Const.LOOKUPSWITCH, match, targets, defaultTarget); + /* alignment remainder assumed 0 here, until dump time. */ + final short length = (short) (9 + getMatchLength() * 8); + super.setLength(length); + setFixedLength(length); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitVariableLengthInstruction(this); + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitSelect(this); + v.visitLOOKUPSWITCH(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + final int matchLength = getMatchLength(); + out.writeInt(matchLength); // npairs + for (int i = 0; i < matchLength; i++) { + out.writeInt(super.getMatch(i)); // match-offset pairs + out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i)))); + } + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.initFromFile(bytes, wide); // reads padding + final int matchLength = bytes.readInt(); + setMatchLength(matchLength); + final short fixedLength = (short) (9 + matchLength * 8); + setFixedLength(fixedLength); + final short length = (short) (matchLength + super.getPadding()); + super.setLength(length); + super.setMatches(new int[matchLength]); + super.setIndices(new int[matchLength]); + super.setTargets(new InstructionHandle[matchLength]); + for (int i = 0; i < matchLength; i++) { + super.setMatch(i, bytes.readInt()); + super.setIndices(i, bytes.readInt()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java new file mode 100644 index 0000000..53d4e9b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LOR - Bitwise OR long + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class LOR extends ArithmeticInstruction { + + public LOR() { + super(com.sun.org.apache.bcel.internal.Const.LOR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLOR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java new file mode 100644 index 0000000..c616858 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LREM.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * LREM - Remainder of long + * + *
+ * Stack: ..., value1, value2 -> result
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class LREM extends ArithmeticInstruction implements ExceptionThrower { + + public LREM() { + super(com.sun.org.apache.bcel.internal.Const.LREM); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLREM(this); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.ARITHMETIC_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java new file mode 100644 index 0000000..9d40c14 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LRETURN.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LRETURN - Return long from method + * + *
+ * Stack: ..., value.word1, value.word2 -> <empty>
+ * 
+ */ +public class LRETURN extends ReturnInstruction { + + public LRETURN() { + super(com.sun.org.apache.bcel.internal.Const.LRETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitLRETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java new file mode 100644 index 0000000..72c2aee --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHL.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSHL - Arithmetic shift left long + * + *
+ * Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
+ * 
+ */ +public class LSHL extends ArithmeticInstruction { + + public LSHL() { + super(com.sun.org.apache.bcel.internal.Const.LSHL); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSHL(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java new file mode 100644 index 0000000..d7a51d3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSHR - Arithmetic shift right long + * + *
+ * Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
+ * 
+ */ +public class LSHR extends ArithmeticInstruction { + + public LSHR() { + super(com.sun.org.apache.bcel.internal.Const.LSHR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSHR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java new file mode 100644 index 0000000..0b49912 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSTORE.java @@ -0,0 +1,55 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSTORE - Store long into local variable + * + *
+ * Stack: ..., value.word1, value.word2 -> ...
+ * 
+ */ +public class LSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + LSTORE() { + super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.Const.LSTORE_0); + } + + public LSTORE(final int n) { + super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.Const.LSTORE_0, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + super.accept(v); + v.visitLSTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java new file mode 100644 index 0000000..a8033e4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LSUB.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LSUB - Substract longs + * + *
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
+ * 
+ *

+ * ..., result.word1, result.word2 + */ +public class LSUB extends ArithmeticInstruction { + + public LSUB() { + super(com.sun.org.apache.bcel.internal.Const.LSUB); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSUB(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java new file mode 100644 index 0000000..0d9d2ea --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LUSHR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LUSHR - Logical shift right long + * + *

+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class LUSHR extends ArithmeticInstruction { + + public LUSHR() { + super(com.sun.org.apache.bcel.internal.Const.LUSHR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLUSHR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java new file mode 100644 index 0000000..cf6ac48 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LXOR.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * LXOR - Bitwise XOR long + * + *
+ * Stack: ..., value1, value2 -> ..., result
+ * 
+ */ +public class LXOR extends ArithmeticInstruction { + + public LXOR() { + super(com.sun.org.apache.bcel.internal.Const.LXOR); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLXOR(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java new file mode 100644 index 0000000..a6f542d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java @@ -0,0 +1,108 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.classfile.LineNumber; + +/** + * This class represents a line number within a method, i.e., give an instruction a line number corresponding to the + * source code line. + * + * @see LineNumber + * @see MethodGen + */ +public class LineNumberGen implements InstructionTargeter, Cloneable { + + static final LineNumberGen[] EMPTY_ARRAY = {}; + + private InstructionHandle ih; + private int srcLine; + + /** + * Create a line number. + * + * @param ih instruction handle to reference + */ + public LineNumberGen(final InstructionHandle ih, final int srcLine) { + setInstruction(ih); + setSourceLine(srcLine); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this line number + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return this.ih == ih; + } + + public InstructionHandle getInstruction() { + return ih; + } + + /** + * Get LineNumber attribute. + *

+ * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods + * has been called for the instruction list. + */ + public LineNumber getLineNumber() { + return new LineNumber(ih.getPosition(), srcLine); + } + + public int getSourceLine() { + return srcLine; + } + + public void setInstruction(final InstructionHandle instructionHandle) { // TODO could be package-protected? + Objects.requireNonNull(instructionHandle, "instructionHandle"); + BranchInstruction.notifyTarget(this.ih, instructionHandle, this); + this.ih = instructionHandle; + } + + public void setSourceLine(final int srcLine) { // TODO could be package-protected? + this.srcLine = srcLine; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + if (oldIh != ih) { + throw new ClassGenException("Not targeting " + oldIh + ", but " + ih + "}"); + } + setInstruction(newIh); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java new file mode 100644 index 0000000..9fad1d1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadClass.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes that an instruction may start the process of loading and resolving the referenced class in the Virtual Machine. + */ +public interface LoadClass { + + /** + * Returns the {@link ObjectType} of the referenced class or interface that may be loaded and resolved. + * + * @param cpg A ConstantPoolGen + * @return object type that may be loaded or null if a primitive is referenced + */ + ObjectType getLoadClassType(ConstantPoolGen cpg); + + /** + * Returns the type associated with this instruction. LoadClass instances are always typed, but this type does not always refer to the type of the class or + * interface that it possibly forces to load. For example, {@link GETFIELD} would return the type of the field and not the type of the class where the field + * is defined. If no class is forced to be loaded, {@code null} is returned. An example for this is an {@link NEWARRAY} instruction that creates an + * {@code int[][]}. + * + * @param cpg A ConstantPoolGen + * @return the type associated with this instruction. + * @see #getLoadClassType(ConstantPoolGen) + */ + Type getType(ConstantPoolGen cpg); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java new file mode 100644 index 0000000..fe5d1ac --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to load a value from a local variable, e.g. ILOAD. + */ +public abstract class LoadInstruction extends LocalVariableInstruction implements PushInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in + * readInstruction and initFromFile, respectively. + */ + LoadInstruction(final short canonTag, final short cTag) { + super(canonTag, cTag); + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ALOAD_0, e.g. + * @param n local variable index (unsigned short) + */ + protected LoadInstruction(final short opcode, final short cTag, final int n) { + super(opcode, cTag, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction(this); + v.visitLoadInstruction(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java new file mode 100644 index 0000000..3df7f7c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java @@ -0,0 +1,236 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.LocalVariable; + +/** + * Represents a local variable within a method. It contains its scope, name and type. The generated LocalVariable object + * can be obtained with getLocalVariable which needs the instruction list and the constant pool as parameters. + * + * @see LocalVariable + * @see MethodGen + */ +public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Cloneable { + + private int index; + private String name; + private Type type; + private InstructionHandle start; + private InstructionHandle end; + private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries + private boolean liveToEnd; + + /** + * Generate a local variable that with index 'index'. Note that double and long variables need two indexs. Index indices + * have to be provided by the user. + * + * @param index index of local variable + * @param name its name + * @param type its type + * @param start from where the instruction is valid (null means from the start) + * @param end until where the instruction is valid (null means to the end) + */ + public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end) { + if (index < 0 || index > Const.MAX_SHORT) { + throw new ClassGenException("Invalid index: " + index); + } + this.name = name; + this.type = type; + this.index = index; + setStart(start); + setEnd(end); + this.origIndex = index; + this.liveToEnd = end == null; + } + + /** + * Generates a local variable that with index 'index'. Note that double and long variables need two indexs. Index + * indices have to be provided by the user. + * + * @param index index of local variable + * @param name its name + * @param type its type + * @param start from where the instruction is valid (null means from the start) + * @param end until where the instruction is valid (null means to the end) + * @param origIndex index of local variable prior to any changes to index + */ + public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end, + final int origIndex) { + this(index, name, type, start, end); + this.origIndex = origIndex; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + /** + * @return true, if ih is target of this variable + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + return start == ih || end == ih; + } + + /** + * Clear the references from and to this variable when it's removed. + */ + void dispose() { + setStart(null); + setEnd(null); + } + + /** + * We consider to local variables to be equal, if the use the same index and are valid in the same range. + */ + @Override + public boolean equals(final Object o) { + if (!(o instanceof LocalVariableGen)) { + return false; + } + final LocalVariableGen l = (LocalVariableGen) o; + return l.index == index && l.start == start && l.end == end; + } + + public InstructionHandle getEnd() { + return end; + } + + public int getIndex() { + return index; + } + + public boolean getLiveToEnd() { + return liveToEnd; + } + + /** + * Gets LocalVariable object. + *

+ * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods + * has been called for the instruction list. + *

+ * Note that due to the conversion from byte code offset to InstructionHandle, it is impossible to tell the difference + * between a live range that ends BEFORE the last insturction of the method or a live range that ends AFTER the last + * instruction of the method. Hence the liveToEnd flag to differentiate between these two cases. + * + * @param cp constant pool + */ + public LocalVariable getLocalVariable(final ConstantPoolGen cp) { + int startPc = 0; + int length = 0; + if (start != null && end != null) { + startPc = start.getPosition(); + length = end.getPosition() - startPc; + if (end.getNext() == null && liveToEnd) { + length += end.getInstruction().getLength(); + } + } + final int nameIndex = cp.addUtf8(name); + final int signatureIndex = cp.addUtf8(type.getSignature()); + return new LocalVariable(startPc, length, nameIndex, signatureIndex, index, cp.getConstantPool(), origIndex); + } + + @Override + public String getName() { + return name; + } + + public int getOrigIndex() { + return origIndex; + } + + public InstructionHandle getStart() { + return start; + } + + @Override + public Type getType() { + return type; + } + + @Override + public int hashCode() { + // If the user changes the name or type, problems with the targeter hashmap will occur. + // Note: index cannot be part of hash as it may be changed by the user. + return name.hashCode() ^ type.hashCode(); + } + + public void setEnd(final InstructionHandle end) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.end, end, this); + this.end = end; + } + + public void setIndex(final int index) { + this.index = index; + } + + public void setLiveToEnd(final boolean liveToEnd) { + this.liveToEnd = liveToEnd; + } + + @Override + public void setName(final String name) { + this.name = name; + } + + public void setStart(final InstructionHandle start) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.start, start, this); + this.start = start; + } + + @Override + public void setType(final Type type) { + this.type = type; + } + + @Override + public String toString() { + return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")"; + } + + /** + * @param oldIh old target, either start or end + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (start == oldIh) { + targeted = true; + setStart(newIh); + } + if (end == oldIh) { + targeted = true; + setEnd(newIh); + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh + ", but {" + start + ", " + end + "}"); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java new file mode 100644 index 0000000..77232e5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Abstract super class for instructions dealing with local variables. + * + * @LastModified: May 2021 + */ +public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction, IndexedInstruction { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int n = -1; // index of referenced variable + + private short cTag = -1; // compact version, such as ILOAD_0 + private short canonTag = -1; // canonical tag such as ILOAD + + /** + * Empty constructor needed for Instruction.readInstruction. Also used by IINC()! + */ + LocalVariableInstruction() { + } + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in + * readInstruction and initFromFile, respectively. + */ + LocalVariableInstruction(final short canonTag, final short cTag) { + this.canonTag = canonTag; + this.cTag = cTag; + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ALOAD_0, e.g. + * @param n local variable index (unsigned short) + */ + protected LocalVariableInstruction(final short opcode, final short cTag, final int n) { + super(opcode, (short) 2); + this.cTag = cTag; + canonTag = opcode; + setIndex(n); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + if (wide()) { + out.writeByte(Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (super.getLength() > 1) { // Otherwise ILOAD_n, instruction, e.g. + if (wide()) { + out.writeShort(n); + } else { + out.writeByte(n); + } + } + } + + /** + * @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 + */ + public short getCanonicalTag() { + return canonTag; + } + + /** + * @return local variable index (n) referred by this instruction. + */ + @Override + public final int getIndex() { + return n; + } + + /** + * Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned. This is just a + * bit incorrect, because ALOAD and ASTORE may work on every ReferenceType (including Type.NULL) and ASTORE may even + * work on a ReturnaddressType . + * + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + switch (canonTag) { + case Const.ILOAD: + case Const.ISTORE: + return Type.INT; + case Const.LLOAD: + case Const.LSTORE: + return Type.LONG; + case Const.DLOAD: + case Const.DSTORE: + return Type.DOUBLE; + case Const.FLOAD: + case Const.FSTORE: + return Type.FLOAT; + case Const.ALOAD: + case Const.ASTORE: + return Type.OBJECT; + default: + throw new ClassGenException("Unknown case in switch" + canonTag); + } + } + + /** + * Read needed data (e.g. index) from file. + * + *

+     * (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
+     * 
+ */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + if (wide) { + n = bytes.readUnsignedShort(); + super.setLength(4); + } else { + final short opcode = super.getOpcode(); + if (opcode >= Const.ILOAD && opcode <= Const.ALOAD || opcode >= Const.ISTORE && opcode <= Const.ASTORE) { + n = bytes.readUnsignedByte(); + super.setLength(2); + } else { + if (opcode <= Const.ALOAD_3) { // compact load instruction such as ILOAD_2 + n = (opcode - Const.ILOAD_0) % 4; + } else { // Assert ISTORE_0 <= tag <= ASTORE_3 + n = (opcode - Const.ISTORE_0) % 4; + } + super.setLength(1); + } + } + } + + /** + * Set the local variable index. also updates opcode and length TODO Why? + * + * @see #setIndexOnly(int) + */ + @Override + public void setIndex(final int n) { // TODO could be package-protected? + if (n < 0 || n > Const.MAX_SHORT) { + throw new ClassGenException("Illegal value: " + n); + } + this.n = n; + // Cannot be < 0 as this is checked above + if (n <= 3) { // Use more compact instruction xLOAD_n + super.setOpcode((short) (cTag + n)); + super.setLength(1); + } else { + super.setOpcode(canonTag); + if (wide()) { + super.setLength(4); + } else { + super.setLength(2); + } + } + } + + /** + * Sets the index of the referenced variable (n) only + * + * @see #setIndex(int) + * @since 6.0 + */ + final void setIndexOnly(final int n) { + this.n = n; + } + + /** + * Long output format: + *

+ * <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable + * index>">" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + final short opcode = super.getOpcode(); + if (opcode >= Const.ILOAD_0 && opcode <= Const.ALOAD_3 || opcode >= Const.ISTORE_0 && opcode <= Const.ASTORE_3) { + return super.toString(verbose); + } + return super.toString(verbose) + " " + n; + } + + private boolean wide() { + return n > Const.MAX_BYTE; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java new file mode 100644 index 0000000..d3da8cb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * MONITORENTER - Enter monitor for object + * + *

+ * Stack: ..., objectref -> ...
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITORENTER() { + super(com.sun.org.apache.bcel.internal.Const.MONITORENTER, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITORENTER(this); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java new file mode 100644 index 0000000..9a4f3fa --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * MONITOREXIT - Exit monitor for object + * + *
+ * Stack: ..., objectref -> ...
+ * 
+ * + * @LastModified: Jan 2020 + */ +public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITOREXIT() { + super(com.sun.org.apache.bcel.internal.Const.MONITOREXIT, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITOREXIT(this); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.NULL_POINTER_EXCEPTION}; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java new file mode 100644 index 0000000..51cd775 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java @@ -0,0 +1,142 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * MULTIANEWARRAY - Create new mutidimensional array of references + * + *
+ * Stack: ..., count1, [count2, ...] -> ..., arrayref
+ * 
+ */ +public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower { + + private short dimensions; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + MULTIANEWARRAY() { + } + + public MULTIANEWARRAY(final int index, final short dimensions) { + super(com.sun.org.apache.bcel.internal.Const.MULTIANEWARRAY, index); + if (dimensions < 1) { + throw new ClassGenException("Invalid dimensions value: " + dimensions); + } + this.dimensions = dimensions; + super.setLength(4); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLoadClass(this); + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitMULTIANEWARRAY(this); + } + + /** + * Also works for instructions whose stack effect depends on the constant pool entry they reference. + * + * @return Number of words consumed from stack by this instruction + */ + @Override + public int consumeStack(final ConstantPoolGen cpg) { + return dimensions; + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(dimensions); + } + + /** + * @return number of dimensions to be created + */ + public final short getDimensions() { + return dimensions; + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION); + } + + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + Type t = getType(cpg); + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + return t instanceof ObjectType ? (ObjectType) t : null; + } + + /** + * Read needed data (i.e., no. dimension) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.initFromFile(bytes, wide); + dimensions = bytes.readByte(); + super.setLength(4); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + super.getIndex() + " " + dimensions; + } + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString(final ConstantPool cp) { + return super.toString(cp) + " " + dimensions; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java new file mode 100644 index 0000000..877b4b1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodGen.java @@ -0,0 +1,1174 @@ +/* + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.Stack; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.Annotations; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.LineNumber; +import com.sun.org.apache.bcel.internal.classfile.LineNumberTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTypeTable; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.ParameterAnnotationEntry; +import com.sun.org.apache.bcel.internal.classfile.ParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleParameterAnnotations; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.util.BCELComparator; + +/** + * Template class for building up a method. This is done by defining exception handlers, adding thrown exceptions, local + * variables and attributes, whereas the 'LocalVariableTable' and 'LineNumberTable' attributes will be set automatically + * for the code. Use stripAttributes() if you don't like this. + *

+ * While generating code it may be necessary to insert NOP operations. You can use the 'removeNOPs' method to get rid + * off them. The resulting method object can be obtained via the 'getMethod()' method. + * + * @LastModified: Feb 2023 + * @see InstructionList + * @see Method + */ +public class MethodGen extends FieldGenOrMethodGen { + + static final class BranchStack { + + private final Stack branchTargets = new Stack<>(); + private final HashMap visitedTargets = new HashMap<>(); + + public BranchTarget pop() { + if (!branchTargets.empty()) { + return branchTargets.pop(); + } + return null; + } + + public void push(final InstructionHandle target, final int stackDepth) { + if (visited(target)) { + return; + } + branchTargets.push(visit(target, stackDepth)); + } + + private BranchTarget visit(final InstructionHandle target, final int stackDepth) { + final BranchTarget bt = new BranchTarget(target, stackDepth); + visitedTargets.put(target, bt); + return bt; + } + + private boolean visited(final InstructionHandle target) { + return visitedTargets.get(target) != null; + } + } + + static final class BranchTarget { + + final InstructionHandle target; + final int stackDepth; + + BranchTarget(final InstructionHandle target, final int stackDepth) { + this.target = target; + this.stackDepth = stackDepth; + } + } + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals(final Object o1, final Object o2) { + final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o1; + final FieldGenOrMethodGen THAT = (FieldGenOrMethodGen) o2; + return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature()); + } + + @Override + public int hashCode(final Object o) { + final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + private static byte[] getByteCodes(final Method method) { + final Code code = method.getCode(); + if (code == null) { + throw new IllegalStateException(String.format("The method '%s' has no code.", method)); + } + return code.getCode(); + } + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + /** + * Computes stack usage of an instruction list by performing control flow analysis. + * + * @return maximum stack depth used by method + */ + public static int getMaxStack(final ConstantPoolGen cp, final InstructionList il, final CodeExceptionGen[] et) { + final BranchStack branchTargets = new BranchStack(); + /* + * Initially, populate the branch stack with the exception handlers, because these aren't (necessarily) branched to + * explicitly. in each case, the stack will have depth 1, containing the exception object. + */ + for (final CodeExceptionGen element : et) { + final InstructionHandle handlerPc = element.getHandlerPC(); + if (handlerPc != null) { + branchTargets.push(handlerPc, 1); + } + } + int stackDepth = 0; + int maxStackDepth = 0; + InstructionHandle ih = il.getStart(); + while (ih != null) { + final Instruction instruction = ih.getInstruction(); + final short opcode = instruction.getOpcode(); + final int delta = instruction.produceStack(cp) - instruction.consumeStack(cp); + stackDepth += delta; + if (stackDepth > maxStackDepth) { + maxStackDepth = stackDepth; + } + // choose the next instruction based on whether current is a branch. + if (instruction instanceof BranchInstruction) { + final BranchInstruction branch = (BranchInstruction) instruction; + if (instruction instanceof Select) { + // explore all of the select's targets. the default target is handled below. + final Select select = (Select) branch; + final InstructionHandle[] targets = select.getTargets(); + for (final InstructionHandle target : targets) { + branchTargets.push(target, stackDepth); + } + // nothing to fall through to. + ih = null; + } else if (!(branch instanceof IfInstruction)) { + // if an instruction that comes back to following PC, + // push next instruction, with stack depth reduced by 1. + if (opcode == Const.JSR || opcode == Const.JSR_W) { + branchTargets.push(ih.getNext(), stackDepth - 1); + } + ih = null; + } + // for all branches, the target of the branch is pushed on the branch stack. + // conditional branches have a fall through case, selects don't, and + // jsr/jsr_w return to the next instruction. + branchTargets.push(branch.getTarget(), stackDepth); + } else // check for instructions that terminate the method. + if (opcode == Const.ATHROW || opcode == Const.RET || opcode >= Const.IRETURN && opcode <= Const.RETURN) { + ih = null; + } + // normal case, go to the next instruction. + if (ih != null) { + ih = ih.getNext(); + } + // if we have no more instructions, see if there are any deferred branches to explore. + if (ih == null) { + final BranchTarget bt = branchTargets.pop(); + if (bt != null) { + ih = bt.target; + stackDepth = bt.stackDepth; + } + } + } + return maxStackDepth; + } + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator(final BCELComparator comparator) { + bcelComparator = comparator; + } + + private String className; + private Type[] argTypes; + private String[] argNames; + private int maxLocals; + private int maxStack; + private InstructionList il; + + private boolean stripAttributes; + private LocalVariableTypeTable localVariableTypeTable; + private final List variableList = new ArrayList<>(); + + private final List lineNumberList = new ArrayList<>(); + + private final List exceptionList = new ArrayList<>(); + + private final List throwsList = new ArrayList<>(); + + private final List codeAttrsList = new ArrayList<>(); + + private List[] paramAnnotations; // Array of lists containing AnnotationGen objects + + private boolean hasParameterAnnotations; + + private boolean haveUnpackedParameterAnnotations; + + private List observers; + + /** + * Declare method. If the method is non-static the constructor automatically declares a local variable '$this' in slot + * 0. The actual code is contained in the 'il' parameter, which may further manipulated by the user. But they must take + * care not to remove any instruction (handles) that are still referenced from this object. + *

+ * For example one may not add a local variable and later remove the instructions it refers to without causing havoc. It + * is safe however if you remove that local variable, too. + * + * @param accessFlags access qualifiers + * @param returnType method type + * @param argTypes argument types + * @param argNames argument names (if this is null, default names will be provided for them) + * @param methodName name of method + * @param className class name containing this method (may be null, if you don't care) + * @param il instruction list associated with this method, may be null only for abstract or native methods + * @param cp constant pool + */ + public MethodGen(final int accessFlags, final Type returnType, final Type[] argTypes, String[] argNames, final String methodName, final String className, + final InstructionList il, final ConstantPoolGen cp) { + super(accessFlags); + setType(returnType); + setArgumentTypes(argTypes); + setArgumentNames(argNames); + setName(methodName); + setClassName(className); + setInstructionList(il); + setConstantPool(cp); + final boolean abstract_ = isAbstract() || isNative(); + InstructionHandle start = null; + final InstructionHandle end = null; + if (!abstract_) { + start = il.getStart(); + // end == null => live to end of method + /* + * Add local variables, namely the implicit 'this' and the arguments + */ + if (!isStatic() && className != null) { // Instance method -> 'this' is local var 0 + addLocalVariable("this", ObjectType.getInstance(className), start, end); + } + } + if (argTypes != null) { + final int size = argTypes.length; + for (final Type argType : argTypes) { + if (Type.VOID == argType) { + throw new ClassGenException("'void' is an illegal argument type for a method"); + } + } + if (argNames != null) { // Names for variables provided? + if (size != argNames.length) { + throw new ClassGenException("Mismatch in argument array lengths: " + size + " vs. " + argNames.length); + } + } else { // Give them dummy names + argNames = new String[size]; + for (int i = 0; i < size; i++) { + argNames[i] = "arg" + i; + } + setArgumentNames(argNames); + } + if (!abstract_) { + for (int i = 0; i < size; i++) { + addLocalVariable(argNames[i], argTypes[i], start, end); + } + } + } + } + + /** + * Instantiate from existing method. + * + * @param method method + * @param className class name containing this method + * @param cp constant pool + */ + public MethodGen(final Method method, final String className, final ConstantPoolGen cp) { + this(method.getAccessFlags(), Type.getReturnType(method.getSignature()), Type.getArgumentTypes(method.getSignature()), + null /* may be overridden anyway */ + , method.getName(), className, + (method.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0 ? new InstructionList(getByteCodes(method)) : null, cp); + final Attribute[] attributes = method.getAttributes(); + for (final Attribute attribute : attributes) { + Attribute a = attribute; + if (a instanceof Code) { + final Code c = (Code) a; + setMaxStack(c.getMaxStack()); + setMaxLocals(c.getMaxLocals()); + final CodeException[] ces = c.getExceptionTable(); + if (ces != null) { + for (final CodeException ce : ces) { + final int type = ce.getCatchType(); + ObjectType cType = null; + if (type > 0) { + final String cen = method.getConstantPool().getConstantString(type, Const.CONSTANT_Class); + cType = ObjectType.getInstance(cen); + } + final int endPc = ce.getEndPC(); + final int length = getByteCodes(method).length; + InstructionHandle end; + if (length == endPc) { // May happen, because end_pc is exclusive + end = il.getEnd(); + } else { + end = il.findHandle(endPc); + end = end.getPrev(); // Make it inclusive + } + addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce.getHandlerPC()), cType); + } + } + final Attribute[] cAttributes = c.getAttributes(); + for (final Attribute cAttribute : cAttributes) { + a = cAttribute; + if (a instanceof LineNumberTable) { + ((LineNumberTable) a).forEach(l -> { + final InstructionHandle ih = il.findHandle(l.getStartPC()); + if (ih != null) { + addLineNumber(ih, l.getLineNumber()); + } + }); + } else if (a instanceof LocalVariableTable) { + updateLocalVariableTable((LocalVariableTable) a); + } else if (a instanceof LocalVariableTypeTable) { + this.localVariableTypeTable = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); + } else { + addCodeAttribute(a); + } + } + } else if (a instanceof ExceptionTable) { + Collections.addAll(throwsList, ((ExceptionTable) a).getExceptionNames()); + } else if (a instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations) a; + runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false))); + } else { + addAttribute(a); + } + } + } + + /** + * @since 6.0 + */ + public void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + addAll(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries())); + } + + /** + * Add an attribute to the code. Currently, the JVM knows about the LineNumberTable, LocalVariableTable and StackMap + * attributes, where the former two will be generated automatically and the latter is used for the MIDP only. Other + * attributes will be ignored by the JVM but do no harm. + * + * @param a attribute to be added + */ + public void addCodeAttribute(final Attribute a) { + codeAttrsList.add(a); + } + + /** + * Add an exception possibly thrown by this method. + * + * @param className (fully qualified) name of exception + */ + public void addException(final String className) { + throwsList.add(className); + } + + /** + * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling + * is done. + * + * @param startPc Start of region (inclusive) + * @param endPc End of region (inclusive) + * @param handlerPc Where handling is done + * @param catchType class type of handled exception or null if any exception is handled + * @return new exception handler object + */ + public CodeExceptionGen addExceptionHandler(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, + final ObjectType catchType) { + if (startPc == null || endPc == null || handlerPc == null) { + throw new ClassGenException("Exception handler target is null instruction"); + } + final CodeExceptionGen c = new CodeExceptionGen(startPc, endPc, handlerPc, catchType); + exceptionList.add(c); + return c; + } + + /** + * Give an instruction a line number corresponding to the source code line. + * + * @param ih instruction to tag + * @return new line number object + * @see LineNumber + */ + public LineNumberGen addLineNumber(final InstructionHandle ih, final int srcLine) { + final LineNumberGen l = new LineNumberGen(ih, srcLine); + lineNumberList.add(l); + return l; + } + + /** + * Adds a local variable to this method and assigns an index automatically. + * + * @param name variable name + * @param type variable type + * @param start from where the variable is valid, if this is null, it is valid from the start + * @param end until where the variable is valid, if this is null, it is valid to the end + * @return new local variable object + * @see LocalVariable + */ + public LocalVariableGen addLocalVariable(final String name, final Type type, final InstructionHandle start, final InstructionHandle end) { + return addLocalVariable(name, type, maxLocals, start, end); + } + + /** + * Adds a local variable to this method. + * + * @param name variable name + * @param type variable type + * @param slot the index of the local variable, if type is long or double, the next available index is slot+2 + * @param start from where the variable is valid + * @param end until where the variable is valid + * @return new local variable object + * @see LocalVariable + */ + public LocalVariableGen addLocalVariable(final String name, final Type type, final int slot, final InstructionHandle start, final InstructionHandle end) { + return addLocalVariable(name, type, slot, start, end, slot); + } + + /** + * Adds a local variable to this method. + * + * @param name variable name + * @param type variable type + * @param slot the index of the local variable, if type is long or double, the next available index is slot+2 + * @param start from where the variable is valid + * @param end until where the variable is valid + * @param origIndex the index of the local variable prior to any modifications + * @return new local variable object + * @see LocalVariable + */ + public LocalVariableGen addLocalVariable(final String name, final Type type, final int slot, final InstructionHandle start, final InstructionHandle end, + final int origIndex) { + final byte t = type.getType(); + if (t != Const.T_ADDRESS) { + final int add = type.getSize(); + if (slot + add > maxLocals) { + maxLocals = slot + add; + } + final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, origIndex); + int i; + if ((i = variableList.indexOf(l)) >= 0) { + variableList.set(i, l); + } else { + variableList.add(l); + } + return l; + } + throw new IllegalArgumentException("Can not use " + type + " as type for local variable"); + } + + /** + * Add observer for this object. + */ + public void addObserver(final MethodObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + public void addParameterAnnotation(final int parameterIndex, final AnnotationEntryGen annotation) { + ensureExistingParameterAnnotationsUnpacked(); + if (!hasParameterAnnotations) { + @SuppressWarnings({"rawtypes", "unchecked"}) final List[] parmList = (List[]) new List[argTypes.length]; + paramAnnotations = parmList; + hasParameterAnnotations = true; + } + final List existingAnnotations = paramAnnotations[parameterIndex]; + if (existingAnnotations != null) { + existingAnnotations.add(annotation); + } else { + final List l = new ArrayList<>(); + l.add(annotation); + paramAnnotations[parameterIndex] = l; + } + } + + /** + * @since 6.0 + */ + public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + if (attrs != null) { + addAll(attrs); + } + } + + private Attribute[] addRuntimeAnnotationsAsAttribute(final ConstantPoolGen cp) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + addAll(attrs); + return attrs; + } + + private Attribute[] addRuntimeParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return Attribute.EMPTY_ARRAY; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); + addAll(attrs); + return attrs; + } + + private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) { + final LocalVariable[] lv = lvt.getLocalVariableTable(); + for (final LocalVariable element : localVariableTypeTable.getLocalVariableTypeTable()) { + for (final LocalVariable l : lv) { + if (element.getName().equals(l.getName()) && element.getIndex() == l.getOrigIndex()) { + element.setLength(l.getLength()); + element.setStartPC(l.getStartPC()); + element.setIndex(l.getIndex()); + break; + } + } + } + } + + /** + * @return deep copy of this method + */ + public MethodGen copy(final String className, final ConstantPoolGen cp) { + final Method m = ((MethodGen) clone()).getMethod(); + final MethodGen mg = new MethodGen(m, className, super.getConstantPool()); + if (super.getConstantPool() != cp) { + mg.setConstantPool(cp); + mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp); + } + return mg; + } + + /** + * Goes through the attributes on the method and identifies any that are RuntimeParameterAnnotations, extracting their + * contents and storing them as parameter annotations. There are two kinds of parameter annotation - visible and + * invisible. Once they have been unpacked, these attributes are deleted. (The annotations will be rebuilt as attributes + * when someone builds a Method object out of this MethodGen object). + */ + private void ensureExistingParameterAnnotationsUnpacked() { + if (haveUnpackedParameterAnnotations) { + return; + } + // Find attributes that contain parameter annotation data + final Attribute[] attrs = getAttributes(); + ParameterAnnotations paramAnnVisAttr = null; + ParameterAnnotations paramAnnInvisAttr = null; + for (final Attribute attribute : attrs) { + if (attribute instanceof ParameterAnnotations) { + // Initialize paramAnnotations + if (!hasParameterAnnotations) { + @SuppressWarnings({"rawtypes", "unchecked"}) final List[] parmList = (List[]) new List[argTypes.length]; + paramAnnotations = parmList; + Arrays.setAll(paramAnnotations, i -> new ArrayList<>()); + } + hasParameterAnnotations = true; + final ParameterAnnotations rpa = (ParameterAnnotations) attribute; + if (rpa instanceof RuntimeVisibleParameterAnnotations) { + paramAnnVisAttr = rpa; + } else { + paramAnnInvisAttr = rpa; + } + final ParameterAnnotationEntry[] parameterAnnotationEntries = rpa.getParameterAnnotationEntries(); + for (int j = 0; j < parameterAnnotationEntries.length; j++) { + // This returns Annotation[] ... + final ParameterAnnotationEntry immutableArray = rpa.getParameterAnnotationEntries()[j]; + // ... which needs transforming into an AnnotationGen[] ... + final List mutable = makeMutableVersion(immutableArray.getAnnotationEntries()); + // ... then add these to any we already know about + paramAnnotations[j].addAll(mutable); + } + } + } + if (paramAnnVisAttr != null) { + removeAttribute(paramAnnVisAttr); + } + if (paramAnnInvisAttr != null) { + removeAttribute(paramAnnInvisAttr); + } + haveUnpackedParameterAnnotations = true; + } + + /** + * Return value as defined by given BCELComparator strategy. By default two MethodGen objects are said to be equal when + * their names and signatures are equal. + * + * @see Object#equals(Object) + */ + @Override + public boolean equals(final Object obj) { + return bcelComparator.equals(this, obj); + } + + // J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this + // is more likely to suggest to the caller it is readonly (which a List does not). + + /** + * Return a list of AnnotationGen objects representing parameter annotations + * + * @since 6.0 + */ + public List getAnnotationsOnParameter(final int i) { + ensureExistingParameterAnnotationsUnpacked(); + if (!hasParameterAnnotations || i > argTypes.length) { + return null; + } + return paramAnnotations[i]; + } + + public String getArgumentName(final int i) { + return argNames[i]; + } + + public String[] getArgumentNames() { + return argNames.clone(); + } + + public Type getArgumentType(final int i) { + return argTypes[i]; + } + + public Type[] getArgumentTypes() { + return argTypes.clone(); + } + + /** + * @return class that contains this method + */ + public String getClassName() { + return className; + } + + /** + * @return all attributes of this method. + */ + public Attribute[] getCodeAttributes() { + return codeAttrsList.toArray(Attribute.EMPTY_ARRAY); + } + + /** + * @return code exceptions for 'Code' attribute + */ + private CodeException[] getCodeExceptions() { + final int size = exceptionList.size(); + final CodeException[] cExc = new CodeException[size]; + Arrays.setAll(cExc, i -> exceptionList.get(i).getCodeException(super.getConstantPool())); + return cExc; + } + + /* + * @return array of declared exception handlers + */ + public CodeExceptionGen[] getExceptionHandlers() { + return exceptionList.toArray(CodeExceptionGen.EMPTY_ARRAY); + } + + /* + * @return array of thrown exceptions + */ + public String[] getExceptions() { + return throwsList.toArray(Const.EMPTY_STRING_ARRAY); + } + + /** + * @return 'Exceptions' attribute of all the exceptions thrown by this method. + */ + private ExceptionTable getExceptionTable(final ConstantPoolGen cp) { + final int size = throwsList.size(); + final int[] ex = new int[size]; + Arrays.setAll(ex, i -> cp.addClass(throwsList.get(i))); + return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool()); + } + + public InstructionList getInstructionList() { + return il; + } + + /* + * @return array of line numbers + */ + public LineNumberGen[] getLineNumbers() { + return lineNumberList.toArray(LineNumberGen.EMPTY_ARRAY); + } + + /** + * @return 'LineNumberTable' attribute of all the local variables of this method. + */ + public LineNumberTable getLineNumberTable(final ConstantPoolGen cp) { + final int size = lineNumberList.size(); + final LineNumber[] ln = new LineNumber[size]; + Arrays.setAll(ln, i -> lineNumberList.get(i).getLineNumber()); + return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp.getConstantPool()); + } + + /* + * If the range of the variable has not been set yet, it will be set to be valid from the start to the end of the + * instruction list. + * + * @return array of declared local variables sorted by index + */ + public LocalVariableGen[] getLocalVariables() { + final int size = variableList.size(); + final LocalVariableGen[] lg = new LocalVariableGen[size]; + variableList.toArray(lg); + for (int i = 0; i < size; i++) { + if (lg[i].getStart() == null && il != null) { + lg[i].setStart(il.getStart()); + } + if (lg[i].getEnd() == null && il != null) { + lg[i].setEnd(il.getEnd()); + } + } + if (size > 1) { + Arrays.sort(lg, Comparator.comparingInt(LocalVariableGen::getIndex)); + } + return lg; + } + + /** + * @return 'LocalVariableTable' attribute of all the local variables of this method. + */ + public LocalVariableTable getLocalVariableTable(final ConstantPoolGen cp) { + final LocalVariableGen[] lg = getLocalVariables(); + final int size = lg.length; + final LocalVariable[] lv = new LocalVariable[size]; + Arrays.setAll(lv, i -> lg[i].getLocalVariable(cp)); + return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), 2 + lv.length * 10, lv, cp.getConstantPool()); + } + + /** + * @return 'LocalVariableTypeTable' attribute of this method. + */ + public LocalVariableTypeTable getLocalVariableTypeTable() { + return localVariableTypeTable; + } + + public int getMaxLocals() { + return maxLocals; + } + + public int getMaxStack() { + return maxStack; + } + + /** + * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively, before calling this method + * (the same applies for max locals). + * + * @return method object + */ + public Method getMethod() { + final String signature = getSignature(); + final ConstantPoolGen cp = super.getConstantPool(); + final int nameIndex = cp.addUtf8(super.getName()); + final int signatureIndex = cp.addUtf8(signature); + /* + * Also updates positions of instructions, i.e., their indices + */ + final byte[] byteCode = il != null ? il.getByteCode() : null; + LineNumberTable lnt = null; + LocalVariableTable lvt = null; + /* + * Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.) + */ + if (!variableList.isEmpty() && !stripAttributes) { + updateLocalVariableTable(getLocalVariableTable(cp)); + addCodeAttribute(lvt = getLocalVariableTable(cp)); + } + if (localVariableTypeTable != null) { + // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with + // LocalVariableTable. + if (lvt != null) { + adjustLocalVariableTypeTable(lvt); + } + addCodeAttribute(localVariableTypeTable); + } + if (!lineNumberList.isEmpty() && !stripAttributes) { + addCodeAttribute(lnt = getLineNumberTable(cp)); + } + final Attribute[] codeAttrs = getCodeAttributes(); + /* + * Each attribute causes 6 additional header bytes + */ + int attrsLen = 0; + for (final Attribute codeAttr : codeAttrs) { + attrsLen += codeAttr.getLength() + 6; + } + final CodeException[] cExc = getCodeExceptions(); + final int excLen = cExc.length * 8; // Every entry takes 8 bytes + Code code = null; + if (byteCode != null && !isAbstract() && !isNative()) { + // Remove any stale code attribute + final Attribute[] attributes = getAttributes(); + for (final Attribute a : attributes) { + if (a instanceof Code) { + removeAttribute(a); + } + } + code = new Code(cp.addUtf8("Code"), 8 + byteCode.length + // prologue byte code + 2 + excLen + // exceptions + 2 + attrsLen, // attributes + maxStack, maxLocals, byteCode, cExc, codeAttrs, cp.getConstantPool()); + addAttribute(code); + } + final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(cp); + final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(cp); + ExceptionTable et = null; + if (!throwsList.isEmpty()) { + addAttribute(et = getExceptionTable(cp)); + // Add 'Exceptions' if there are "throws" clauses + } + final Method m = new Method(super.getAccessFlags(), nameIndex, signatureIndex, getAttributes(), cp.getConstantPool()); + // Undo effects of adding attributes + if (lvt != null) { + removeCodeAttribute(lvt); + } + if (localVariableTypeTable != null) { + removeCodeAttribute(localVariableTypeTable); + } + if (lnt != null) { + removeCodeAttribute(lnt); + } + if (code != null) { + removeAttribute(code); + } + if (et != null) { + removeAttribute(et); + } + removeRuntimeAttributes(annotations); + removeRuntimeAttributes(parameterAnnotations); + return m; + } + + public Type getReturnType() { + return getType(); + } + + @Override + public String getSignature() { + return Type.getMethodSignature(super.getType(), argTypes); + } + + /** + * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR + * signature. + * + * @see Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + private List makeMutableVersion(final AnnotationEntry[] mutableArray) { + final List result = new ArrayList<>(); + for (final AnnotationEntry element : mutableArray) { + result.add(new AnnotationEntryGen(element, getConstantPool(), false)); + } + return result; + } + + /** + * Remove a code attribute. + */ + public void removeCodeAttribute(final Attribute a) { + codeAttrsList.remove(a); + } + + /** + * Remove all code attributes. + */ + public void removeCodeAttributes() { + localVariableTypeTable = null; + codeAttrsList.clear(); + } + + /** + * Remove an exception. + */ + public void removeException(final String c) { + throwsList.remove(c); + } + + /** + * Remove an exception handler. + */ + public void removeExceptionHandler(final CodeExceptionGen c) { + exceptionList.remove(c); + } + + /** + * Remove all line numbers. + */ + public void removeExceptionHandlers() { + exceptionList.clear(); + } + + /** + * Remove all exceptions. + */ + public void removeExceptions() { + throwsList.clear(); + } + + /** + * Remove a line number. + */ + public void removeLineNumber(final LineNumberGen l) { + lineNumberList.remove(l); + } + + /** + * Remove all line numbers. + */ + public void removeLineNumbers() { + lineNumberList.clear(); + } + + /** + * Remove a local variable, its slot will not be reused, if you do not use addLocalVariable with an explicit index + * argument. + */ + public void removeLocalVariable(final LocalVariableGen l) { + variableList.remove(l); + } + + /** + * Remove all local variables. + */ + public void removeLocalVariables() { + variableList.clear(); + } + + /** + * Remove the LocalVariableTypeTable + */ + public void removeLocalVariableTypeTable() { + localVariableTypeTable = null; + } + + /** + * Remove all NOPs from the instruction list (if possible) and update every object referring to them, i.e., branch + * instructions, local variables and exception handlers. + */ + public void removeNOPs() { + if (il != null) { + InstructionHandle next; + /* + * Check branch instructions. + */ + for (InstructionHandle ih = il.getStart(); ih != null; ih = next) { + next = ih.getNext(); + if (next != null && ih.getInstruction() instanceof NOP) { + try { + il.delete(ih); + } catch (final TargetLostException e) { + for (final InstructionHandle target : e.getTargets()) { + for (final InstructionTargeter targeter : target.getTargeters()) { + targeter.updateTarget(target, next); + } + } + } + } + } + } + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final MethodObserver o) { + if (observers != null) { + observers.remove(o); + } + } + + /** + * Would prefer to make this private, but need a way to test if client is using BCEL version 6.5.0 or later that + * contains fix for BCEL-329. + * + * @since 6.5.0 + */ + public void removeRuntimeAttributes(final Attribute[] attrs) { + for (final Attribute attr : attrs) { + removeAttribute(attr); + } + } + + public void setArgumentName(final int i, final String name) { + argNames[i] = name; + } + + public void setArgumentNames(final String[] argNames) { + this.argNames = argNames; + } + + public void setArgumentType(final int i, final Type type) { + argTypes[i] = type; + } + + public void setArgumentTypes(final Type[] argTypes) { + this.argTypes = argTypes; + } + + public void setClassName(final String className) { // TODO could be package-protected? + this.className = className; + } + + public void setInstructionList(final InstructionList il) { // TODO could be package-protected? + this.il = il; + } + + /** + * Compute maximum number of local variables. + */ + public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) + if (il != null) { + int max = isStatic() ? 0 : 1; + if (argTypes != null) { + for (final Type argType : argTypes) { + max += argType.getSize(); + } + } + for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { + final Instruction ins = ih.getInstruction(); + if (ins instanceof LocalVariableInstruction || ins instanceof RET || ins instanceof IINC) { + final int index = ((IndexedInstruction) ins).getIndex() + ((TypedInstruction) ins).getType(super.getConstantPool()).getSize(); + if (index > max) { + max = index; + } + } + } + maxLocals = max; + } else { + maxLocals = 0; + } + } + + /** + * Set maximum number of local variables. + */ + public void setMaxLocals(final int m) { + maxLocals = m; + } + + /** + * Computes max. stack size by performing control flow analysis. + */ + public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) + if (il != null) { + maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); + } else { + maxStack = 0; + } + } + + /** + * Set maximum stack size for this method. + */ + public void setMaxStack(final int m) { // TODO could be package-protected? + maxStack = m; + } + + public void setReturnType(final Type returnType) { + setType(returnType); + } + + /** + * Do not/Do produce attributes code attributesLineNumberTable and LocalVariableTable, like javac -O + */ + public void stripAttributes(final boolean flag) { + stripAttributes = flag; + } + + /** + * Return string representation close to declaration format, 'public static void main(String[]) throws IOException', + * e.g. + * + * @return String representation of the method. + */ + @Override + public final String toString() { + final String access = Utility.accessToString(super.getAccessFlags()); + String signature = Type.getMethodSignature(super.getType(), argTypes); + signature = Utility.methodSignatureToString(signature, super.getName(), access, true, getLocalVariableTable(super.getConstantPool())); + final StringBuilder buf = new StringBuilder(signature); + for (final Attribute a : getAttributes()) { + if (!(a instanceof Code || a instanceof ExceptionTable)) { + buf.append(" [").append(a).append("]"); + } + } + + if (!throwsList.isEmpty()) { + for (final String throwsDescriptor : throwsList) { + buf.append("\n\t\tthrows ").append(throwsDescriptor); + } + } + return buf.toString(); + } + + /** + * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but + * has to be called by the user after they have finished editing the object. + */ + public void update() { + if (observers != null) { + for (final MethodObserver observer : observers) { + observer.notify(this); + } + } + } + + private void updateLocalVariableTable(final LocalVariableTable a) { + removeLocalVariables(); + for (final LocalVariable l : a.getLocalVariableTable()) { + InstructionHandle start = il.findHandle(l.getStartPC()); + final InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); + // Repair malformed handles + if (null == start) { + start = il.getStart(); + } + // end == null => live to end of method + // Since we are recreating the LocalVaraible, we must + // propagate the orig_index to new copy. + addLocalVariable(l.getName(), Type.getType(l.getSignature()), l.getIndex(), start, end, l.getOrigIndex()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java new file mode 100644 index 0000000..22e773e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/MethodObserver.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Implement this interface if you're interested in changes to a MethodGen object and register yourself with + * addObserver(). + */ +public interface MethodObserver { + + void notify(MethodGen method); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java new file mode 100644 index 0000000..a54d58b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEW.java @@ -0,0 +1,72 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * NEW - Create new object + * + *

+ * Stack: ... -> ..., objectref
+ * 
+ */ +public class NEW extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + NEW() { + } + + public NEW(final int index) { + super(com.sun.org.apache.bcel.internal.Const.NEW, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitLoadClass(this); + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitNEW(this); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.INSTANTIATION_ERROR); + } + + @Override + public ObjectType getLoadClassType(final ConstantPoolGen cpg) { + return (ObjectType) getType(cpg); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java new file mode 100644 index 0000000..e8f52df --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.ExceptionConst; +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * NEWARRAY - Create new array of basic type (int, short, ...) + * + *
+ * Stack: ..., count -> ..., arrayref
+ * 
+ *

+ * type must be one of T_INT, T_SHORT, ... + * + * @LastModified: Jan 2020 + */ +public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower, StackProducer { + + private byte type; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + NEWARRAY() { + } + + public NEWARRAY(final BasicType type) { + this(type.getType()); + } + + public NEWARRAY(final byte type) { + super(com.sun.org.apache.bcel.internal.Const.NEWARRAY, (short) 2); + this.type = type; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitNEWARRAY(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + out.writeByte(type); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION}; + } + + /** + * @return type of constructed array + */ + public final Type getType() { + return new ArrayType(BasicType.getType(type), 1); + } + + /** + * @return numeric code for basic element type + */ + public final byte getTypecode() { + return type; + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + type = bytes.readByte(); + super.setLength(2); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + com.sun.org.apache.bcel.internal.Const.getTypeName(type); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java new file mode 100644 index 0000000..37f7395 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NOP.java @@ -0,0 +1,43 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * NOP - Do nothing + */ +public class NOP extends Instruction { + + public NOP() { + super(com.sun.org.apache.bcel.internal.Const.NOP, (short) 1); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitNOP(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java new file mode 100644 index 0000000..3b79c82 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java @@ -0,0 +1,67 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.classfile.ConstantCP; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; + +/** + * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have names and signatures + * + * @since 6.0 + */ +public abstract class NameSignatureInstruction extends CPInstruction { + + public NameSignatureInstruction() { + } + + public NameSignatureInstruction(final short opcode, final int index) { + super(opcode, index); + } + + /** + * @return name of referenced method/field. + */ + public String getName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantNameAndType cnat = getNameAndType(cpg); + return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes(); + } + + public ConstantNameAndType getNameAndType(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + return (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + } + + /** + * @return signature of referenced method/field. + */ + public String getSignature(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantNameAndType cnat = getNameAndType(cpg); + return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes(); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java new file mode 100644 index 0000000..a46e7aa --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java @@ -0,0 +1,36 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote entity that has both name and type. This is true for local variables, methods and fields. + */ +public interface NamedAndTyped { + + String getName(); + + Type getType(); + + void setName(String name); + + void setType(Type type); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java new file mode 100644 index 0000000..2be7a81 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ObjectType.java @@ -0,0 +1,160 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Denotes reference such as java.lang.String. + */ +public class ObjectType extends ReferenceType { + + /** + * Constructs a new instance. + * + * @param className fully qualified class name, e.g. java.lang.String + * @return a new instance. + * @since 6.0 + */ + public static ObjectType getInstance(final String className) { + return new ObjectType(className); + } + + private final String className; // Class name of type + + /** + * Constructs a new instance. + * + * @param className fully qualified class name, e.g. java.lang.String + */ + public ObjectType(final String className) { + super(Const.T_REFERENCE, "L" + Utility.packageToPath(className) + ";"); + this.className = Utility.pathToPackage(className); + } + + /** + * Java Virtual Machine Specification edition 2, 5.4.4 Access Control + * + * @throws ClassNotFoundException if the class referenced by this type can't be found + */ + public boolean accessibleTo(final ObjectType accessor) throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(className); + if (jc.isPublic()) { + return true; + } + final JavaClass acc = Repository.lookupClass(accessor.className); + return acc.getPackageName().equals(jc.getPackageName()); + } + + /** + * @return true if both type objects refer to the same class. + */ + @Override + public boolean equals(final Object type) { + return type instanceof ObjectType && ((ObjectType) type).className.equals(className); + } + + /** + * @return name of referenced class + */ + @Override + public String getClassName() { + return className; + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return className.hashCode(); + } + + /** + * If "this" doesn't reference a class, it references an interface or a non-existant entity. + * + * @deprecated (since 6.0) this method returns an inaccurate result if the class or interface referenced cannot be + * found: use referencesClassExact() instead + */ + @Deprecated + public boolean referencesClass() { + try { + final JavaClass jc = Repository.lookupClass(className); + return jc.isClass(); + } catch (final ClassNotFoundException e) { + return false; + } + } + + /** + * Return true if this type references a class, false if it references an interface. + * + * @return true if the type references a class, false if it references an interface + * @throws ClassNotFoundException if the class or interface referenced by this type can't be found + */ + public boolean referencesClassExact() throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(className); + return jc.isClass(); + } + + /** + * If "this" doesn't reference an interface, it references a class or a non-existant entity. + * + * @deprecated (since 6.0) this method returns an inaccurate result if the class or interface referenced cannot be + * found: use referencesInterfaceExact() instead + */ + @Deprecated + public boolean referencesInterface() { + try { + final JavaClass jc = Repository.lookupClass(className); + return !jc.isClass(); + } catch (final ClassNotFoundException e) { + return false; + } + } + + /** + * Return true if this type references an interface, false if it references a class. + * + * @return true if the type references an interface, false if it references a class + * @throws ClassNotFoundException if the class or interface referenced by this type can't be found + */ + public boolean referencesInterfaceExact() throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(className); + return !jc.isClass(); + } + + /** + * Return true if this type is a subclass of given ObjectType. + * + * @throws ClassNotFoundException if any of this class's superclasses can't be found + */ + public boolean subclassOf(final ObjectType superclass) throws ClassNotFoundException { + if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) { + return false; + } + return Repository.instanceOf(this.className, superclass.className); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java new file mode 100644 index 0000000..e826dd7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * POP - Pop top operand stack word + * + *

+ * Stack: ..., word -> ...
+ * 
+ */ +public class POP extends StackInstruction implements PopInstruction { + + public POP() { + super(com.sun.org.apache.bcel.internal.Const.POP); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java new file mode 100644 index 0000000..5124f41 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/POP2.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * POP2 - Pop two top operand stack words + * + *
+ * Stack: ..., word2, word1 -> ...
+ * 
+ */ +public class POP2 extends StackInstruction implements PopInstruction { + + public POP2() { + super(com.sun.org.apache.bcel.internal.Const.POP2); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP2(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java new file mode 100644 index 0000000..3bec045 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUSH.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Wrapper class for push operations, which are implemented either as BIPUSH, LDC or xCONST_n instructions. + * + * @LastModified: Feb 2023 + */ +public final class PUSH implements CompoundInstruction, VariableLengthInstruction { + + private final Instruction instruction; + + /** + * Pushes an array type constant, for example {@code int[].class}, {@code String[].class}, and so on. + * + * @param cp generated constant pool. + * @param value to be pushed. + * @since 6.7.0 + */ + public PUSH(final ConstantPoolGen cp, final ArrayType value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addArrayClass(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final boolean value) { + Objects.requireNonNull(cp, "cp"); + instruction = InstructionConst.getInstruction(Const.ICONST_0 + (value ? 1 : 0)); + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Boolean value) { + this(cp, value.booleanValue()); + } + + /** + * creates a push object from a Character value. Warning: Make sure not to attempt to allow autoboxing to create this + * value parameter, as an alternative constructor will be called + * + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Character value) { + this(cp, value.charValue()); + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final double value) { + if (value == 0.0) { + instruction = InstructionConst.DCONST_0; + } else if (value == 1.0) { + instruction = InstructionConst.DCONST_1; + } else { + instruction = new LDC2_W(cp.addDouble(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final float value) { + if (value == 0.0) { + instruction = InstructionConst.FCONST_0; + } else if (value == 1.0) { + instruction = InstructionConst.FCONST_1; + } else if (value == 2.0) { + instruction = InstructionConst.FCONST_2; + } else { + instruction = new LDC(cp.addFloat(value)); + } + } + + /** + * This constructor also applies for values of type short, char, byte + * + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final int value) { + if (value >= -1 && value <= 5) { + instruction = InstructionConst.getInstruction(Const.ICONST_0 + value); + } else if (Instruction.isValidByte(value)) { + instruction = new BIPUSH((byte) value); + } else if (Instruction.isValidShort(value)) { + instruction = new SIPUSH((short) value); + } else { + instruction = new LDC(cp.addInteger(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final long value) { + if (value == 0) { + instruction = InstructionConst.LCONST_0; + } else if (value == 1) { + instruction = InstructionConst.LCONST_1; + } else { + instruction = new LDC2_W(cp.addLong(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Number value) { + if (value instanceof Integer || value instanceof Short || value instanceof Byte) { + instruction = new PUSH(cp, value.intValue()).instruction; + } else if (value instanceof Double) { + instruction = new PUSH(cp, value.doubleValue()).instruction; + } else if (value instanceof Float) { + instruction = new PUSH(cp, value.floatValue()).instruction; + } else if (value instanceof Long) { + instruction = new PUSH(cp, value.longValue()).instruction; + } else { + throw new ClassGenException("What's this: " + value); + } + } + + /** + * @param cp + * @param value + * @since 6.0 + */ + public PUSH(final ConstantPoolGen cp, final ObjectType value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addClass(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final String value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addString(value)); + } + } + + public Instruction getInstruction() { + return instruction; + } + + @Override + public InstructionList getInstructionList() { + return new InstructionList(instruction); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString() { + return instruction + " (PUSH)"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java new file mode 100644 index 0000000..e236675 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java @@ -0,0 +1,81 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * PUTFIELD - Put field in object + * + *
+ * Stack: ..., objectref, value -> ...
+ * 
+ *

+ * OR + * + *

+ * Stack: ..., objectref, value.word1, value.word2 -> ...
+ * 
+ */ +public class PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + PUTFIELD() { + } + + public PUTFIELD(final int index) { + super(Const.PUTFIELD, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitTypedInstruction(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitFieldInstruction(this); + v.visitPUTFIELD(this); + } + + @Override + public int consumeStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg) + 1; + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java new file mode 100644 index 0000000..54ab3e7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java @@ -0,0 +1,80 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * PUTSTATIC - Put static field in class + * + *
+ * Stack: ..., value -> ...
+ * 
+ *

+ * OR + * + *

+ * Stack: ..., value.word1, value.word2 -> ...
+ * 
+ */ +public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + PUTSTATIC() { + } + + public PUTSTATIC(final int index) { + super(Const.PUTSTATIC, index); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitTypedInstruction(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitFieldInstruction(this); + v.visitPUTSTATIC(this); + } + + @Override + public int consumeStack(final ConstantPoolGen cpg) { + return getFieldSize(cpg); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java new file mode 100644 index 0000000..2062999 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PopInstruction.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to pop a value on top from the stack, such as ISTORE, POP, PUTSTATIC. + * + * @see ISTORE + * @see POP + */ +public interface PopInstruction extends StackConsumer { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java new file mode 100644 index 0000000..e2f8572 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/PushInstruction.java @@ -0,0 +1,36 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to produce a value on top of the stack, such as ILOAD, LDC, SIPUSH, DUP, + * ICONST, etc. + * + * @see ILOAD + * @see ICONST + * @see LDC + * @see DUP + * @see SIPUSH + * @see GETSTATIC + */ +public interface PushInstruction extends StackProducer { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java new file mode 100644 index 0000000..a7cacc7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RET.java @@ -0,0 +1,140 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * RET - Return from subroutine + * + *
+ * Stack: ... -> ...
+ * 
+ */ +public class RET extends Instruction implements IndexedInstruction, TypedInstruction { + + private boolean wide; + private int index; // index to local variable containg the return address + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + RET() { + } + + public RET(final int index) { + super(com.sun.org.apache.bcel.internal.Const.RET, (short) 2); + setIndex(index); // May set wide as side effect + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitRET(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + if (wide) { + out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (wide) { + out.writeShort(index); + } else { + out.writeByte(index); + } + } + + /** + * @return index of local variable containg the return address + */ + @Override + public final int getIndex() { + return index; + } + + /** + * @return return address type + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return ReturnaddressType.NO_TARGET; + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + this.wide = wide; + if (wide) { + index = bytes.readUnsignedShort(); + super.setLength(4); + } else { + index = bytes.readUnsignedByte(); + super.setLength(2); + } + } + + /** + * Set index of local variable containg the return address + */ + @Override + public final void setIndex(final int n) { + if (n < 0) { + throw new ClassGenException("Negative index value: " + n); + } + index = n; + setWide(); + } + + private void setWide() { + wide = index > com.sun.org.apache.bcel.internal.Const.MAX_BYTE; + if (wide) { + super.setLength(4); // Including the wide byte + } else { + super.setLength(2); + } + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + index; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java new file mode 100644 index 0000000..0e6b594 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/RETURN.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * RETURN - Return from void method + * + *
+ * Stack: ... -> <empty>
+ * 
+ */ +public class RETURN extends ReturnInstruction { + + public RETURN() { + super(com.sun.org.apache.bcel.internal.Const.RETURN); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitRETURN(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java new file mode 100644 index 0000000..a6f3831 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReferenceType.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Super class for object and array types. + */ +public abstract class ReferenceType extends Type { + + /** + * Class is non-abstract but not instantiable from the outside + */ + ReferenceType() { + super(Const.T_OBJECT, ""); + } + + protected ReferenceType(final byte t, final String s) { + super(t, s); + } + + /** + * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an + * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t + * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If + * "this" or t is an ArrayType, then Type.OBJECT is returned. If "this" or t is a ReferenceType referencing an + * interface, then Type.OBJECT is returned. If not all of the two classes' superclasses cannot be found, "null" is + * returned. See the JVM specification edition 2, "4.9.2 The Bytecode Verifier". + * + * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter + * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics. + */ + @Deprecated + public ReferenceType firstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t; + } + if (t.equals(Type.NULL) || this.equals(t)) { + return this; + /* + * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also + * say all the objects referenced by Type.NULL were derived from java.lang.Object. However, the Java Language's + * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :) + */ + } + if (this instanceof ArrayType || t instanceof ArrayType) { + return Type.OBJECT; + // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType? + } + return getFirstCommonSuperclassInternal(t); + } + + /** + * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an + * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t + * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If + * "this" or t is an ArrayType, then Type.OBJECT is returned; unless their dimensions match. Then an ArrayType of the + * same number of dimensions is returned, with its basic type being the first common super class of the basic types of + * "this" and t. If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned. If not all of + * the two classes' superclasses cannot be found, "null" is returned. See the JVM specification edition 2, "4.9.2 The + * Bytecode Verifier". + * + * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter + */ + public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t; + } + if (t.equals(Type.NULL) || this.equals(t)) { + return this; + /* + * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also + * say all the objects referenced by Type.NULL were derived from java.lang.Object. However, the Java Language's + * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :) + */ + } + /* This code is from a bug report by Konstantin Shagin */ + if (this instanceof ArrayType && t instanceof ArrayType) { + final ArrayType arrType1 = (ArrayType) this; + final ArrayType arrType2 = (ArrayType) t; + if (arrType1.getDimensions() == arrType2.getDimensions() && arrType1.getBasicType() instanceof ObjectType + && arrType2.getBasicType() instanceof ObjectType) { + return new ArrayType(((ObjectType) arrType1.getBasicType()).getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), + arrType1.getDimensions()); + } + } + if (this instanceof ArrayType || t instanceof ArrayType) { + return Type.OBJECT; + // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType? + } + return getFirstCommonSuperclassInternal(t); + } + + private ReferenceType getFirstCommonSuperclassInternal(final ReferenceType t) throws ClassNotFoundException { + if (this instanceof ObjectType && ((ObjectType) this).referencesInterfaceExact() + || t instanceof ObjectType && ((ObjectType) t).referencesInterfaceExact()) { + return Type.OBJECT; + // TODO: The above line is correct comparing to the vmspec2. But one could + // make class file verification a bit stronger here by using the notion of + // superinterfaces or even castability or assignment compatibility. + } + // this and t are ObjectTypes, see above. + final ObjectType thiz = (ObjectType) this; + final ObjectType other = (ObjectType) t; + final JavaClass[] thizSups = Repository.getSuperClasses(thiz.getClassName()); + final JavaClass[] otherSups = Repository.getSuperClasses(other.getClassName()); + if (thizSups == null || otherSups == null) { + return null; + } + // Waaahh... + final JavaClass[] thisSups = new JavaClass[thizSups.length + 1]; + final JavaClass[] tSups = new JavaClass[otherSups.length + 1]; + System.arraycopy(thizSups, 0, thisSups, 1, thizSups.length); + System.arraycopy(otherSups, 0, tSups, 1, otherSups.length); + thisSups[0] = Repository.lookupClass(thiz.getClassName()); + tSups[0] = Repository.lookupClass(other.getClassName()); + for (final JavaClass tSup : tSups) { + for (final JavaClass thisSup : thisSups) { + if (thisSup.equals(tSup)) { + return ObjectType.getInstance(thisSup.getClassName()); + } + } + } + // Huh? Did you ask for Type.OBJECT's superclass?? + return null; + } + + /** + * Return true iff this is assignment compatible with another type t as defined in the JVM specification; see the + * AASTORE definition there. + * + * @throws ClassNotFoundException if any classes or interfaces required to determine assignment compatibility can't be + * found + */ + public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundException { + if (!(t instanceof ReferenceType)) { + return false; + } + final ReferenceType T = (ReferenceType) t; + if (this.equals(Type.NULL)) { + return true; // This is not explicitly stated, but clear. Isn't it? + } + /* + * If this is a class type then + */ + if (this instanceof ObjectType && ((ObjectType) this).referencesClassExact()) { + /* + * If T is a class type, then this must be the same class as T, or this must be a subclass of T; + */ + if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() + && (this.equals(T) || Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { + return true; + } + /* + * If T is an interface type, this must implement interface T. + */ + if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact() + && Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName())) { + return true; + } + } + /* + * If this is an interface type, then: + */ + if (this instanceof ObjectType && ((ObjectType) this).referencesInterfaceExact()) { + /* + * If T is a class type, then T must be Object (2.4.7). + */ + if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) { + return true; + } + /* + * If T is an interface type, then T must be the same interface as this or a superinterface of this (2.13.2). + */ + if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact() + && (this.equals(T) || Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { + return true; + } + } + /* + * If this is an array type, namely, the type SC[], that is, an array of components of type SC, then: + */ + if (this instanceof ArrayType) { + /* + * If T is a class type, then T must be Object (2.4.7). + */ + if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) { + return true; + } + /* + * If T is an array type TC[], that is, an array of components of type TC, then one of the following must be true: + */ + if (T instanceof ArrayType) { + /* + * TC and SC are the same primitive type (2.4.1). + */ + final Type sc = ((ArrayType) this).getElementType(); + final Type tc = ((ArrayType) T).getElementType(); + if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc)) { + return true; + } + /* + * TC and SC are reference types (2.4.6), and type SC is assignable to TC by these runtime rules. + */ + if (tc instanceof ReferenceType && sc instanceof ReferenceType && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) { + return true; + } + } + /* If T is an interface type, T must be one of the interfaces implemented by arrays (2.15). */ + // TODO: Check if this is still valid or find a way to dynamically find out which + // interfaces arrays implement. However, as of the JVM specification edition 2, there + // are at least two different pages where assignment compatibility is defined and + // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or + // 'java.io.Serializable'" + if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact()) { + for (final String element : Const.getInterfacesImplementedByArrays()) { + if (T.equals(ObjectType.getInstance(element))) { + return true; + } + } + } + } + return false; // default. + } + + /** + * Return true iff this type is castable to another type t as defined in the JVM specification. The case where this is + * Type.NULL is not defined (see the CHECKCAST definition in the JVM specification). However, because e.g. CHECKCAST + * doesn't throw a ClassCastException when casting a null reference to any Object, true is returned in this case. + * + * @throws ClassNotFoundException if any classes or interfaces required to determine assignment compatibility can't be + * found + */ + public boolean isCastableTo(final Type t) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible() + } + return isAssignmentCompatibleWith(t); + /* + * Yes, it's true: It's the same definition. See vmspec2 AASTORE / CHECKCAST definitions. + */ + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java new file mode 100644 index 0000000..48ebc24 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.ExceptionConst; + +/** + * Super class for the xRETURN family of instructions. + * + * @LastModified: Feb 2023 + */ +public abstract class ReturnInstruction extends Instruction implements ExceptionThrower, TypedInstruction, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + ReturnInstruction() { + } + + /** + * @param opcode of instruction + */ + protected ReturnInstruction(final short opcode) { + super(opcode, (short) 1); + } + + @Override + public Class[] getExceptions() { + return new Class[]{ExceptionConst.ILLEGAL_MONITOR_STATE}; + } + + public Type getType() { + final short opcode = super.getOpcode(); + switch (opcode) { + case Const.IRETURN: + return Type.INT; + case Const.LRETURN: + return Type.LONG; + case Const.FRETURN: + return Type.FLOAT; + case Const.DRETURN: + return Type.DOUBLE; + case Const.ARETURN: + return Type.OBJECT; + case Const.RETURN: + return Type.VOID; + default: // Never reached + throw new ClassGenException("Unknown type " + opcode); + } + } + + /** + * @return type associated with the instruction + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return getType(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java new file mode 100644 index 0000000..cbe613a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java @@ -0,0 +1,83 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import com.sun.org.apache.bcel.internal.Const; + +/** + * Returnaddress, the type JSR or JSR_W instructions push upon the stack. + *

+ * see vmspec2 3.3.3 + */ +public class ReturnaddressType extends Type { + + public static final ReturnaddressType NO_TARGET = new ReturnaddressType(); + private InstructionHandle returnTarget; + + /** + * A Returnaddress [that doesn't know where to return to]. + */ + private ReturnaddressType() { + super(Const.T_ADDRESS, ""); + } + + /** + * Creates a ReturnaddressType object with a target. + */ + public ReturnaddressType(final InstructionHandle returnTarget) { + super(Const.T_ADDRESS, ""); + this.returnTarget = returnTarget; + } + + /** + * Returns if the two Returnaddresses refer to the same target. + */ + @Override + public boolean equals(final Object rat) { + if (!(rat instanceof ReturnaddressType)) { + return false; + } + final ReturnaddressType that = (ReturnaddressType) rat; + if (this.returnTarget == null || that.returnTarget == null) { + return that.returnTarget == this.returnTarget; + } + return that.returnTarget.equals(this.returnTarget); + } + + /** + * @return the target of this ReturnaddressType + */ + public InstructionHandle getTarget() { + return returnTarget; + } + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + if (returnTarget == null) { + return 0; + } + return returnTarget.hashCode(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java new file mode 100644 index 0000000..9499e56 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SALOAD.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SALOAD - Load short from array + * + *

+ * Stack: ..., arrayref, index -> ..., value
+ * 
+ */ +public class SALOAD extends ArrayInstruction implements StackProducer { + + public SALOAD() { + super(com.sun.org.apache.bcel.internal.Const.SALOAD); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSALOAD(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java new file mode 100644 index 0000000..c9c42d3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SASTORE.java @@ -0,0 +1,51 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SASTORE - Store into short array + * + *
+ * Stack: ..., arrayref, index, value -> ...
+ * 
+ */ +public class SASTORE extends ArrayInstruction implements StackConsumer { + + public SASTORE() { + super(com.sun.org.apache.bcel.internal.Const.SASTORE); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSASTORE(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java new file mode 100644 index 0000000..513495e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SIPUSH.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * SIPUSH - Push short + * + *
+ * Stack: ... -> ..., value
+ * 
+ */ +public class SIPUSH extends Instruction implements ConstantPushInstruction { + + private short b; + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + SIPUSH() { + } + + public SIPUSH(final short b) { + super(com.sun.org.apache.bcel.internal.Const.SIPUSH, (short) 3); + this.b = b; + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitSIPUSH(this); + } + + /** + * Dump instruction as short code to stream out. + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + out.writeShort(b); + } + + /** + * @return Type.SHORT + */ + @Override + public Type getType(final ConstantPoolGen cp) { + return Type.SHORT; + } + + @Override + public Number getValue() { + return Integer.valueOf(b); + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.setLength(3); + b = bytes.readShort(); + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + return super.toString(verbose) + " " + b; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java new file mode 100644 index 0000000..e3c0a46 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWAP.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * SWAP - Swa top operand stack word + * + *
+ * Stack: ..., word2, word1 -> ..., word1, word2
+ * 
+ */ +public class SWAP extends StackInstruction implements StackConsumer, StackProducer { + + public SWAP() { + super(com.sun.org.apache.bcel.internal.Const.SWAP); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitStackInstruction(this); + v.visitSWAP(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java new file mode 100644 index 0000000..d5cbdd3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SWITCH.java @@ -0,0 +1,139 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.util.Arrays; + +/** + * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or TABLESWITCH instruction, depending on + * whether the match values (int[]) can be sorted with no gaps between the numbers. + */ +public final class SWITCH implements CompoundInstruction { + + /** + * @return match is sorted in ascending order with no gap bigger than maxGap? + */ + private static boolean matchIsOrdered(final int[] match, final int matchLength, final int maxGap) { + for (int i = 1; i < matchLength; i++) { + if (match[i] - match[i - 1] > maxGap) { + return false; + } + } + return true; + } + + /** + * Sorts match and targets array with QuickSort. + */ + private static void sort(final int l, final int r, final int[] match, final InstructionHandle[] targets) { + int i = l; + int j = r; + int h; + final int m = match[l + r >>> 1]; + InstructionHandle h2; + do { + while (match[i] < m) { + i++; + } + while (m < match[j]) { + j--; + } + if (i <= j) { + h = match[i]; + match[i] = match[j]; + match[j] = h; // Swap elements + h2 = targets[i]; + targets[i] = targets[j]; + targets[j] = h2; // Swap instructions, too + i++; + j--; + } + } while (i <= j); + if (l < j) { + sort(l, j, match, targets); + } + if (i < r) { + sort(i, r, match, targets); + } + } + + private final Select instruction; + + public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target) { + this(match, targets, target, 1); + } + + /** + * Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than + * maxGap between the numbers, a TABLESWITCH instruction is generated, and a LOOKUPSWITCH otherwise. The former may be + * more efficient, but needs more space. + *

+ * Note, that the key array always will be sorted, though we leave the original arrays unaltered. + * + * @param match array of match values (case 2: ... case 7: ..., etc.) + * @param targets the instructions to be branched to for each case + * @param target the default target + * @param maxGap maximum gap that may between case branches + */ + public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int maxGap) { + int[] matchClone = match.clone(); + final InstructionHandle[] targetsClone = targets.clone(); + final int matchLength = match.length; + if (matchLength < 2) { + instruction = new TABLESWITCH(match, targets, target); + } else { + sort(0, matchLength - 1, matchClone, targetsClone); + if (matchIsOrdered(matchClone, matchLength, maxGap)) { + final int maxSize = matchLength + matchLength * maxGap; + final int[] mVec = new int[maxSize]; + final InstructionHandle[] tVec = new InstructionHandle[maxSize]; + int count = 1; + mVec[0] = match[0]; + tVec[0] = targets[0]; + for (int i = 1; i < matchLength; i++) { + final int prev = match[i - 1]; + final int gap = match[i] - prev; + for (int j = 1; j < gap; j++) { + mVec[count] = prev + j; + tVec[count] = target; + count++; + } + mVec[count] = match[i]; + tVec[count] = targets[i]; + count++; + } + instruction = new TABLESWITCH(Arrays.copyOf(mVec, count), Arrays.copyOf(tVec, count), target); + } else { + instruction = new LOOKUPSWITCH(matchClone, targetsClone, target); + } + } + } + + public Instruction getInstruction() { + return instruction; + } + + @Override + public InstructionList getInstructionList() { + return new InstructionList(instruction); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java new file mode 100644 index 0000000..8920e10 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Select.java @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. + * + *

+ * We use our super's {@code target} property as the default target. + * + * @LastModified: May 2021 + * @see LOOKUPSWITCH + * @see TABLESWITCH + * @see InstructionList + */ +public abstract class Select extends BranchInstruction implements VariableLengthInstruction, StackConsumer /* @since 6.0 */, StackProducer { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int[] match; // matches, i.e., case 1: ... TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int[] indices; // target offsets TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected InstructionHandle[] targets; // target objects in instruction list TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int fixed_length; // fixed length defined by subclasses TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int match_length; // number of cases TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int padding; // number of pad bytes for alignment TODO could be package-protected? + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + Select() { + } + + /** + * (Match, target) pairs for switch. 'Match' and 'targets' must have the same length of course. + * + * @param match array of matching values + * @param targets instruction targets + * @param defaultTarget default instruction target + */ + Select(final short opcode, final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + // don't set default target before instuction is built + super(opcode, null); + this.match = match; + this.targets = targets; + // now it's safe to set default target + setTarget(defaultTarget); + for (final InstructionHandle target2 : targets) { + notifyTarget(null, target2, this); + } + if ((match_length = match.length) != targets.length) { + throw new ClassGenException("Match and target array have not the same length: Match length: " + match.length + " Target length: " + targets.length); + } + indices = new int[match_length]; + } + + @Override + protected Object clone() throws CloneNotSupportedException { + final Select copy = (Select) super.clone(); + copy.match = match.clone(); + copy.indices = indices.clone(); + copy.targets = targets.clone(); + return copy; + } + + /** + * @return true, if ih is target of this instruction + */ + @Override + public boolean containsTarget(final InstructionHandle ih) { + if (super.getTarget() == ih) { + return true; + } + for (final InstructionHandle target2 : targets) { + if (target2 == ih) { + return true; + } + } + return false; + } + + /** + * Inform targets that they're not targeted anymore. + */ + @Override + void dispose() { + super.dispose(); + for (final InstructionHandle target2 : targets) { + target2.removeTargeter(this); + } + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + out.writeByte(super.getOpcode()); + for (int i = 0; i < padding; i++) { + out.writeByte(0); + } + super.setIndex(getTargetOffset()); // Write default target offset + out.writeInt(super.getIndex()); + } + + /** + * @return the fixed_length + * @since 6.0 + */ + final int getFixedLength() { + return fixed_length; + } + + /** + * @return array of match target offsets + */ + public int[] getIndices() { + return indices; + } + + /** + * @return index entry from indices + * @since 6.0 + */ + final int getIndices(final int index) { + return indices[index]; + } + + /** + * @return match entry + * @since 6.0 + */ + final int getMatch(final int index) { + return match[index]; + } + + /** + * @return the match_length + * @since 6.0 + */ + final int getMatchLength() { + return match_length; + } + + /** + * @return array of match indices + */ + public int[] getMatchs() { + return match; + } + + /** + * @return the padding + * @since 6.0 + */ + final int getPadding() { + return padding; + } + + /** + * @return target entry + * @since 6.0 + */ + final InstructionHandle getTarget(final int index) { + return targets[index]; + } + + /** + * @return array of match targets + */ + public InstructionHandle[] getTargets() { + return targets; + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + padding = (4 - bytes.getIndex() % 4) % 4; // Compute number of pad bytes + for (int i = 0; i < padding; i++) { + bytes.readByte(); + } + // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) + super.setIndex(bytes.readInt()); + } + + /** + * @param fixedLength the fixed_length to set + * @since 6.0 + */ + final void setFixedLength(final int fixedLength) { + this.fixed_length = fixedLength; + } + + /** + * @since 6.0 + */ + final int setIndices(final int i, final int value) { + indices[i] = value; + return value; // Allow use in nested calls + } + + /** + * @param array + * @since 6.0 + */ + final void setIndices(final int[] array) { + indices = array; + } + + /** + * @param index + * @param value + * @since 6.0 + */ + final void setMatch(final int index, final int value) { + match[index] = value; + } + + /** + * @param array + * @since 6.0 + */ + final void setMatches(final int[] array) { + match = array; + } + + /** + * @param matchLength the match_length to set + * @since 6.0 + */ + final int setMatchLength(final int matchLength) { + this.match_length = matchLength; + return matchLength; + } + + /** + * Set branch target for 'i'th case + */ + public void setTarget(final int i, final InstructionHandle target) { // TODO could be package-protected? + notifyTarget(targets[i], target, this); + targets[i] = target; + } + + /** + * @param array + * @since 6.0 + */ + final void setTargets(final InstructionHandle[] array) { + targets = array; + } + + /** + * @return mnemonic for instruction + */ + @Override + public String toString(final boolean verbose) { + final StringBuilder buf = new StringBuilder(super.toString(verbose)); + if (verbose) { + for (int i = 0; i < match_length; i++) { + String s = "null"; + if (targets[i] != null) { + s = targets[i].getInstruction().toString(); + } + buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(indices[i]).append("})"); + } + } else { + buf.append(" ..."); + } + return buf.toString(); + } + + /** + * Since this is a variable length instruction, it may shift the following instructions which then need to update their + * position. + *

+ * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable + * length instructions 'setPositions' performs multiple passes over the instruction list to calculate the correct (byte) + * positions and offsets by calling this function. + * + * @param offset additional offset caused by preceding (variable length) instructions + * @param maxOffset the maximum offset that may be caused by these instructions + * @return additional offset caused by possible change of this instruction's length + */ + @Override + protected int updatePosition(final int offset, final int maxOffset) { + setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc. + final short oldLength = (short) super.getLength(); + /* + * Alignment on 4-byte-boundary, + 1, because of tag byte. + */ + padding = (4 - (getPosition() + 1) % 4) % 4; + super.setLength((short) (fixed_length + padding)); // Update length + return super.getLength() - oldLength; + } + + /** + * @param oldIh old target + * @param newIh new target + */ + @Override + public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) { + boolean targeted = false; + if (super.getTarget() == oldIh) { + targeted = true; + setTarget(newIh); + } + for (int i = 0; i < targets.length; i++) { + if (targets[i] == oldIh) { + targeted = true; + setTarget(i, newIh); + } + } + if (!targeted) { + throw new ClassGenException("Not targeting " + oldIh); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java new file mode 100644 index 0000000..553aa40 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java @@ -0,0 +1,240 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.classfile.ConstantDouble; +import com.sun.org.apache.bcel.internal.classfile.ConstantFloat; +import com.sun.org.apache.bcel.internal.classfile.ConstantInteger; +import com.sun.org.apache.bcel.internal.classfile.ConstantLong; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.ElementValue; +import com.sun.org.apache.bcel.internal.classfile.SimpleElementValue; + +/** + * @since 6.0 + */ +public class SimpleElementValueGen extends ElementValueGen { + // For primitive types and string type, this points to the value entry in + // the cpGen + // For 'class' this points to the class entry in the cpGen + private final int idx; + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final boolean value) { + super(type, cpGen); + if (value) { + idx = getConstantPool().addInteger(1); + } else { + idx = getConstantPool().addInteger(0); + } + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final byte value) { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final char value) { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final double value) { + super(type, cpGen); + idx = getConstantPool().addDouble(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final float value) { + super(type, cpGen); + idx = getConstantPool().addFloat(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final int value) { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final long value) { + super(type, cpGen); + idx = getConstantPool().addLong(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final short value) { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final String value) { + super(type, cpGen); + idx = getConstantPool().addUtf8(value); + } + + // ctors for each supported type... type could be inferred but for now lets + // force it to be passed + + /** + * Protected ctor used for deserialization, doesn't *put* an entry in the constant pool, assumes the one at the supplied + * index is correct. + */ + protected SimpleElementValueGen(final int type, final int idx, final ConstantPoolGen cpGen) { + super(type, cpGen); + this.idx = idx; + } + + /** + * The boolean controls whether we copy info from the 'old' constant pool to the 'new'. You need to use this ctor if the + * annotation is being copied from one file to another. + */ + public SimpleElementValueGen(final SimpleElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { + super(value.getElementValueType(), cpool); + if (!copyPoolEntries) { + // J5ASSERT: Could assert value.stringifyValue() is the same as + // cpool.getConstant(SimpleElementValuevalue.getIndex()) + idx = value.getIndex(); + } else { + switch (value.getElementValueType()) { + case STRING: + idx = cpool.addUtf8(value.getValueString()); + break; + case PRIMITIVE_INT: + idx = cpool.addInteger(value.getValueInt()); + break; + case PRIMITIVE_BYTE: + idx = cpool.addInteger(value.getValueByte()); + break; + case PRIMITIVE_CHAR: + idx = cpool.addInteger(value.getValueChar()); + break; + case PRIMITIVE_LONG: + idx = cpool.addLong(value.getValueLong()); + break; + case PRIMITIVE_FLOAT: + idx = cpool.addFloat(value.getValueFloat()); + break; + case PRIMITIVE_DOUBLE: + idx = cpool.addDouble(value.getValueDouble()); + break; + case PRIMITIVE_BOOLEAN: + if (value.getValueBoolean()) { + idx = cpool.addInteger(1); + } else { + idx = cpool.addInteger(0); + } + break; + case PRIMITIVE_SHORT: + idx = cpool.addInteger(value.getValueShort()); + break; + default: + throw new IllegalArgumentException("SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType()); + } + } + } + + @Override + public void dump(final DataOutputStream dos) throws IOException { + dos.writeByte(super.getElementValueType()); // u1 kind of value + switch (super.getElementValueType()) { + case PRIMITIVE_INT: + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_FLOAT: + case PRIMITIVE_LONG: + case PRIMITIVE_BOOLEAN: + case PRIMITIVE_SHORT: + case PRIMITIVE_DOUBLE: + case STRING: + dos.writeShort(idx); + break; + default: + throw new IllegalStateException("SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType()); + } + } + + /** + * Return immutable variant + */ + @Override + public ElementValue getElementValue() { + return new SimpleElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool()); + } + + public int getIndex() { + return idx; + } + + public int getValueInt() { + if (super.getElementValueType() != PRIMITIVE_INT) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); + return c.getBytes(); + } + + public String getValueString() { + if (super.getElementValueType() != STRING) { + throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx); + return c.getBytes(); + } + + // Whatever kind of value it is, return it as a string + @Override + public String stringifyValue() { + switch (super.getElementValueType()) { + case PRIMITIVE_INT: + final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(c.getBytes()); + case PRIMITIVE_LONG: + final ConstantLong j = (ConstantLong) getConstantPool().getConstant(idx); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + final ConstantDouble d = (ConstantDouble) getConstantPool().getConstant(idx); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + final ConstantFloat f = (ConstantFloat) getConstantPool().getConstant(idx); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + final ConstantInteger s = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + final ConstantInteger b = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + final ConstantInteger ch = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(ch.getBytes()); + case PRIMITIVE_BOOLEAN: + final ConstantInteger bo = (ConstantInteger) getConstantPool().getConstant(idx); + if (bo.getBytes() == 0) { + return "false"; + } + return "true"; + case STRING: + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); + return cu8.getBytes(); + default: + throw new IllegalStateException("SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java new file mode 100644 index 0000000..c0709a4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackConsumer.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denote an instruction that may consume a value from the stack. + */ +public interface StackConsumer { + + /** + * @return how many words are consumed from stack + */ + int consumeStack(ConstantPoolGen cpg); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java new file mode 100644 index 0000000..3132151 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackInstruction.java @@ -0,0 +1,48 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Super class for stack operations like DUP and POP. + */ +public abstract class StackInstruction extends Instruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + StackInstruction() { + } + + /** + * @param opcode instruction opcode + */ + protected StackInstruction(final short opcode) { + super(opcode, (short) 1); + } + + /** + * @return Type.UNKNOWN + */ + public Type getType(final ConstantPoolGen cp) { + return Type.UNKNOWN; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java new file mode 100644 index 0000000..f660e3b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StackProducer.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction that may produce a value on top of the stack (this excludes DUP_X1, e.g.) + */ +public interface StackProducer { + + /** + * @return how many words are produced on stack + */ + int produceStack(ConstantPoolGen cpg); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java new file mode 100644 index 0000000..a47df89 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java @@ -0,0 +1,60 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an unparameterized instruction to store a value into a local variable, e.g. ISTORE. + */ +public abstract class StoreInstruction extends LocalVariableInstruction implements PopInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in + * readInstruction and initFromFile, respectively. + */ + StoreInstruction(final short canonTag, final short cTag) { + super(canonTag, cTag); + } + + /** + * @param opcode Instruction opcode + * @param cTag Instruction number for compact version, ASTORE_0, e.g. + * @param n local variable index (unsigned short) + */ + protected StoreInstruction(final short opcode, final short cTag, final int n) { + super(opcode, cTag, n); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction(this); + v.visitStoreInstruction(this); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java new file mode 100644 index 0000000..21a41cf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java @@ -0,0 +1,109 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.sun.org.apache.bcel.internal.util.ByteSequence; + +/** + * TABLESWITCH - Switch within given range of values, i.e., low..high + * + * @see SWITCH + */ +public class TABLESWITCH extends Select { + + /** + * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. + */ + TABLESWITCH() { + } + + /** + * @param match sorted array of match values, match[0] must be low value, match[match_length - 1] high value + * @param targets where to branch for matched values + * @param defaultTarget default branch + */ + public TABLESWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + super(com.sun.org.apache.bcel.internal.Const.TABLESWITCH, match, targets, defaultTarget); + /* Alignment remainder assumed 0 here, until dump time */ + final short length = (short) (13 + getMatchLength() * 4); + super.setLength(length); + setFixedLength(length); + } + + /** + * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call + * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitVariableLengthInstruction(this); + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitSelect(this); + v.visitTABLESWITCH(this); + } + + /** + * Dump instruction as byte code to stream out. + * + * @param out Output stream + */ + @Override + public void dump(final DataOutputStream out) throws IOException { + super.dump(out); + final int matchLength = getMatchLength(); + final int low = matchLength > 0 ? super.getMatch(0) : 0; + out.writeInt(low); + final int high = matchLength > 0 ? super.getMatch(matchLength - 1) : 0; + out.writeInt(high); + for (int i = 0; i < matchLength; i++) { + out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i)))); + } + } + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException { + super.initFromFile(bytes, wide); + final int low = bytes.readInt(); + final int high = bytes.readInt(); + final int matchLength = high - low + 1; + setMatchLength(matchLength); + final short fixedLength = (short) (13 + matchLength * 4); + setFixedLength(fixedLength); + super.setLength((short) (fixedLength + super.getPadding())); + super.setMatches(new int[matchLength]); + super.setIndices(new int[matchLength]); + super.setTargets(new InstructionHandle[matchLength]); + for (int i = 0; i < matchLength; i++) { + super.setMatch(i, low + i); + super.setIndices(i, bytes.readInt()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java new file mode 100644 index 0000000..bb2cee2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TargetLostException.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Thrown by InstructionList.remove() when one or multiple disposed instructions are still being referenced by an + * InstructionTargeter object. I.e. the InstructionTargeter has to be notified that (one of) the InstructionHandle it is + * referencing is being removed from the InstructionList and thus not valid anymore. + * + *

+ * Making this an exception instead of a return value forces the user to handle these case explicitly in a try { ... } + * catch. The following code illustrates how this may be done: + *

+ * + *
+ * ...
+ * try {
+ * il.delete(start_ih, end_ih);
+ * } catch(TargetLostException e) {
+ * for (InstructionHandle target : e.getTargets()) {
+ * for (InstructionTargeter targeter : target.getTargeters()) {
+ * targeter.updateTarget(target, new_target);
+ * }
+ * }
+ * }
+ * 
+ * + * @LastModified: Feb 2023 + * @see InstructionHandle + * @see InstructionList + * @see InstructionTargeter + */ +public final class TargetLostException extends Exception { + + private static final long serialVersionUID = -6857272667645328384L; + private final InstructionHandle[] targets; + + TargetLostException(final InstructionHandle[] t, final String mesg) { + super(mesg); + targets = t; + } + + /** + * @return list of instructions still being targeted. + */ + public InstructionHandle[] getTargets() { + return targets; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java new file mode 100644 index 0000000..1282bac --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Type.java @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ClassFormatException; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Abstract super class for all possible java types, namely basic types such as int, object types like String and array + * types, e.g. int[] + * + * @LastModified: May 2021 + */ +public abstract class Type { + + /** + * Predefined constants + */ + public static final BasicType VOID = new BasicType(Const.T_VOID); + + public static final BasicType BOOLEAN = new BasicType(Const.T_BOOLEAN); + public static final BasicType INT = new BasicType(Const.T_INT); + public static final BasicType SHORT = new BasicType(Const.T_SHORT); + public static final BasicType BYTE = new BasicType(Const.T_BYTE); + public static final BasicType LONG = new BasicType(Const.T_LONG); + public static final BasicType DOUBLE = new BasicType(Const.T_DOUBLE); + public static final BasicType FLOAT = new BasicType(Const.T_FLOAT); + public static final BasicType CHAR = new BasicType(Const.T_CHAR); + public static final ObjectType OBJECT = new ObjectType("java.lang.Object"); + public static final ObjectType CLASS = new ObjectType("java.lang.Class"); + public static final ObjectType STRING = new ObjectType("java.lang.String"); + public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer"); + public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable"); + + /** + * Empty array. + */ + public static final Type[] NO_ARGS = {}; + public static final ReferenceType NULL = new ReferenceType() { + }; + + public static final Type UNKNOWN = new Type(Const.T_UNKNOWN, "") { + }; + + private static final ThreadLocal CONSUMED_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0)); + + // int consumed_chars=0; // Remember position in string, see getArgumentTypes + static int consumed(final int coded) { + return coded >> 2; + } + + static int encode(final int size, final int consumed) { + return consumed << 2 | size; + } + + /** + * Convert arguments of a method (signature) to an array of Type objects. + * + * @param signature signature string such as (Ljava/lang/String;)V + * @return array of argument types + */ + public static Type[] getArgumentTypes(final String signature) { + final List vec = new ArrayList<>(); + int index; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + vec.add(getType(signature.substring(index))); + // corrected concurrent private static field acess + index += unwrap(CONSUMED_CHARS); // update position + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + final Type[] types = new Type[vec.size()]; + vec.toArray(types); + return types; + } + + static int getArgumentTypesSize(final String signature) { + int res = 0; + int index; + try { + // Skip any type arguments to read argument declarations between '(' and ')' + index = signature.indexOf('(') + 1; + if (index <= 0) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + while (signature.charAt(index) != ')') { + final int coded = getTypeSize(signature.substring(index)); + res += size(coded); + index += consumed(coded); + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return res; + } + + /** + * Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I + * + * @param returnType what the method returns + * @param argTypes what are the argument types + * @return method signature for given type(s). + */ + public static String getMethodSignature(final Type returnType, final Type[] argTypes) { + final StringBuilder buf = new StringBuilder("("); + if (argTypes != null) { + for (final Type argType : argTypes) { + buf.append(argType.getSignature()); + } + } + buf.append(')'); + buf.append(returnType.getSignature()); + return buf.toString(); + } + + /** + * Convert return value of a method (signature) to a Type object. + * + * @param signature signature string such as (Ljava/lang/String;)V + * @return return type + */ + public static Type getReturnType(final String signature) { + try { + // Read return type after ')' + final int index = signature.lastIndexOf(')') + 1; + return getType(signature.substring(index)); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + static int getReturnTypeSize(final String signature) { + final int index = signature.lastIndexOf(')') + 1; + return Type.size(getTypeSize(signature.substring(index))); + } + + public static String getSignature(final java.lang.reflect.Method meth) { + final StringBuilder sb = new StringBuilder("("); + final Class[] params = meth.getParameterTypes(); // avoid clone + for (final Class param : params) { + sb.append(getType(param).getSignature()); + } + sb.append(")"); + sb.append(getType(meth.getReturnType()).getSignature()); + return sb.toString(); + } + + /** + * Convert runtime java.lang.Class to BCEL Type object. + * + * @param cls Java class + * @return corresponding Type object + */ + public static Type getType(final Class cls) { + Objects.requireNonNull(cls, "cls"); + /* + * That's an amzingly easy case, because getName() returns the signature. That's what we would have liked anyway. + */ + if (cls.isArray()) { + return getType(cls.getName()); + } + if (!cls.isPrimitive()) { // "Real" class + return ObjectType.getInstance(cls.getName()); + } + if (cls == Integer.TYPE) { + return INT; + } + if (cls == Void.TYPE) { + return VOID; + } + if (cls == Double.TYPE) { + return DOUBLE; + } + if (cls == Float.TYPE) { + return FLOAT; + } + if (cls == Boolean.TYPE) { + return BOOLEAN; + } + if (cls == Byte.TYPE) { + return BYTE; + } + if (cls == Short.TYPE) { + return SHORT; + } + if (cls == Long.TYPE) { + return LONG; + } + if (cls == Character.TYPE) { + return CHAR; + } + throw new IllegalStateException("Unknown primitive type " + cls); + } + + /** + * Convert signature to a Type object. + * + * @param signature signature string such as Ljava/lang/String; + * @return type object + */ + public static Type getType(final String signature) throws StringIndexOutOfBoundsException { + final byte type = Utility.typeOfSignature(signature); + if (type <= Const.T_VOID) { + // corrected concurrent private static field acess + wrap(CONSUMED_CHARS, 1); + return BasicType.getType(type); + } + if (type != Const.T_ARRAY) { // type == T_REFERENCE + // Utility.typeSignatureToString understands how to parse generic types. + final String parsedSignature = Utility.typeSignatureToString(signature, false); + wrap(CONSUMED_CHARS, parsedSignature.length() + 2); // "Lblabla;" 'L' and ';' are removed + return ObjectType.getInstance(Utility.pathToPackage(parsedSignature)); + } + int dim = 0; + do { // Count dimensions + dim++; + } while (signature.charAt(dim) == '['); + // Recurse, but just once, if the signature is ok + final Type t = getType(signature.substring(dim)); + // corrected concurrent private static field acess + // consumed_chars += dim; // update counter - is replaced by + final int temp = unwrap(CONSUMED_CHARS) + dim; + wrap(CONSUMED_CHARS, temp); + return new ArrayType(t, dim); + } + + /** + * Convert runtime java.lang.Class[] to BCEL Type objects. + * + * @param classes an array of runtime class objects + * @return array of corresponding Type objects + */ + public static Type[] getTypes(final Class[] classes) { + final Type[] ret = new Type[classes.length]; + Arrays.setAll(ret, i -> getType(classes[i])); + return ret; + } + + static int getTypeSize(final String signature) throws StringIndexOutOfBoundsException { + final byte type = Utility.typeOfSignature(signature); + if (type <= Const.T_VOID) { + return encode(BasicType.getType(type).getSize(), 1); + } + if (type == Const.T_ARRAY) { + int dim = 0; + do { // Count dimensions + dim++; + } while (signature.charAt(dim) == '['); + // Recurse, but just once, if the signature is ok + final int consumed = consumed(getTypeSize(signature.substring(dim))); + return encode(1, dim + consumed); + } + final int index = signature.indexOf(';'); // Look for closing ';' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + return encode(1, index + 1); + } + + static int size(final int coded) { + return coded & 3; + } + + private static int unwrap(final ThreadLocal tl) { + return tl.get().intValue(); + } + + private static void wrap(final ThreadLocal tl, final int value) { + tl.set(Integer.valueOf(value)); + } + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected byte type; // TODO should be final (and private) + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected String signature; // signature for the type TODO should be private + + protected Type(final byte type, final String signature) { + this.type = type; + this.signature = signature; + } + + /** + * @return whether the Types are equal + */ + @Override + public boolean equals(final Object o) { + if (o instanceof Type) { + final Type t = (Type) o; + return type == t.type && signature.equals(t.signature); + } + return false; + } + + public String getClassName() { + return toString(); + } + + /** + * @return signature for given type. + */ + public String getSignature() { + return signature; + } + + /** + * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise) + */ + public int getSize() { + switch (type) { + case Const.T_DOUBLE: + case Const.T_LONG: + return 2; + case Const.T_VOID: + return 0; + default: + return 1; + } + } + + /** + * @return type as defined in Constants + */ + public byte getType() { + return type; + } + + /** + * @return hashcode of Type + */ + @Override + public int hashCode() { + return type ^ signature.hashCode(); + } + + /** + * boolean, short and char variable are considered as int in the stack or local variable area. Returns {@link Type#INT} + * for {@link Type#BOOLEAN}, {@link Type#SHORT} or {@link Type#CHAR}, otherwise returns the given type. + * + * @since 6.0 + */ + public Type normalizeForStackOrLocal() { + if (this == Type.BOOLEAN || this == Type.BYTE || this == Type.SHORT || this == Type.CHAR) { + return Type.INT; + } + return this; + } + + /* + * Currently only used by the ArrayType constructor. The signature has a complicated dependency on other parameter so + * it's tricky to do it in a call to the super ctor. + */ + void setSignature(final String signature) { + this.signature = signature; + } + + /** + * @return Type string, e.g. 'int[]' + */ + @Override + public String toString() { + return this.equals(Type.NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java new file mode 100644 index 0000000..5a22942 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java @@ -0,0 +1,30 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Get the type associated with an instruction, int for ILOAD, or the type of the field of a PUTFIELD instruction, e.g.. + */ +public interface TypedInstruction { + + Type getType(ConstantPoolGen cpg); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java new file mode 100644 index 0000000..8ccd731 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. + * + * @see GOTO + * @see JSR + */ +public interface UnconditionalBranch { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java new file mode 100644 index 0000000..6931174 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java @@ -0,0 +1,33 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Denotes an instruction to be a variable length instruction, such as GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. + * + * @see GOTO + * @see JSR + * @see LOOKUPSWITCH + * @see TABLESWITCH + */ +public interface VariableLengthInstruction { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java new file mode 100644 index 0000000..fd70e8c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/Visitor.java @@ -0,0 +1,394 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.generic; + +/** + * Interface implementing the Visitor pattern programming style. I.e., a class that implements this interface can handle + * all types of instructions with the properly typed methods just by calling the accept() method. + */ +public interface Visitor { + + void visitAALOAD(AALOAD obj); + + void visitAASTORE(AASTORE obj); + + void visitACONST_NULL(ACONST_NULL obj); + + void visitAllocationInstruction(AllocationInstruction obj); + + void visitALOAD(ALOAD obj); + + void visitANEWARRAY(ANEWARRAY obj); + + void visitARETURN(ARETURN obj); + + void visitArithmeticInstruction(ArithmeticInstruction obj); + + void visitArrayInstruction(ArrayInstruction obj); + + void visitARRAYLENGTH(ARRAYLENGTH obj); + + void visitASTORE(ASTORE obj); + + void visitATHROW(ATHROW obj); + + void visitBALOAD(BALOAD obj); + + void visitBASTORE(BASTORE obj); + + void visitBIPUSH(BIPUSH obj); + + void visitBranchInstruction(BranchInstruction obj); + + void visitBREAKPOINT(BREAKPOINT obj); + + void visitCALOAD(CALOAD obj); + + void visitCASTORE(CASTORE obj); + + void visitCHECKCAST(CHECKCAST obj); + + void visitConstantPushInstruction(ConstantPushInstruction obj); + + void visitConversionInstruction(ConversionInstruction obj); + + void visitCPInstruction(CPInstruction obj); + + void visitD2F(D2F obj); + + void visitD2I(D2I obj); + + void visitD2L(D2L obj); + + void visitDADD(DADD obj); + + void visitDALOAD(DALOAD obj); + + void visitDASTORE(DASTORE obj); + + void visitDCMPG(DCMPG obj); + + void visitDCMPL(DCMPL obj); + + void visitDCONST(DCONST obj); + + void visitDDIV(DDIV obj); + + void visitDLOAD(DLOAD obj); + + void visitDMUL(DMUL obj); + + void visitDNEG(DNEG obj); + + void visitDREM(DREM obj); + + void visitDRETURN(DRETURN obj); + + void visitDSTORE(DSTORE obj); + + void visitDSUB(DSUB obj); + + void visitDUP(DUP obj); + + void visitDUP_X1(DUP_X1 obj); + + void visitDUP_X2(DUP_X2 obj); + + void visitDUP2(DUP2 obj); + + void visitDUP2_X1(DUP2_X1 obj); + + void visitDUP2_X2(DUP2_X2 obj); + + void visitExceptionThrower(ExceptionThrower obj); + + void visitF2D(F2D obj); + + void visitF2I(F2I obj); + + void visitF2L(F2L obj); + + void visitFADD(FADD obj); + + void visitFALOAD(FALOAD obj); + + void visitFASTORE(FASTORE obj); + + void visitFCMPG(FCMPG obj); + + void visitFCMPL(FCMPL obj); + + void visitFCONST(FCONST obj); + + void visitFDIV(FDIV obj); + + void visitFieldInstruction(FieldInstruction obj); + + void visitFieldOrMethod(FieldOrMethod obj); + + void visitFLOAD(FLOAD obj); + + void visitFMUL(FMUL obj); + + void visitFNEG(FNEG obj); + + void visitFREM(FREM obj); + + void visitFRETURN(FRETURN obj); + + void visitFSTORE(FSTORE obj); + + void visitFSUB(FSUB obj); + + void visitGETFIELD(GETFIELD obj); + + void visitGETSTATIC(GETSTATIC obj); + + void visitGOTO(GOTO obj); + + void visitGOTO_W(GOTO_W obj); + + void visitGotoInstruction(GotoInstruction obj); + + void visitI2B(I2B obj); + + void visitI2C(I2C obj); + + void visitI2D(I2D obj); + + void visitI2F(I2F obj); + + void visitI2L(I2L obj); + + void visitI2S(I2S obj); + + void visitIADD(IADD obj); + + void visitIALOAD(IALOAD obj); + + void visitIAND(IAND obj); + + void visitIASTORE(IASTORE obj); + + void visitICONST(ICONST obj); + + void visitIDIV(IDIV obj); + + void visitIF_ACMPEQ(IF_ACMPEQ obj); + + void visitIF_ACMPNE(IF_ACMPNE obj); + + void visitIF_ICMPEQ(IF_ICMPEQ obj); + + void visitIF_ICMPGE(IF_ICMPGE obj); + + void visitIF_ICMPGT(IF_ICMPGT obj); + + void visitIF_ICMPLE(IF_ICMPLE obj); + + void visitIF_ICMPLT(IF_ICMPLT obj); + + void visitIF_ICMPNE(IF_ICMPNE obj); + + void visitIFEQ(IFEQ obj); + + void visitIFGE(IFGE obj); + + void visitIFGT(IFGT obj); + + void visitIfInstruction(IfInstruction obj); + + void visitIFLE(IFLE obj); + + void visitIFLT(IFLT obj); + + void visitIFNE(IFNE obj); + + void visitIFNONNULL(IFNONNULL obj); + + void visitIFNULL(IFNULL obj); + + void visitIINC(IINC obj); + + void visitILOAD(ILOAD obj); + + void visitIMPDEP1(IMPDEP1 obj); + + void visitIMPDEP2(IMPDEP2 obj); + + void visitIMUL(IMUL obj); + + void visitINEG(INEG obj); + + void visitINSTANCEOF(INSTANCEOF obj); + + /** + * @since 6.0 + */ + void visitINVOKEDYNAMIC(INVOKEDYNAMIC obj); + + void visitInvokeInstruction(InvokeInstruction obj); + + void visitINVOKEINTERFACE(INVOKEINTERFACE obj); + + void visitINVOKESPECIAL(INVOKESPECIAL obj); + + void visitINVOKESTATIC(INVOKESTATIC obj); + + void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj); + + void visitIOR(IOR obj); + + void visitIREM(IREM obj); + + void visitIRETURN(IRETURN obj); + + void visitISHL(ISHL obj); + + void visitISHR(ISHR obj); + + void visitISTORE(ISTORE obj); + + void visitISUB(ISUB obj); + + void visitIUSHR(IUSHR obj); + + void visitIXOR(IXOR obj); + + void visitJSR(JSR obj); + + void visitJSR_W(JSR_W obj); + + void visitJsrInstruction(JsrInstruction obj); + + void visitL2D(L2D obj); + + void visitL2F(L2F obj); + + void visitL2I(L2I obj); + + void visitLADD(LADD obj); + + void visitLALOAD(LALOAD obj); + + void visitLAND(LAND obj); + + void visitLASTORE(LASTORE obj); + + void visitLCMP(LCMP obj); + + void visitLCONST(LCONST obj); + + void visitLDC(LDC obj); + + void visitLDC2_W(LDC2_W obj); + + void visitLDIV(LDIV obj); + + void visitLLOAD(LLOAD obj); + + void visitLMUL(LMUL obj); + + void visitLNEG(LNEG obj); + + void visitLoadClass(LoadClass obj); + + void visitLoadInstruction(LoadInstruction obj); + + void visitLocalVariableInstruction(LocalVariableInstruction obj); + + void visitLOOKUPSWITCH(LOOKUPSWITCH obj); + + void visitLOR(LOR obj); + + void visitLREM(LREM obj); + + void visitLRETURN(LRETURN obj); + + void visitLSHL(LSHL obj); + + void visitLSHR(LSHR obj); + + void visitLSTORE(LSTORE obj); + + void visitLSUB(LSUB obj); + + void visitLUSHR(LUSHR obj); + + void visitLXOR(LXOR obj); + + void visitMONITORENTER(MONITORENTER obj); + + void visitMONITOREXIT(MONITOREXIT obj); + + void visitMULTIANEWARRAY(MULTIANEWARRAY obj); + + void visitNEW(NEW obj); + + void visitNEWARRAY(NEWARRAY obj); + + void visitNOP(NOP obj); + + void visitPOP(POP obj); + + void visitPOP2(POP2 obj); + + void visitPopInstruction(PopInstruction obj); + + void visitPushInstruction(PushInstruction obj); + + void visitPUTFIELD(PUTFIELD obj); + + void visitPUTSTATIC(PUTSTATIC obj); + + void visitRET(RET obj); + + void visitRETURN(RETURN obj); + + void visitReturnInstruction(ReturnInstruction obj); + + void visitSALOAD(SALOAD obj); + + void visitSASTORE(SASTORE obj); + + void visitSelect(Select obj); + + void visitSIPUSH(SIPUSH obj); + + void visitStackConsumer(StackConsumer obj); + + void visitStackInstruction(StackInstruction obj); + + void visitStackProducer(StackProducer obj); + + void visitStoreInstruction(StoreInstruction obj); + + void visitSWAP(SWAP obj); + + void visitTABLESWITCH(TABLESWITCH obj); + + void visitTypedInstruction(TypedInstruction obj); + + void visitUnconditionalBranch(UnconditionalBranch obj); + + void visitVariableLengthInstruction(VariableLengthInstruction obj); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html new file mode 100644 index 0000000..1945ee3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/generic/package.html @@ -0,0 +1,32 @@ + + + + + + + +

+ This package contains the "generic" part of the + Byte Code Engineering + Library, i.e., classes to dynamically modify class objects and + byte code instructions. +

+ + diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html new file mode 100644 index 0000000..879d144 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/package.html @@ -0,0 +1,33 @@ + + + + + + + +

+ This package contains basic classes for the + Byte Code Engineering Library + and constants defined by the + + JVM specification. +

+ + diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java new file mode 100644 index 0000000..a61d9d3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Args.java @@ -0,0 +1,148 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.ClassFormatException; + +/** + * Argument validation. + * + * @since 6.7.0 + */ +public class Args { + + /** + * Requires a specific value. + * + * @param value The value to test. + * @param required The required value. + * @param message The message prefix + * @return The value to test. + */ + public static int require(final int value, final int required, final String message) { + if (value != required) { + throw new ClassFormatException(String.format("%s [Value must be 0: %,d]", message, value)); + } + return value; + } + + /** + * Requires a 0 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int require0(final int value, final String message) { + return require(value, 0, message); + } + + /** + * Requires a u1 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU1(final int value, final String message) { + if (value < 0 || value > Const.MAX_BYTE) { + throw new ClassFormatException(String.format("%s [Value out of range (0 - %,d) for type u1: %,d]", message, Const.MAX_BYTE, value)); + } + return value; + } + + /** + * Requires a u2 value of at least {@code min} and not above {@code max}. + * + * @param value The value to test. + * @param min The minimum required u2 value. + * @param max The maximum required u2 value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final int min, final int max, final String message) { + if (max > Const.MAX_SHORT) { + throw new IllegalArgumentException(String.format("%s programming error: max %,d > %,d", message, max, Const.MAX_SHORT)); + } + if (min < 0) { + throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min)); + } + if (value < min || value > max) { + throw new ClassFormatException(String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Const.MAX_SHORT, value)); + } + return value; + } + + /** + * Requires a u2 value of at least {@code min}. + * + * @param value The value to test. + * @param min The minimum required value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final int min, final String message) { + return requireU2(value, min, Const.MAX_SHORT, message); + } + + /** + * Requires a u2 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU2(final int value, final String message) { + return requireU2(value, 0, message); + } + + /** + * Requires a u4 value of at least {@code min}. + * + * @param value The value to test. + * @param min The minimum required value. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU4(final int value, final int min, final String message) { + if (min < 0) { + throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min)); + } + if (value < min) { + throw new ClassFormatException( + String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Integer.MAX_VALUE, value & 0xFFFFFFFFL)); + } + return value; + } + + /** + * Requires a u4 value. + * + * @param value The value to test. + * @param message The message prefix + * @return The value to test. + */ + public static int requireU4(final int value, final String message) { + return requireU4(value, 0, message); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java new file mode 100644 index 0000000..04b9833 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/AttributeHTML.java @@ -0,0 +1,195 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.Closeable; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.InnerClass; +import com.sun.org.apache.bcel.internal.classfile.InnerClasses; +import com.sun.org.apache.bcel.internal.classfile.LineNumber; +import com.sun.org.apache.bcel.internal.classfile.LineNumberTable; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.SourceFile; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert found attributes into HTML file. + */ +final class AttributeHTML implements Closeable { + + private final String className; // name of current class + private final PrintWriter printWriter; // file to write to + private final ConstantHTML constantHtml; + private final ConstantPool constantPool; + private int attrCount; + + AttributeHTML(final String dir, final String className, final ConstantPool constantPool, final ConstantHTML constantHtml, final Charset charset) + throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.constantPool = constantPool; + this.constantHtml = constantHtml; + printWriter = new PrintWriter(dir + className + "_attributes.html", charset.name()); + printWriter.print(""); + printWriter.println(""); + } + + @Override + public void close() { + printWriter.println("
"); + printWriter.close(); + } + + private String codeLink(final int link, final int methodNumber) { + return "" + link + ""; + } + + void writeAttribute(final Attribute attribute, final String anchor) { + writeAttribute(attribute, anchor, 0); + } + + void writeAttribute(final Attribute attribute, final String anchor, final int methodNumber) { + final byte tag = attribute.getTag(); + int index; + if (tag == Const.ATTR_UNKNOWN) { + return; + } + attrCount++; // Increment number of attributes found so far + if (attrCount % 2 == 0) { + printWriter.print(""); + } else { + printWriter.print(""); + } + printWriter.println("

" + attrCount + " " + Const.getAttributeName(tag) + "

"); + /* + * Handle different attributes + */ + switch (tag) { + case Const.ATTR_CODE: + final Code c = (Code) attribute; + // Some directly printable values + printWriter.print("
  • Maximum stack size = " + c.getMaxStack() + "
  • \n
  • Number of local variables = " + c.getMaxLocals() + + "
  • \n
  • Byte code
\n"); + // Get handled exceptions and list them + final CodeException[] ce = c.getExceptionTable(); + final int len = ce.length; + if (len > 0) { + printWriter.print("

Exceptions handled

    "); + for (final CodeException cex : ce) { + final int catchType = cex.getCatchType(); // Index in constant pool + printWriter.print("
  • "); + if (catchType != 0) { + printWriter.print(constantHtml.referenceConstant(catchType)); // Create Link to _cp.html + } else { + printWriter.print("Any Exception"); + } + printWriter.print("
    (Ranging from lines " + codeLink(cex.getStartPC(), methodNumber) + " to " + codeLink(cex.getEndPC(), methodNumber) + + ", handled at line " + codeLink(cex.getHandlerPC(), methodNumber) + ")
  • "); + } + printWriter.print("
"); + } + break; + case Const.ATTR_CONSTANT_VALUE: + index = ((ConstantValue) attribute).getConstantValueIndex(); + // Reference _cp.html + printWriter + .print("\n"); + break; + case Const.ATTR_SOURCE_FILE: + index = ((SourceFile) attribute).getSourceFileIndex(); + // Reference _cp.html + printWriter + .print("\n"); + break; + case Const.ATTR_EXCEPTIONS: + // List thrown exceptions + final int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable(); + printWriter.print("\n"); + break; + case Const.ATTR_LINE_NUMBER_TABLE: + final LineNumber[] lineNumbers = ((LineNumberTable) attribute).getLineNumberTable(); + // List line number pairs + printWriter.print("

"); + for (int i = 0; i < lineNumbers.length; i++) { + printWriter.print("(" + lineNumbers[i].getStartPC() + ", " + lineNumbers[i].getLineNumber() + ")"); + if (i < lineNumbers.length - 1) { + printWriter.print(", "); // breakable + } + } + break; + case Const.ATTR_LOCAL_VARIABLE_TABLE: + // List name, range and type + printWriter.print("

    "); + ((LocalVariableTable) attribute).forEach(var -> { + final int sigIdx = var.getSignatureIndex(); + String signature = constantPool.getConstantUtf8(sigIdx).getBytes(); + signature = Utility.signatureToString(signature, false); + final int start = var.getStartPC(); + final int end = start + var.getLength(); + printWriter.println("
  • " + Class2HTML.referenceType(signature) + " " + var.getName() + " in slot %" + var.getIndex() + + "
    Valid from lines " + "" + start + + " to " + "" + end + "
  • "); + }); + printWriter.print("
\n"); + break; + case Const.ATTR_INNER_CLASSES: + // List inner classes + printWriter.print("
    "); + for (final InnerClass clazz : ((InnerClasses) attribute).getInnerClasses()) { + final String name; + final String access; + index = clazz.getInnerNameIndex(); + if (index > 0) { + name = constantPool.getConstantUtf8(index).getBytes(); + } else { + name = "<anonymous>"; + } + access = Utility.accessToString(clazz.getInnerAccessFlags()); + printWriter.print("
  • " + access + " " + constantHtml.referenceConstant(clazz.getInnerClassIndex()) + + " in class " + constantHtml.referenceConstant(clazz.getOuterClassIndex()) + " named " + name + "
  • \n"); + } + printWriter.print("
\n"); + break; + default: // Such as Unknown attribute or Deprecated + printWriter.print("

" + attribute); + } + printWriter.println(""); + printWriter.flush(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java new file mode 100644 index 0000000..2e663bf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELComparator.java @@ -0,0 +1,47 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +/** + * Used for BCEL comparison strategy + * + * @since 5.2 + */ +public interface BCELComparator { + + /** + * Compare two objects and return what THIS.equals(THAT) should return + * + * @param THIS + * @param THAT + * @return true if and only if THIS equals THAT + */ + boolean equals(Object THIS, Object THAT); + + /** + * Return hashcode for THIS.hashCode() + * + * @param THIS + * @return hashcode for THIS.hashCode() + */ + int hashCode(Object THIS); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java new file mode 100644 index 0000000..fe7a6f6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELFactory.java @@ -0,0 +1,340 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.generic.AllocationInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayType; +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.BranchInstruction; +import com.sun.org.apache.bcel.internal.generic.CHECKCAST; +import com.sun.org.apache.bcel.internal.generic.CPInstruction; +import com.sun.org.apache.bcel.internal.generic.CodeExceptionGen; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ConstantPushInstruction; +import com.sun.org.apache.bcel.internal.generic.EmptyVisitor; +import com.sun.org.apache.bcel.internal.generic.FieldInstruction; +import com.sun.org.apache.bcel.internal.generic.IINC; +import com.sun.org.apache.bcel.internal.generic.INSTANCEOF; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InvokeInstruction; +import com.sun.org.apache.bcel.internal.generic.LDC; +import com.sun.org.apache.bcel.internal.generic.LDC2_W; +import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction; +import com.sun.org.apache.bcel.internal.generic.MULTIANEWARRAY; +import com.sun.org.apache.bcel.internal.generic.MethodGen; +import com.sun.org.apache.bcel.internal.generic.NEWARRAY; +import com.sun.org.apache.bcel.internal.generic.ObjectType; +import com.sun.org.apache.bcel.internal.generic.RET; +import com.sun.org.apache.bcel.internal.generic.ReturnInstruction; +import com.sun.org.apache.bcel.internal.generic.Select; +import com.sun.org.apache.bcel.internal.generic.Type; + +/** + * Factory creates il.append() statements, and sets instruction targets. A helper class for BCELifier. + * + * @LastModified: Feb 2023 + * @see BCELifier + */ +class BCELFactory extends EmptyVisitor { + + private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + "."; + private final MethodGen methodGen; + private final PrintWriter printWriter; + private final ConstantPoolGen constantPoolGen; + + private final Map branchMap = new HashMap<>(); + + // Memorize BranchInstructions that need an update + private final List branches = new ArrayList<>(); + + BCELFactory(final MethodGen mg, final PrintWriter out) { + methodGen = mg; + constantPoolGen = mg.getConstantPool(); + printWriter = out; + } + + private void createConstant(final Object value) { + String embed = value.toString(); + if (value instanceof String) { + embed = '"' + Utility.convertString(embed) + '"'; + } else if (value instanceof Character) { + embed = "(char)0x" + Integer.toHexString(((Character) value).charValue()); + } else if (value instanceof Float) { + final Float f = (Float) value; + if (Float.isNaN(f)) { + embed = "Float.NaN"; + } else if (f == Float.POSITIVE_INFINITY) { + embed = "Float.POSITIVE_INFINITY"; + } else if (f == Float.NEGATIVE_INFINITY) { + embed = "Float.NEGATIVE_INFINITY"; + } else { + embed += "f"; + } + } else if (value instanceof Double) { + final Double d = (Double) value; + if (Double.isNaN(d)) { + embed = "Double.NaN"; + } else if (d == Double.POSITIVE_INFINITY) { + embed = "Double.POSITIVE_INFINITY"; + } else if (d == Double.NEGATIVE_INFINITY) { + embed = "Double.NEGATIVE_INFINITY"; + } else { + embed += "d"; + } + } else if (value instanceof Long) { + embed += "L"; + } else if (value instanceof ObjectType) { + final ObjectType ot = (ObjectType) value; + embed = "new ObjectType(\"" + ot.getClassName() + "\")"; + } else if (value instanceof ArrayType) { + final ArrayType at = (ArrayType) value; + embed = "new ArrayType(" + BCELifier.printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; + } + + printWriter.println("il.append(new PUSH(_cp, " + embed + "));"); + } + + public void start() { + if (!methodGen.isAbstract() && !methodGen.isNative()) { + for (InstructionHandle ih = methodGen.getInstructionList().getStart(); ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { + branchMap.put(i, ih); // memorize container + } + if (ih.hasTargeters()) { + if (i instanceof BranchInstruction) { + printWriter.println(" InstructionHandle ih_" + ih.getPosition() + ";"); + } else { + printWriter.print(" InstructionHandle ih_" + ih.getPosition() + " = "); + } + } else { + printWriter.print(" "); + } + if (!visitInstruction(i)) { + i.accept(this); + } + } + updateBranchTargets(); + updateExceptionHandlers(); + } + } + + private void updateBranchTargets() { + branches.forEach(bi -> { + final BranchHandle bh = (BranchHandle) branchMap.get(bi); + final int pos = bh.getPosition(); + final String name = bi.getName() + "_" + pos; + int targetPos = bh.getTarget().getPosition(); + printWriter.println(" " + name + ".setTarget(ih_" + targetPos + ");"); + if (bi instanceof Select) { + final InstructionHandle[] ihs = ((Select) bi).getTargets(); + for (int j = 0; j < ihs.length; j++) { + targetPos = ihs[j].getPosition(); + printWriter.println(" " + name + ".setTarget(" + j + ", ih_" + targetPos + ");"); + } + } + }); + } + + private void updateExceptionHandlers() { + final CodeExceptionGen[] handlers = methodGen.getExceptionHandlers(); + for (final CodeExceptionGen h : handlers) { + final String type = h.getCatchType() == null ? "null" : BCELifier.printType(h.getCatchType()); + printWriter.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", " + + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");"); + } + } + + @Override + @SuppressWarnings("fallthrough") // by design for case Const.ANEWARRAY + public void visitAllocationInstruction(final AllocationInstruction i) { + Type type; + if (i instanceof CPInstruction) { + type = ((CPInstruction) i).getType(constantPoolGen); + } else { + type = ((NEWARRAY) i).getType(); + } + final short opcode = ((Instruction) i).getOpcode(); + int dim = 1; + switch (opcode) { + case Const.NEW: + printWriter.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + "\"));"); + break; + case Const.MULTIANEWARRAY: + dim = ((MULTIANEWARRAY) i).getDimensions(); + //$FALL-THROUGH$ + case Const.NEWARRAY: + if (type instanceof ArrayType) { + type = ((ArrayType) type).getBasicType(); + } + //$FALL-THROUGH$ + case Const.ANEWARRAY: + printWriter.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + ", (short) " + dim + "));"); + break; + default: + throw new IllegalArgumentException("Unhandled opcode: " + opcode); + } + } + + @Override + public void visitArrayInstruction(final ArrayInstruction i) { + final short opcode = i.getOpcode(); + final Type type = i.getType(constantPoolGen); + final String kind = opcode < Const.IASTORE ? "Load" : "Store"; + printWriter.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) + "));"); + } + + @Override + public void visitBranchInstruction(final BranchInstruction bi) { + final BranchHandle bh = (BranchHandle) branchMap.get(bi); + final int pos = bh.getPosition(); + final String name = bi.getName() + "_" + pos; + if (bi instanceof Select) { + final Select s = (Select) bi; + branches.add(bi); + final StringBuilder args = new StringBuilder("new int[] { "); + final int[] matchs = s.getMatchs(); + for (int i = 0; i < matchs.length; i++) { + args.append(matchs[i]); + if (i < matchs.length - 1) { + args.append(", "); + } + } + args.append(" }"); + printWriter.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH) + "(" + args + ", new InstructionHandle[] { "); + for (int i = 0; i < matchs.length; i++) { + printWriter.print("null"); + if (i < matchs.length - 1) { + printWriter.print(", "); + } + } + printWriter.println(" }, null);"); + } else { + final int tPos = bh.getTarget().getPosition(); + String target; + if (pos > tPos) { + target = "ih_" + tPos; + } else { + branches.add(bi); + target = "null"; + } + printWriter.println(" BranchInstruction " + name + " = _factory.createBranchInstruction(" + CONSTANT_PREFIX + + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target + ");"); + } + if (bh.hasTargeters()) { + printWriter.println(" ih_" + pos + " = il.append(" + name + ");"); + } else { + printWriter.println(" il.append(" + name + ");"); + } + } + + @Override + public void visitCHECKCAST(final CHECKCAST i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); + } + + @Override + public void visitConstantPushInstruction(final ConstantPushInstruction i) { + createConstant(i.getValue()); + } + + @Override + public void visitFieldInstruction(final FieldInstruction i) { + final short opcode = i.getOpcode(); + final String className = i.getReferenceType(constantPoolGen).getClassName(); + final String fieldName = i.getFieldName(constantPoolGen); + final Type type = i.getFieldType(constantPoolGen); + printWriter.println("il.append(_factory.createFieldAccess(\"" + className + "\", \"" + fieldName + "\", " + BCELifier.printType(type) + ", " + + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + @Override + public void visitINSTANCEOF(final INSTANCEOF i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createInstanceOf(" + BCELifier.printType(type) + "));"); + } + + private boolean visitInstruction(final Instruction i) { + final short opcode = i.getOpcode(); + if (InstructionConst.getInstruction(opcode) != null && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below + printWriter.println("il.append(InstructionConst." + i.getName().toUpperCase(Locale.ENGLISH) + ");"); + return true; + } + return false; + } + + @Override + public void visitInvokeInstruction(final InvokeInstruction i) { + final short opcode = i.getOpcode(); + final String className = i.getReferenceType(constantPoolGen).getClassName(); + final String methodName = i.getMethodName(constantPoolGen); + final Type type = i.getReturnType(constantPoolGen); + final Type[] argTypes = i.getArgumentTypes(constantPoolGen); + printWriter.println("il.append(_factory.createInvoke(\"" + className + "\", \"" + methodName + "\", " + BCELifier.printType(type) + ", " + + BCELifier.printArgumentTypes(argTypes) + ", " + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + @Override + public void visitLDC(final LDC i) { + createConstant(i.getValue(constantPoolGen)); + } + + @Override + public void visitLDC2_W(final LDC2_W i) { + createConstant(i.getValue(constantPoolGen)); + } + + @Override + public void visitLocalVariableInstruction(final LocalVariableInstruction i) { + final short opcode = i.getOpcode(); + final Type type = i.getType(constantPoolGen); + if (opcode == Const.IINC) { + printWriter.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));"); + } else { + final String kind = opcode < Const.ISTORE ? "Load" : "Store"; + printWriter.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));"); + } + } + + @Override + public void visitRET(final RET i) { + printWriter.println("il.append(new RET(" + i.getIndex() + "));"); + } + + @Override + public void visitReturnInstruction(final ReturnInstruction i) { + final Type type = i.getType(constantPoolGen); + printWriter.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java new file mode 100644 index 0000000..3203c1d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/BCELifier.java @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.Locale; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.Repository; +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.ConstantValue; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; +import com.sun.org.apache.bcel.internal.generic.ArrayType; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.MethodGen; +import com.sun.org.apache.bcel.internal.generic.Type; + +/** + * This class takes a given JavaClass object and converts it to a Java program that creates that very class using BCEL. + * This gives new users of BCEL a useful example showing how things are done with BCEL. It does not cover all features + * of BCEL, but tries to mimic hand-written code as close as possible. + * + * @LastModified: Feb 2023 + */ +public class BCELifier extends com.sun.org.apache.bcel.internal.classfile.EmptyVisitor { + + // The base package name for imports; assumes Const is at the top level + // N.B we use the class so renames will be detected by the compiler/IDE + private static final String BASE_PACKAGE = Const.class.getPackage().getName(); + private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + "."; + private final JavaClass clazz; + private final PrintWriter printWriter; + private final ConstantPoolGen constantPoolGen; + + /** + * Constructs a new instance. + * + * @param clazz Java class to "decompile". + * @param out where to print the Java program in UTF-8. + */ + public BCELifier(final JavaClass clazz, final OutputStream out) { + this.clazz = clazz; + this.printWriter = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), false); + this.constantPoolGen = new ConstantPoolGen(this.clazz.getConstantPool()); + } + + // Needs to be accessible from unit test code + static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException { + JavaClass javaClass; + if ((javaClass = Repository.lookupClass(name)) == null) { + javaClass = new ClassParser(name).parse(); // May throw IOException + } + return javaClass; + } + + /** + * Default main method + */ + public static void _main(final String[] argv) throws Exception { + if (argv.length != 1) { + System.out.println("Usage: BCELifier className"); + System.out.println("\tThe class must exist on the classpath"); + return; + } + final BCELifier bcelifier = new BCELifier(getJavaClass(argv[0]), System.out); + bcelifier.start(); + } + + static String printArgumentTypes(final Type[] argTypes) { + if (argTypes.length == 0) { + return "Type.NO_ARGS"; + } + final StringBuilder args = new StringBuilder(); + for (int i = 0; i < argTypes.length; i++) { + args.append(printType(argTypes[i])); + if (i < argTypes.length - 1) { + args.append(", "); + } + } + return "new Type[] { " + args.toString() + " }"; + } + + static String printFlags(final int flags) { + return printFlags(flags, FLAGS.UNKNOWN); + } + + /** + * Return a string with the flag settings + * + * @param flags the flags field to interpret + * @param location the item type + * @return the formatted string + * @since 6.0 made public + */ + public static String printFlags(final int flags, final FLAGS location) { + if (flags == 0) { + return "0"; + } + final StringBuilder buf = new StringBuilder(); + for (int i = 0, pow = 1; pow <= Const.MAX_ACC_FLAG_I; i++) { + if ((flags & pow) != 0) { + if (pow == Const.ACC_SYNCHRONIZED && location == FLAGS.CLASS) { + buf.append(CONSTANT_PREFIX).append("ACC_SUPER | "); + } else if (pow == Const.ACC_VOLATILE && location == FLAGS.METHOD) { + buf.append(CONSTANT_PREFIX).append("ACC_BRIDGE | "); + } else if (pow == Const.ACC_TRANSIENT && location == FLAGS.METHOD) { + buf.append(CONSTANT_PREFIX).append("ACC_VARARGS | "); + } else if (i < Const.ACCESS_NAMES_LENGTH) { + buf.append(CONSTANT_PREFIX).append("ACC_").append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH)).append(" | "); + } else { + buf.append(String.format(CONSTANT_PREFIX + "ACC_BIT %x | ", pow)); + } + } + pow <<= 1; + } + final String str = buf.toString(); + return str.substring(0, str.length() - 3); + } + + static String printType(final String signature) { + final Type type = Type.getType(signature); + final byte t = type.getType(); + if (t <= Const.T_VOID) { + return "Type." + Const.getTypeName(t).toUpperCase(Locale.ENGLISH); + } + if (type.toString().equals("java.lang.String")) { + return "Type.STRING"; + } + if (type.toString().equals("java.lang.Object")) { + return "Type.OBJECT"; + } + if (type.toString().equals("java.lang.StringBuffer")) { + return "Type.STRINGBUFFER"; + } + if (type instanceof ArrayType) { + final ArrayType at = (ArrayType) type; + return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; + } + return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; + } + + static String printType(final Type type) { + return printType(type.getSignature()); + } + + private void printCreate() { + printWriter.println(" public void create(OutputStream out) throws IOException {"); + final Field[] fields = clazz.getFields(); + if (fields.length > 0) { + printWriter.println(" createFields();"); + } + final Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + printWriter.println(" createMethod_" + i + "();"); + } + printWriter.println(" _cg.getJavaClass().dump(out);"); + printWriter.println(" }"); + printWriter.println(); + } + + private void printMain() { + final String className = clazz.getClassName(); + printWriter.println(" public static void main(String[] args) throws Exception {"); + printWriter.println(" " + className + "Creator creator = new " + className + "Creator();"); + printWriter.println(" creator.create(new FileOutputStream(\"" + className + ".class\"));"); + printWriter.println(" }"); + } + + /** + * Start Java code generation + */ + public void start() { + visitJavaClass(clazz); + printWriter.flush(); + } + + @Override + public void visitField(final Field field) { + printWriter.println(); + printWriter.println( + " field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", " + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);"); + final ConstantValue cv = field.getConstantValue(); + if (cv != null) { + printWriter.print(" field.setInitValue("); + if (field.getType() == Type.CHAR) { + printWriter.print("(char)"); + } + if (field.getType() == Type.SHORT) { + printWriter.print("(short)"); + } + if (field.getType() == Type.BYTE) { + printWriter.print("(byte)"); + } + printWriter.print(cv); + if (field.getType() == Type.LONG) { + printWriter.print("L"); + } + if (field.getType() == Type.FLOAT) { + printWriter.print("F"); + } + if (field.getType() == Type.DOUBLE) { + printWriter.print("D"); + } + printWriter.println(");"); + } + printWriter.println(" _cg.addField(field.getField());"); + } + + @Override + public void visitJavaClass(final JavaClass clazz) { + String className = clazz.getClassName(); + final String superName = clazz.getSuperclassName(); + final String packageName = clazz.getPackageName(); + final String inter = Utility.printArray(clazz.getInterfaceNames(), false, true); + if (packageName != null && !packageName.trim().isEmpty()) { + className = className.substring(packageName.length() + 1); + printWriter.println("package " + packageName + ";"); + printWriter.println(); + } + printWriter.println("import " + BASE_PACKAGE + ".generic.*;"); + printWriter.println("import " + BASE_PACKAGE + ".classfile.*;"); + printWriter.println("import " + BASE_PACKAGE + ".*;"); + printWriter.println("import java.io.*;"); + printWriter.println(); + printWriter.println("public class " + className + "Creator {"); + printWriter.println(" private InstructionFactory _factory;"); + printWriter.println(" private ConstantPoolGen _cp;"); + printWriter.println(" private ClassGen _cg;"); + printWriter.println(); + printWriter.println(" public " + className + "Creator() {"); + printWriter.println(" _cg = new ClassGen(\"" + (packageName.isEmpty() ? className : packageName + "." + className) + "\", \"" + superName + + "\", " + "\"" + clazz.getSourceFileName() + "\", " + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + "new String[] { " + inter + " });"); + printWriter.println(" _cg.setMajor(" + clazz.getMajor() + ");"); + printWriter.println(" _cg.setMinor(" + clazz.getMinor() + ");"); + printWriter.println(); + printWriter.println(" _cp = _cg.getConstantPool();"); + printWriter.println(" _factory = new InstructionFactory(_cg, _cp);"); + printWriter.println(" }"); + printWriter.println(); + printCreate(); + final Field[] fields = clazz.getFields(); + if (fields.length > 0) { + printWriter.println(" private void createFields() {"); + printWriter.println(" FieldGen field;"); + for (final Field field : fields) { + field.accept(this); + } + printWriter.println(" }"); + printWriter.println(); + } + final Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + printWriter.println(" private void createMethod_" + i + "() {"); + methods[i].accept(this); + printWriter.println(" }"); + printWriter.println(); + } + printMain(); + printWriter.println("}"); + } + + @Override + public void visitMethod(final Method method) { + final MethodGen mg = new MethodGen(method, clazz.getClassName(), constantPoolGen); + printWriter.println(" InstructionList il = new InstructionList();"); + printWriter.println(" MethodGen method = new MethodGen(" + printFlags(method.getAccessFlags(), FLAGS.METHOD) + ", " + printType(mg.getReturnType()) + + ", " + printArgumentTypes(mg.getArgumentTypes()) + ", " + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) + " }, \"" + + method.getName() + "\", \"" + clazz.getClassName() + "\", il, _cp);"); + final ExceptionTable exceptionTable = method.getExceptionTable(); + if (exceptionTable != null) { + final String[] exceptionNames = exceptionTable.getExceptionNames(); + for (final String exceptionName : exceptionNames) { + printWriter.print(" method.addException(\""); + printWriter.print(exceptionName); + printWriter.println("\");"); + } + } + printWriter.println(); + final BCELFactory factory = new BCELFactory(mg, printWriter); + factory.start(); + printWriter.println(" method.setMaxStack();"); + printWriter.println(" method.setMaxLocals();"); + printWriter.println(" _cg.addMethod(method.getMethod());"); + printWriter.println(" il.dispose();"); + } + + /** + * Enum corresponding to flag source. + */ + public enum FLAGS { + UNKNOWN, CLASS, METHOD, + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java new file mode 100644 index 0000000..3596c56 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ByteSequence.java @@ -0,0 +1,65 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; + +/** + * Utility class that implements a sequence of bytes which can be read via the 'readByte()' method. This is used to + * implement a wrapper for the Java byte code stream to gain some more readability. + */ +public final class ByteSequence extends DataInputStream { + + private final ByteArrayStream byteStream; + + public ByteSequence(final byte[] bytes) { + super(new ByteArrayStream(bytes)); + byteStream = (ByteArrayStream) in; + } + + public int getIndex() { + return byteStream.getPosition(); + } + + void unreadByte() { + byteStream.unreadByte(); + } + + private static final class ByteArrayStream extends ByteArrayInputStream { + + ByteArrayStream(final byte[] bytes) { + super(bytes); + } + + int getPosition() { + // pos is protected in ByteArrayInputStream + return pos; + } + + void unreadByte() { + if (pos > 0) { + pos--; + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java new file mode 100644 index 0000000..152b261 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Class2HTML.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Read class file(s) and convert them into HTML files. + *

+ * Given a JavaClass object "class" that is in package "package" five files will be created in the specified directory. + * + *

    + *
  1. "package"."class".html as the main file which defines the frames for the following subfiles. + *
  2. "package"."class"_attributes.html contains all (known) attributes found in the file + *
  3. "package"."class"_cp.html contains the constant pool + *
  4. "package"."class"_code.html contains the byte code + *
  5. "package"."class"_methods.html contains references to all methods and fields of the class + *
+ *

+ * All subfiles reference each other appropriately, e.g. clicking on a method in the Method's frame will jump to the + * appropriate method in the Code frame. + * + * @LastModified: Feb 2023 + */ +public class Class2HTML { + + private static final Set basicTypes = new HashSet<>(); + private static String classPackage; // name of package, unclean to make it static, but ... + private static String className; // name of current class, dito + private static ConstantPool constantPool; + + static { + basicTypes.add("int"); + basicTypes.add("short"); + basicTypes.add("boolean"); + basicTypes.add("void"); + basicTypes.add("char"); + basicTypes.add("byte"); + basicTypes.add("long"); + basicTypes.add("double"); + basicTypes.add("float"); + } + + private final JavaClass javaClass; // current class object + private final String dir; + + /** + * Write contents of the given JavaClass into HTML files. + * + * @param javaClass The class to write + * @param dir The directory to put the files in + * @throws IOException Thrown when an I/O exception of some sort has occurred. + */ + public Class2HTML(final JavaClass javaClass, final String dir) throws IOException { + this(javaClass, dir, StandardCharsets.UTF_8); + } + + private Class2HTML(final JavaClass javaClass, final String dir, final Charset charset) throws IOException { + final Method[] methods = javaClass.getMethods(); + this.javaClass = javaClass; + this.dir = dir; + className = javaClass.getClassName(); // Remember full name + constantPool = javaClass.getConstantPool(); + // Get package name by tacking off everything after the last '.' + final int index = className.lastIndexOf('.'); + if (index > -1) { + classPackage = className.substring(0, index); + } else { + classPackage = ""; // default package + } + final ConstantHTML constantHtml = new ConstantHTML(dir, className, classPackage, methods, constantPool, charset); + /* + * Attributes can't be written in one step, so we just open a file which will be written consequently. + */ + try (AttributeHTML attributeHtml = new AttributeHTML(dir, className, constantPool, constantHtml, charset)) { + new MethodHTML(dir, className, methods, javaClass.getFields(), constantHtml, attributeHtml, charset); + // Write main file (with frames, yuk) + writeMainHTML(attributeHtml, charset); + new CodeHTML(dir, className, methods, constantPool, constantHtml, charset); + } + } + + public static void _main(final String[] argv) throws IOException { + final String[] fileName = new String[argv.length]; + int files = 0; + ClassParser parser = null; + JavaClass javaClass = null; + String zipFile = null; + final char sep = File.separatorChar; + String dir = "." + sep; // Where to store HTML files + /* + * Parse command line arguments. + */ + for (int i = 0; i < argv.length; i++) { + if (argv[i].charAt(0) == '-') { // command line switch + if (argv[i].equals("-d")) { // Specify target directory, default '.' + dir = argv[++i]; + if (!dir.endsWith("" + sep)) { + dir = dir + sep; + } + final File store = new File(dir); + if (!store.isDirectory()) { + final boolean created = store.mkdirs(); // Create target directory if necessary + if (!created && !store.isDirectory()) { + System.out.println("Tried to create the directory " + dir + " but failed"); + } + } + } else if (argv[i].equals("-zip")) { + zipFile = argv[++i]; + } else { + System.out.println("Unknown option " + argv[i]); + } + } else { + fileName[files++] = argv[i]; + } + } + if (files == 0) { + System.err.println("Class2HTML: No input files specified."); + } else { // Loop through files ... + for (int i = 0; i < files; i++) { + System.out.print("Processing " + fileName[i] + "..."); + if (zipFile == null) { + parser = new ClassParser(fileName[i]); // Create parser object from file + } else { + parser = new ClassParser(zipFile, fileName[i]); // Create parser object from zip file + } + javaClass = parser.parse(); + new Class2HTML(javaClass, dir); + System.out.println("Done."); + } + } + } + + /** + * Utility method that converts a class reference in the constant pool, i.e., an index to a string. + */ + static String referenceClass(final int index) { + String str = constantPool.getConstantString(index, Const.CONSTANT_Class); + str = Utility.compactClassName(str); + str = Utility.compactClassName(str, classPackage + ".", true); + return "" + str + ""; + } + + static String referenceType(final String type) { + String shortType = Utility.compactClassName(type); + shortType = Utility.compactClassName(shortType, classPackage + ".", true); + final int index = type.indexOf('['); // Type is an array? + String baseType = type; + if (index > -1) { + baseType = type.substring(0, index); // Tack of the '[' + } + // test for basic type + if (basicTypes.contains(baseType)) { + return "" + type + ""; + } + return "" + shortType + ""; + } + + static String toHTML(final String str) { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < str.length(); i++) { + char ch; + switch (ch = str.charAt(i)) { + case '<': + buf.append("<"); + break; + case '>': + buf.append(">"); + break; + case '\n': + buf.append("\\n"); + break; + case '\r': + buf.append("\\r"); + break; + default: + buf.append(ch); + } + } + return buf.toString(); + } + + private void writeMainHTML(final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + try (PrintWriter file = new PrintWriter(dir + className + ".html", charset.name())) { + file.println("\n" + "Documentation for " + className + "" + "\n" + "\n" + + "\n" + "\n" + "\n" + "\n" + + "\n" + "\n" + "\n" + ""); + } + final Attribute[] attributes = javaClass.getAttributes(); + for (int i = 0; i < attributes.length; i++) { + attributeHtml.writeAttribute(attributes[i], "class" + i); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java new file mode 100644 index 0000000..05ce40d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassQueue.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.util.LinkedList; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) queue of JavaClass objects. + * + * @LastModified: Jan 2020 + */ +public class ClassQueue { + + /** + * @deprecated (since 6.0) will be made private; do not access + */ + @Deprecated + protected LinkedList vec = new LinkedList<>(); // TODO not used externally + + public JavaClass dequeue() { + return vec.removeFirst(); + } + + public boolean empty() { + return vec.isEmpty(); + } + + public void enqueue(final JavaClass clazz) { + vec.addLast(clazz); + } + + @Override + public String toString() { + return vec.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java new file mode 100644 index 0000000..d143cee --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassSet.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.Const; + +import java.util.HashMap; +import java.util.Map; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (type-safe) set of JavaClass objects. Since JavaClass has no equals() method, the name of the class is used for comparison. + * + * @LastModified: Feb 2023 + * @see ClassStack + */ +public class ClassSet { + + private final Map map = new HashMap<>(); + + public boolean add(final JavaClass clazz) { + return map.putIfAbsent(clazz.getClassName(), clazz) != null; + } + + public boolean empty() { + return map.isEmpty(); + } + + public String[] getClassNames() { + return map.keySet().toArray(Const.EMPTY_STRING_ARRAY); + } + + public void remove(final JavaClass clazz) { + map.remove(clazz.getClassName()); + } + + public JavaClass[] toArray() { + return map.values().toArray(JavaClass.EMPTY_ARRAY); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java new file mode 100644 index 0000000..cc07acf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ClassStack.java @@ -0,0 +1,52 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.util.Stack; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) stack of JavaClass objects. + * + * @see Stack + */ +public class ClassStack { + + private final Stack stack = new Stack<>(); + + public boolean empty() { + return stack.empty(); + } + + public JavaClass pop() { + return stack.pop(); + } + + public void push(final JavaClass clazz) { + stack.push(clazz); + } + + public JavaClass top() { + return stack.peek(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java new file mode 100644 index 0000000..f69836a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/CodeHTML.java @@ -0,0 +1,565 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.util.BitSet; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.CodeException; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInvokeDynamic; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert code into HTML file. + */ +final class CodeHTML { + + private static boolean wide; + private final String className; // name of current class + // private Method[] methods; // Methods to print + private final PrintWriter printWriter; // file to write to + private final ConstantPool constantPool; + private final ConstantHTML constantHtml; + private BitSet gotoSet; + + CodeHTML(final String dir, final String className, final Method[] methods, final ConstantPool constantPool, final ConstantHTML constantHtml, + final Charset charset) throws IOException { + this.className = className; +// this.methods = methods; + this.constantPool = constantPool; + this.constantHtml = constantHtml; + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_code.html", charset.name())) { + printWriter = newPrintWriter; + printWriter.print(""); + printWriter.println(""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + printWriter.println(""); + } + } + + /** + * Disassemble a stream of byte codes and return the string representation. + * + * @param stream data input stream + * @return String representation of byte code + */ + private String codeToHTML(final ByteSequence bytes, final int methodNumber) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + String name; + String signature; + int defaultOffset = 0; + int low; + int high; + int index; + int classIndex; + int vindex; + int constant; + int[] jumpTable; + int noPadBytes = 0; + int offset; + final StringBuilder buf = new StringBuilder(256); // CHECKSTYLE IGNORE MagicNumber + buf.append("").append(Const.getOpcodeName(opcode)).append(""); + /* + * Special case: Skip (0-3) padding bytes, i.e., the following bytes are 4-byte-aligned + */ + if (opcode == Const.TABLESWITCH || opcode == Const.LOOKUPSWITCH) { + final int remainder = bytes.getIndex() % 4; + noPadBytes = remainder == 0 ? 0 : 4 - remainder; + for (int i = 0; i < noPadBytes; i++) { + bytes.readByte(); + } + // Both cases have a field default_offset in common + defaultOffset = bytes.readInt(); + } + switch (opcode) { + case Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + buf.append(""); + // Print switch indices in first row (and default) + jumpTable = new int[high - low + 1]; + for (int i = 0; i < jumpTable.length; i++) { + jumpTable[i] = offset + bytes.readInt(); + buf.append(""); + } + buf.append("\n"); + // Print target and default indices in second row + for (final int element : jumpTable) { + buf.append(""); + } + buf.append("\n
").append(low + i).append("default
").append(element).append("").append(defaultOffset) + .append("
\n"); + break; + /* + * Lookup switch has variable length arguments. + */ + case Const.LOOKUPSWITCH: + final int npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + jumpTable = new int[npairs]; + defaultOffset += offset; + buf.append(""); + // Print switch indices in first row (and default) + for (int i = 0; i < npairs; i++) { + final int match = bytes.readInt(); + jumpTable[i] = offset + bytes.readInt(); + buf.append(""); + } + buf.append("\n"); + // Print target and default indices in second row + for (int i = 0; i < npairs; i++) { + buf.append(""); + } + buf.append("\n
").append(match).append("default
").append(jumpTable[i]) + .append("").append(defaultOffset) + .append("
\n"); + break; + /* + * Two address bytes + offset from start of byte stream form the jump target. + */ + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + case Const.JSR: + index = bytes.getIndex() + bytes.readShort() - 1; + buf.append("").append(index).append(""); + break; + /* + * Same for 32-bit wide jumps + */ + case Const.GOTO_W: + case Const.JSR_W: + final int windex = bytes.getIndex() + bytes.readInt() - 1; + buf.append("").append(windex).append(""); + break; + /* + * Index byte references local variable (register) + */ + case Const.ALOAD: + case Const.ASTORE: + case Const.DLOAD: + case Const.DSTORE: + case Const.FLOAD: + case Const.FSTORE: + case Const.ILOAD: + case Const.ISTORE: + case Const.LLOAD: + case Const.LSTORE: + case Const.RET: + if (wide) { + vindex = bytes.readShort(); + wide = false; // Clear flag + } else { + vindex = bytes.readUnsignedByte(); + } + buf.append("%").append(vindex); + break; + /* + * Remember wide byte which is used to form a 16-bit address in the following instruction. Relies on that the method is + * called again with the following opcode. + */ + case Const.WIDE: + wide = true; + buf.append("(wide)"); + break; + /* + * Array of basic type. + */ + case Const.NEWARRAY: + buf.append("").append(Const.getTypeName(bytes.readByte())).append(""); + break; + /* + * Access object/class fields. + */ + case Const.GETFIELD: + case Const.GETSTATIC: + case Const.PUTFIELD: + case Const.PUTSTATIC: + index = bytes.readShort(); + final ConstantFieldref c1 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class); + classIndex = c1.getClassIndex(); + name = constantPool.getConstantString(classIndex, Const.CONSTANT_Class); + name = Utility.compactClassName(name, false); + index = c1.getNameAndTypeIndex(); + final String fieldName = constantPool.constantToString(index, Const.CONSTANT_NameAndType); + if (name.equals(className)) { // Local field + buf.append("").append(fieldName) + .append("\n"); + } else { + buf.append(constantHtml.referenceConstant(classIndex)).append(".").append(fieldName); + } + break; + /* + * Operands are references to classes in constant pool + */ + case Const.CHECKCAST: + case Const.INSTANCEOF: + case Const.NEW: + index = bytes.readShort(); + buf.append(constantHtml.referenceConstant(index)); + break; + /* + * Operands are references to methods in constant pool + */ + case Const.INVOKESPECIAL: + case Const.INVOKESTATIC: + case Const.INVOKEVIRTUAL: + case Const.INVOKEINTERFACE: + case Const.INVOKEDYNAMIC: + final int mIndex = bytes.readShort(); + String str; + if (opcode == Const.INVOKEINTERFACE) { // Special treatment needed + bytes.readUnsignedByte(); // Redundant + bytes.readUnsignedByte(); // Reserved +// int nargs = bytes.readUnsignedByte(); // Redundant +// int reserved = bytes.readUnsignedByte(); // Reserved + final ConstantInterfaceMethodref c = constantPool.getConstant(mIndex, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class); + classIndex = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(classIndex); + } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed + bytes.readUnsignedByte(); // Reserved + bytes.readUnsignedByte(); // Reserved + final ConstantInvokeDynamic c = constantPool.getConstant(mIndex, Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class); + index = c.getNameAndTypeIndex(); + name = "#" + c.getBootstrapMethodAttrIndex(); + } else { + // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to + // reference EITHER a Methodref OR an InterfaceMethodref. + // Not sure if that affects this code or not. (markro) + final ConstantMethodref c = constantPool.getConstant(mIndex, Const.CONSTANT_Methodref, ConstantMethodref.class); + classIndex = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(classIndex); + } + str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant(index, Const.CONSTANT_NameAndType))); + // Get signature, i.e., types + final ConstantNameAndType c2 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + final String type = Utility.methodSignatureReturnType(signature, false); + buf.append(name).append(".").append(str) + .append("").append("("); + // List arguments + for (int i = 0; i < args.length; i++) { + buf.append(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + buf.append(", "); + } + } + // Attach return type + buf.append("):").append(Class2HTML.referenceType(type)); + break; + /* + * Operands are references to items in constant pool + */ + case Const.LDC_W: + case Const.LDC2_W: + index = bytes.readShort(); + buf.append("") + .append(Class2HTML.toHTML(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append(""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("") + .append(Class2HTML.toHTML(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append(""); + break; + /* + * Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readShort(); + buf.append(constantHtml.referenceConstant(index)); + break; + /* + * Multidimensional array of references. + */ + case Const.MULTIANEWARRAY: + index = bytes.readShort(); + final int dimensions = bytes.readByte(); + buf.append(constantHtml.referenceConstant(index)).append(":").append(dimensions).append("-dimensional"); + break; + /* + * Increment local variable. + */ + case Const.IINC: + if (wide) { + vindex = bytes.readShort(); + constant = bytes.readShort(); + wide = false; + } else { + vindex = bytes.readUnsignedByte(); + constant = bytes.readByte(); + } + buf.append("%").append(vindex).append(" ").append(constant); + break; + default: + if (Const.getNoOfOperands(opcode) > 0) { + for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) { + switch (Const.getOperandType(opcode, i)) { + case Const.T_BYTE: + buf.append(bytes.readUnsignedByte()); + break; + case Const.T_SHORT: // Either branch or index + buf.append(bytes.readShort()); + break; + case Const.T_INT: + buf.append(bytes.readInt()); + break; + default: // Never reached + throw new IllegalStateException("Unreachable default case reached! " + Const.getOperandType(opcode, i)); + } + buf.append(" "); + } + } + } + buf.append(""); + return buf.toString(); + } + + /** + * Find all target addresses in code, so that they can be marked with <A NAME = ...>. Target addresses are kept in + * an BitSet object. + */ + private void findGotos(final ByteSequence bytes, final Code code) throws IOException { + int index; + gotoSet = new BitSet(bytes.available()); + int opcode; + /* + * First get Code attribute from method and the exceptions handled (try .. catch) in this method. We only need the line + * number here. + */ + if (code != null) { + final CodeException[] ce = code.getExceptionTable(); + for (final CodeException cex : ce) { + gotoSet.set(cex.getStartPC()); + gotoSet.set(cex.getEndPC()); + gotoSet.set(cex.getHandlerPC()); + } + // Look for local variables and their range + final Attribute[] attributes = code.getAttributes(); + for (final Attribute attribute : attributes) { + if (attribute.getTag() == Const.ATTR_LOCAL_VARIABLE_TABLE) { + ((LocalVariableTable) attribute).forEach(var -> { + final int start = var.getStartPC(); + gotoSet.set(start); + gotoSet.set(start + var.getLength()); + }); + break; + } + } + } + // Get target addresses from GOTO, JSR, TABLESWITCH, etc. + while (bytes.available() > 0) { + opcode = bytes.readUnsignedByte(); + // System.out.println(getOpcodeName(opcode)); + switch (opcode) { + case Const.TABLESWITCH: + case Const.LOOKUPSWITCH: + // bytes.readByte(); // Skip already read byte + final int remainder = bytes.getIndex() % 4; + final int noPadBytes = remainder == 0 ? 0 : 4 - remainder; + int defaultOffset; + int offset; + for (int j = 0; j < noPadBytes; j++) { + bytes.readByte(); + } + // Both cases have a field default_offset in common + defaultOffset = bytes.readInt(); + if (opcode == Const.TABLESWITCH) { + final int low = bytes.readInt(); + final int high = bytes.readInt(); + offset = bytes.getIndex() - 12 - noPadBytes - 1; + defaultOffset += offset; + gotoSet.set(defaultOffset); + for (int j = 0; j < high - low + 1; j++) { + index = offset + bytes.readInt(); + gotoSet.set(index); + } + } else { // LOOKUPSWITCH + final int npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - noPadBytes - 1; + defaultOffset += offset; + gotoSet.set(defaultOffset); + for (int j = 0; j < npairs; j++) { +// int match = bytes.readInt(); + bytes.readInt(); + index = offset + bytes.readInt(); + gotoSet.set(index); + } + } + break; + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + case Const.JSR: + // bytes.readByte(); // Skip already read byte + index = bytes.getIndex() + bytes.readShort() - 1; + gotoSet.set(index); + break; + case Const.GOTO_W: + case Const.JSR_W: + // bytes.readByte(); // Skip already read byte + index = bytes.getIndex() + bytes.readInt() - 1; + gotoSet.set(index); + break; + default: + bytes.unreadByte(); + codeToHTML(bytes, 0); // Ignore output + } + } + } + + /** + * Write a single method with the byte code associated with it. + */ + private void writeMethod(final Method method, final int methodNumber) throws IOException { + // Get raw signature + final String signature = method.getSignature(); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + // Get method name + final String name = method.getName(); + final String htmlName = Class2HTML.toHTML(name); + // Get method's access flags + String access = Utility.accessToString(method.getAccessFlags()); + access = Utility.replace(access, " ", " "); + // Get the method's attributes, the Code Attribute in particular + final Attribute[] attributes = method.getAttributes(); + printWriter.print("

" + access + " " + "" + Class2HTML.referenceType(type) + + " " + htmlName + "("); + for (int i = 0; i < args.length; i++) { + printWriter.print(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + printWriter.print(", "); + } + } + printWriter.println(")

"); + Code c = null; + byte[] code = null; + if (attributes.length > 0) { + printWriter.print("

Attributes

    \n"); + for (int i = 0; i < attributes.length; i++) { + byte tag = attributes[i].getTag(); + if (tag != Const.ATTR_UNKNOWN) { + printWriter.print("
  • " + + Const.getAttributeName(tag) + "
  • \n"); + } else { + printWriter.print("
  • " + attributes[i] + "
  • "); + } + if (tag == Const.ATTR_CODE) { + c = (Code) attributes[i]; + final Attribute[] attributes2 = c.getAttributes(); + code = c.getCode(); + printWriter.print(""); + } + } + printWriter.println("
"); + } + if (code != null) { // No code, an abstract method, e.g. + // System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1)); + // Print the byte code + try (ByteSequence stream = new ByteSequence(code)) { + stream.mark(stream.available()); + findGotos(stream, c); + stream.reset(); + printWriter.println("" + ""); + while (stream.available() > 0) { + final int offset = stream.getIndex(); + final String str = codeToHTML(stream, methodNumber); + String anchor = ""; + /* + * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every line is very + * inefficient! + */ + if (gotoSet.get(offset)) { + anchor = ""; + } + String anchor2; + if (stream.getIndex() == code.length) { + anchor2 = "" + offset + ""; + } else { + anchor2 = "" + offset; + } + printWriter.println(""); + } + } + // Mark last line, may be targetted from Attributes window + printWriter.println(""); + printWriter.println("
Byte
offset
InstructionArgument
" + anchor2 + "" + anchor + str + "
"); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java new file mode 100644 index 0000000..e80a55f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ConstantHTML.java @@ -0,0 +1,203 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Constant; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; +import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; +import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantString; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert constant pool into HTML file. + */ +final class ConstantHTML { + + private final String className; // name of current class + private final String classPackage; // name of package + private final ConstantPool constantPool; // reference to constant pool + private final PrintWriter printWriter; // file to write to + private final String[] constantRef; // String to return for cp[i] + private final Constant[] constants; // The constants in the cp + private final Method[] methods; + + ConstantHTML(final String dir, final String className, final String classPackage, final Method[] methods, final ConstantPool constantPool, + final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.classPackage = classPackage; + this.constantPool = constantPool; + this.methods = methods; + this.constants = constantPool.getConstantPool(); + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_cp.html", charset.name())) { + printWriter = newPrintWriter; + constantRef = new String[constants.length]; + constantRef[0] = "<unknown>"; + printWriter.print(""); + printWriter.println(""); + // Loop through constants, constants[0] is reserved + for (int i = 1; i < constants.length; i++) { + if (i % 2 == 0) { + printWriter.print("\n"); + } + printWriter.println("
"); + } else { + printWriter.print("
"); + } + if (constants[i] != null) { + writeConstant(i); + } + printWriter.print("
"); + } + } + + private int getMethodNumber(final String str) { + for (int i = 0; i < methods.length; i++) { + final String cmp = methods[i].getName() + methods[i].getSignature(); + if (cmp.equals(str)) { + return i; + } + } + return -1; + } + + String referenceConstant(final int index) { + return constantRef[index]; + } + + private void writeConstant(final int index) { + final byte tag = constants[index].getTag(); + int classIndex; + int nameIndex; + String ref; + // The header is always the same + printWriter.println("

" + index + " " + Const.getConstantName(tag) + "

"); + /* + * For every constant type get the needed parameters and print them appropriately + */ + switch (tag) { + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + // Get class_index and name_and_type_index, depending on type + if (tag == Const.CONSTANT_Methodref) { + final ConstantMethodref c = constantPool.getConstant(index, Const.CONSTANT_Methodref, ConstantMethodref.class); + classIndex = c.getClassIndex(); + nameIndex = c.getNameAndTypeIndex(); + } else { + final ConstantInterfaceMethodref c1 = constantPool.getConstant(index, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class); + classIndex = c1.getClassIndex(); + nameIndex = c1.getNameAndTypeIndex(); + } + // Get method name and its class + final String methodName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType); + final String htmlMethodName = Class2HTML.toHTML(methodName); + // Partially compacted class name, i.e., / -> . + final String methodClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class); + String shortMethodClass = Utility.compactClassName(methodClass); // I.e., remove java.lang. + shortMethodClass = Utility.compactClassName(shortMethodClass, classPackage + ".", true); // Remove class package prefix + // Get method signature + final ConstantNameAndType c2 = constantPool.getConstant(nameIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + final String signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + final String retType = Class2HTML.referenceType(type); + final StringBuilder buf = new StringBuilder("("); + for (int i = 0; i < args.length; i++) { + buf.append(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + buf.append(", "); + } + } + buf.append(")"); + final String argTypes = buf.toString(); + if (methodClass.equals(className)) { + ref = "" + htmlMethodName + ""; + } else { + ref = "" + shortMethodClass + "." + htmlMethodName; + } + constantRef[index] = retType + " " + shortMethodClass + + "." + htmlMethodName + " " + argTypes; + printWriter.println("

" + retType + " " + ref + argTypes + " \n

"); + break; + case Const.CONSTANT_Fieldref: + // Get class_index and name_and_type_index + final ConstantFieldref c3 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class); + classIndex = c3.getClassIndex(); + nameIndex = c3.getNameAndTypeIndex(); + // Get method name and its class (compacted) + final String fieldClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class); + String shortFieldClass = Utility.compactClassName(fieldClass); // I.e., remove java.lang. + shortFieldClass = Utility.compactClassName(shortFieldClass, classPackage + ".", true); // Remove class package prefix + final String fieldName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType); + if (fieldClass.equals(className)) { + ref = "" + fieldName + ""; + } else { + ref = "" + shortFieldClass + "." + fieldName + "\n"; + } + constantRef[index] = "" + shortFieldClass + "." + fieldName + ""; + printWriter.println("

" + ref + "
\n" + "

"); + break; + case Const.CONSTANT_Class: + final ConstantClass c4 = constantPool.getConstant(index, Const.CONSTANT_Class, ConstantClass.class); + nameIndex = c4.getNameIndex(); + final String className2 = constantPool.constantToString(index, tag); // / -> . + String shortClassName = Utility.compactClassName(className2); // I.e., remove java.lang. + shortClassName = Utility.compactClassName(shortClassName, classPackage + ".", true); // Remove class package prefix + ref = "" + shortClassName + ""; + constantRef[index] = "" + shortClassName + ""; + printWriter.println("

" + ref + "

\n"); + break; + case Const.CONSTANT_String: + final ConstantString c5 = constantPool.getConstant(index, Const.CONSTANT_String, ConstantString.class); + nameIndex = c5.getStringIndex(); + final String str = Class2HTML.toHTML(constantPool.constantToString(index, tag)); + printWriter.println("

" + str + "

\n"); + break; + case Const.CONSTANT_NameAndType: + final ConstantNameAndType c6 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class); + nameIndex = c6.getNameIndex(); + final int signatureIndex = c6.getSignatureIndex(); + printWriter.println("

" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "

\n"); + break; + default: + printWriter.println("

" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "\n"); + } // switch + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java new file mode 100644 index 0000000..610a17d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/InstructionFinder.java @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.generic.ClassGenException; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; + +/** + * InstructionFinder is a tool to search for given instructions patterns, i.e., match sequences of instructions in an + * instruction list via regular expressions. This can be used, e.g., in order to implement a peep hole optimizer that + * looks for code patterns and replaces them with faster equivalents. + * + *

+ * This class internally uses the java.util.regex package to search for regular expressions. + *

+ * A typical application would look like this: + * + *

+ *
+ *
+ *   InstructionFinder f   = new InstructionFinder(il);
+ *   String            pat = "IfInstruction ICONST_0 GOTO ICONST_1 NOP (IFEQ|IFNE)";
+ *
+ *   for (Iterator i = f.search(pat, constraint); i.hasNext(); ) {
+ *   InstructionHandle[] match = (InstructionHandle[])i.next();
+ *   ...
+ *   il.delete(match[1], match[5]);
+ *   ...
+ *   }
+ *
+ *
+ * 
+ * + * @LastModified: May 2021 + * @see com.sun.org.apache.bcel.internal.generic.Instruction + * @see InstructionList + */ +public class InstructionFinder { + + /** + * Code patterns found may be checked using an additional user-defined constraint object whether they really match the + * needed criterion. I.e., check constraints that can not expressed with regular expressions. + */ + public interface CodeConstraint { + + /** + * @param match array of instructions matching the requested pattern + * @return true if the matched area is really useful + */ + boolean checkCode(InstructionHandle[] match); + } + + private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1 + private static final int NO_OPCODES = 256; // Potential number, some are not used + private static final Map map = new HashMap<>(); + + // Initialize pattern map + static { + map.put("arithmeticinstruction", + "(irem|lrem|iand|ior|ineg|isub|lneg|fneg|fmul|ldiv|fadd|lxor|frem|idiv|land|ixor|ishr|fsub|lshl|fdiv|iadd|lor|dmul|lsub|ishl|imul|lmul|lushr|dneg|iushr|lshr|ddiv|drem|dadd|ladd|dsub)"); + map.put("invokeinstruction", "(invokevirtual|invokeinterface|invokestatic|invokespecial|invokedynamic)"); + map.put("arrayinstruction", + "(baload|aastore|saload|caload|fastore|lastore|iaload|castore|iastore|aaload|bastore|sastore|faload|laload|daload|dastore)"); + map.put("gotoinstruction", "(goto|goto_w)"); + map.put("conversioninstruction", "(d2l|l2d|i2s|d2i|l2i|i2b|l2f|d2f|f2i|i2d|i2l|f2d|i2c|f2l|i2f)"); + map.put("localvariableinstruction", "(fstore|iinc|lload|dstore|dload|iload|aload|astore|istore|fload|lstore)"); + map.put("loadinstruction", "(fload|dload|lload|iload|aload)"); + map.put("fieldinstruction", "(getfield|putstatic|getstatic|putfield)"); + map.put("cpinstruction", + "(ldc2_w|invokeinterface|invokedynamic|multianewarray|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|ldc_w|invokestatic|invokevirtual|putfield|ldc|new|anewarray)"); + map.put("stackinstruction", "(dup2|swap|dup2_x2|pop|pop2|dup|dup2_x1|dup_x2|dup_x1)"); + map.put("branchinstruction", + "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)"); + map.put("returninstruction", "(lreturn|ireturn|freturn|dreturn|areturn|return)"); + map.put("storeinstruction", "(istore|fstore|dstore|astore|lstore)"); + map.put("select", "(tableswitch|lookupswitch)"); + map.put("ifinstruction", + "(ifeq|ifgt|if_icmpne|if_icmpeq|ifge|ifnull|ifne|if_icmple|if_icmpge|if_acmpeq|if_icmplt|if_acmpne|ifnonnull|iflt|if_icmpgt|ifle)"); + map.put("jsrinstruction", "(jsr|jsr_w)"); + map.put("variablelengthinstruction", "(tableswitch|jsr|goto|lookupswitch)"); + map.put("unconditionalbranch", "(goto|jsr|jsr_w|athrow|goto_w)"); + map.put("constantpushinstruction", "(dconst|bipush|sipush|fconst|iconst|lconst)"); + map.put("typedinstruction", + "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dastore|ret|f2d|f2i|drem|iinc|i2c|checkcast|frem|lreturn|astore|lushr|daload|dneg|fastore|istore|lshl|ldiv|lstore|areturn|ishr|ldc_w|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|faload|sipush|iushr|caload|instanceof|invokespecial|putfield|fmul|ireturn|laload|d2f|lneg|ixor|i2l|fdiv|lastore|multianewarray|i2b|getstatic|i2d|putstatic|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|freturn|ldc|aconst_null|castore|lmul|ldc2_w|dadd|iconst|f2l|ddiv|dstore|land|jsr|anewarray|dmul|bipush|dsub|sastore|d2i|i2s|lshr|iadd|l2i|lload|bastore|fstore|fneg|iload|fadd|baload|fconst|ior|ineg|dreturn|l2f|lconst|getfield|invokevirtual|invokestatic|iastore)"); + map.put("popinstruction", "(fstore|dstore|pop|pop2|astore|putstatic|istore|lstore)"); + map.put("allocationinstruction", "(multianewarray|new|anewarray|newarray)"); + map.put("indexedinstruction", + "(lload|lstore|fload|ldc2_w|invokeinterface|invokedynamic|multianewarray|astore|dload|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|dstore|istore|iinc|ldc_w|ret|fstore|invokestatic|iload|putfield|invokevirtual|ldc|new|aload|anewarray)"); + map.put("pushinstruction", "(dup|lload|dup2|bipush|fload|ldc2_w|sipush|lconst|fconst|dload|getstatic|ldc_w|aconst_null|dconst|iload|ldc|iconst|aload)"); + map.put("stackproducer", + "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dup|f2d|f2i|drem|i2c|checkcast|frem|lushr|daload|dneg|lshl|ldiv|ishr|ldc_w|invokeinterface|invokedynamic|lxor|ishl|l2d|i2f|faload|sipush|iushr|caload|instanceof|invokespecial|fmul|laload|d2f|lneg|ixor|i2l|fdiv|getstatic|i2b|swap|i2d|dup2|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|ldc|arraylength|aconst_null|tableswitch|lmul|ldc2_w|iconst|dadd|f2l|ddiv|land|jsr|anewarray|dmul|bipush|dsub|d2i|newarray|i2s|lshr|iadd|lload|l2i|fneg|iload|fadd|baload|fconst|lookupswitch|ior|ineg|lconst|l2f|getfield|invokevirtual|invokestatic)"); + map.put("stackconsumer", + "(imul|lsub|lor|iflt|fcmpg|if_icmpgt|iand|ifeq|if_icmplt|lrem|ifnonnull|idiv|d2l|isub|dcmpg|dastore|if_icmpeq|f2d|f2i|drem|i2c|checkcast|frem|lreturn|astore|lushr|pop2|monitorexit|dneg|fastore|istore|lshl|ldiv|lstore|areturn|if_icmpge|ishr|monitorenter|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|iushr|instanceof|invokespecial|fmul|ireturn|d2f|lneg|ixor|pop|i2l|ifnull|fdiv|lastore|i2b|if_acmpeq|ifge|swap|i2d|putstatic|fcmpl|ladd|irem|dcmpl|fsub|freturn|ifgt|castore|lmul|dadd|f2l|ddiv|dstore|land|if_icmpne|if_acmpne|dmul|dsub|sastore|ifle|d2i|i2s|lshr|iadd|l2i|bastore|fstore|fneg|fadd|ior|ineg|ifne|dreturn|l2f|if_icmple|getfield|invokevirtual|invokestatic|iastore)"); + map.put("exceptionthrower", + "(irem|lrem|laload|putstatic|baload|dastore|areturn|getstatic|ldiv|anewarray|iastore|castore|idiv|saload|lastore|fastore|putfield|lreturn|caload|getfield|return|aastore|freturn|newarray|instanceof|multianewarray|athrow|faload|iaload|aaload|dreturn|monitorenter|checkcast|bastore|arraylength|new|invokevirtual|sastore|ldc_w|ireturn|invokespecial|monitorexit|invokeinterface|invokedynamic|ldc|invokestatic|daload)"); + map.put("loadclass", + "(multianewarray|invokeinterface|invokedynamic|instanceof|invokespecial|putfield|checkcast|putstatic|invokevirtual|new|getstatic|invokestatic|getfield|anewarray)"); + map.put("instructiontargeter", + "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)"); + // Some aliases + map.put("if_icmp", "(if_icmpne|if_icmpeq|if_icmple|if_icmpge|if_icmplt|if_icmpgt)"); + map.put("if_acmp", "(if_acmpeq|if_acmpne)"); + map.put("if", "(ifeq|ifne|iflt|ifge|ifgt|ifle)"); + // Precompile some aliases first + map.put("iconst", precompile(Const.ICONST_0, Const.ICONST_5, Const.ICONST_M1)); + map.put("lconst", new String(new char[]{'(', makeChar(Const.LCONST_0), '|', makeChar(Const.LCONST_1), ')'})); + map.put("dconst", new String(new char[]{'(', makeChar(Const.DCONST_0), '|', makeChar(Const.DCONST_1), ')'})); + map.put("fconst", new String(new char[]{'(', makeChar(Const.FCONST_0), '|', makeChar(Const.FCONST_1), '|', makeChar(Const.FCONST_2), ')'})); + map.put("lload", precompile(Const.LLOAD_0, Const.LLOAD_3, Const.LLOAD)); + map.put("iload", precompile(Const.ILOAD_0, Const.ILOAD_3, Const.ILOAD)); + map.put("dload", precompile(Const.DLOAD_0, Const.DLOAD_3, Const.DLOAD)); + map.put("fload", precompile(Const.FLOAD_0, Const.FLOAD_3, Const.FLOAD)); + map.put("aload", precompile(Const.ALOAD_0, Const.ALOAD_3, Const.ALOAD)); + map.put("lstore", precompile(Const.LSTORE_0, Const.LSTORE_3, Const.LSTORE)); + map.put("istore", precompile(Const.ISTORE_0, Const.ISTORE_3, Const.ISTORE)); + map.put("dstore", precompile(Const.DSTORE_0, Const.DSTORE_3, Const.DSTORE)); + map.put("fstore", precompile(Const.FSTORE_0, Const.FSTORE_3, Const.FSTORE)); + map.put("astore", precompile(Const.ASTORE_0, Const.ASTORE_3, Const.ASTORE)); + // Compile strings + map.forEach((key, value) -> { + final char ch = value.charAt(1); // Omit already precompiled patterns + if (ch < OFFSET) { + map.put(key, compilePattern(value)); // precompile all patterns + } + }); + // Add instruction alias to match anything + final StringBuilder buf = new StringBuilder("("); + for (short i = 0; i < NO_OPCODES; i++) { + if (Const.getNoOfOperands(i) != Const.UNDEFINED) { // Not an invalid opcode + buf.append(makeChar(i)); + if (i < NO_OPCODES - 1) { + buf.append('|'); + } + } + } + buf.append(')'); + map.put("instruction", buf.toString()); + } + + /** + * Replace symbolic names of instructions with the appropriate character and remove all white space from string. Meta + * characters such as +, * are ignored. + * + * @param pattern The pattern to compile + * @return translated regular expression string + */ + private static String compilePattern(final String pattern) { + // Bug: BCEL-77 - Instructions are assumed to be english, to avoid odd Locale issues + final String lower = pattern.toLowerCase(Locale.ENGLISH); + final StringBuilder buf = new StringBuilder(); + final int size = pattern.length(); + for (int i = 0; i < size; i++) { + char ch = lower.charAt(i); + if (Character.isLetterOrDigit(ch)) { + final StringBuilder name = new StringBuilder(); + while ((Character.isLetterOrDigit(ch) || ch == '_') && i < size) { + name.append(ch); + if (++i >= size) { + break; + } + ch = lower.charAt(i); + } + i--; + buf.append(mapName(name.toString())); + } else if (!Character.isWhitespace(ch)) { + buf.append(ch); + } + } + return buf.toString(); + } + + /** + * Convert opcode number to char. + */ + private static char makeChar(final short opcode) { + return (char) (opcode + OFFSET); + } + + /** + * Map symbolic instruction names like "getfield" to a single character. + * + * @param pattern instruction pattern in lower case + * @return encoded string for a pattern such as "BranchInstruction". + */ + private static String mapName(final String pattern) { + final String result = map.get(pattern); + if (result != null) { + return result; + } + for (short i = 0; i < NO_OPCODES; i++) { + if (pattern.equals(Const.getOpcodeName(i))) { + return String.valueOf(makeChar(i)); + } + } + throw new IllegalArgumentException("Instruction unknown: " + pattern); + } + + private static String precompile(final short from, final short to, final short extra) { + final StringBuilder buf = new StringBuilder("("); + for (short i = from; i <= to; i++) { + buf.append(makeChar(i)); + buf.append('|'); + } + buf.append(makeChar(extra)); + buf.append(")"); + return buf.toString(); + } + + private final InstructionList il; + + private String ilString; // instruction list as string + + private InstructionHandle[] handles; // map instruction + + // list to array + + /** + * @param il instruction list to search for given patterns + */ + public InstructionFinder(final InstructionList il) { + this.il = il; + reread(); + } + + /** + * @return the inquired instruction list + */ + public final InstructionList getInstructionList() { + return il; + } + + /** + * @return the matched piece of code as an array of instruction (handles) + */ + private InstructionHandle[] getMatch(final int matchedFrom, final int matchLength) { + return Arrays.copyOfRange(handles, matchedFrom, matchedFrom + matchLength); + } + + /** + * Reread the instruction list, e.g., after you've altered the list upon a match. + */ + public final void reread() { + final int size = il.getLength(); + final char[] buf = new char[size]; // Create a string with length equal to il length + handles = il.getInstructionHandles(); + // Map opcodes to characters + for (int i = 0; i < size; i++) { + buf[i] = makeChar(handles[i].getInstruction().getOpcode()); + } + ilString = new String(buf); + } + + /** + * Start search beginning from the start of the given instruction list. + * + * @param pattern the instruction pattern to search for, where case is ignored + * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area + */ + public final Iterator search(final String pattern) { + return search(pattern, il.getStart(), null); + } + + /** + * Start search beginning from the start of the given instruction list. Check found matches with the constraint object. + * + * @param pattern the instruction pattern to search for, case is ignored + * @param constraint constraints to be checked on matching code + * @return instruction handle or 'null' if the match failed + */ + public final Iterator search(final String pattern, final CodeConstraint constraint) { + return search(pattern, il.getStart(), constraint); + } + + /** + * Start search beginning from 'from'. + * + * @param pattern the instruction pattern to search for, where case is ignored + * @param from where to start the search in the instruction list + * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area + */ + public final Iterator search(final String pattern, final InstructionHandle from) { + return search(pattern, from, null); + } + + /** + * Search for the given pattern in the instruction list. You can search for any valid opcode via its symbolic name, e.g. + * "istore". You can also use a super class or an interface name to match a whole set of instructions, e.g. + * "BranchInstruction" or "LoadInstruction". "istore" is also an alias for all "istore_x" instructions. Additional + * aliases are "if" for "ifxx", "if_icmp" for "if_icmpxx", "if_acmp" for "if_acmpxx". + *

+ * Consecutive instruction names must be separated by white space which will be removed during the compilation of the + * pattern. + *

+ * For the rest the usual pattern matching rules for regular expressions apply. + *

+ * Example pattern: + * + *

+     * search("BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*");
+     * 
+ * + *

+ * If you alter the instruction list upon a match such that other matching areas are affected, you should call reread() + * to update the finder and call search() again, because the matches are cached. + * + * @param pattern the instruction pattern to search for, where case is ignored + * @param from where to start the search in the instruction list + * @param constraint optional CodeConstraint to check the found code pattern for user-defined constraints + * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area + */ + public final Iterator search(final String pattern, final InstructionHandle from, final CodeConstraint constraint) { + final String search = compilePattern(pattern); + int start = -1; + for (int i = 0; i < handles.length; i++) { + if (handles[i] == from) { + start = i; // Where to start search from (index) + break; + } + } + if (start == -1) { + throw new ClassGenException("Instruction handle " + from + " not found in instruction list."); + } + final Pattern regex = Pattern.compile(search); + final List matches = new ArrayList<>(); + final Matcher matcher = regex.matcher(ilString); + while (start < ilString.length() && matcher.find(start)) { + final int startExpr = matcher.start(); + final int endExpr = matcher.end(); + final int lenExpr = endExpr - startExpr; + final InstructionHandle[] match = getMatch(startExpr, lenExpr); + if (constraint == null || constraint.checkCode(match)) { + matches.add(match); + } + start = endExpr; + } + return matches.iterator(); + } + + /* + * Internal debugging routines. + */ +// private static final String pattern2string( String pattern ) { +// return pattern2string(pattern, true); +// } + +// private static final String pattern2string( String pattern, boolean make_string ) { +// StringBuffer buf = new StringBuffer(); +// for (int i = 0; i < pattern.length(); i++) { +// char ch = pattern.charAt(i); +// if (ch >= OFFSET) { +// if (make_string) { +// buf.append(Constants.getOpcodeName(ch - OFFSET)); +// } else { +// buf.append((ch - OFFSET)); +// } +// } else { +// buf.append(ch); +// } +// } +// return buf.toString(); +// } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java new file mode 100644 index 0000000..a11c69a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/MethodHTML.java @@ -0,0 +1,152 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.bcel.internal.util; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +import com.sun.org.apache.bcel.internal.Const; +import com.sun.org.apache.bcel.internal.classfile.Attribute; +import com.sun.org.apache.bcel.internal.classfile.Code; +import com.sun.org.apache.bcel.internal.classfile.ExceptionTable; +import com.sun.org.apache.bcel.internal.classfile.Field; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +/** + * Convert methods and fields into HTML file. + */ +final class MethodHTML { + + private final String className; // name of current class + private final PrintWriter printWriter; // file to write to + private final ConstantHTML constantHtml; + private final AttributeHTML attributeHtml; + + MethodHTML(final String dir, final String className, final Method[] methods, final Field[] fields, final ConstantHTML constantHtml, + final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException { + this.className = className; + this.attributeHtml = attributeHtml; + this.constantHtml = constantHtml; + try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_methods.html", charset.name())) { + printWriter = newPrintWriter; + printWriter.print(""); + printWriter.println(""); + printWriter.println("" + ""); + for (final Field field : fields) { + writeField(field); + } + printWriter.println("
Access flagsTypeField name
"); + printWriter.println("" + + "" + ""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + printWriter.println("
Access flagsReturn typeMethod nameArguments
"); + } + } + + /** + * Print field of class. + * + * @param field field to print + */ + private void writeField(final Field field) { + final String type = Utility.signatureToString(field.getSignature()); + final String name = field.getName(); + String access = Utility.accessToString(field.getAccessFlags()); + Attribute[] attributes; + access = Utility.replace(access, " ", " "); + printWriter.print("" + access + "\n" + Class2HTML.referenceType(type) + "" + name + ""); + attributes = field.getAttributes(); + // Write them to the Attributes.html file with anchor "[]" + for (int i = 0; i < attributes.length; i++) { + attributeHtml.writeAttribute(attributes[i], name + "@" + i); + } + for (int i = 0; i < attributes.length; i++) { + if (attributes[i].getTag() == Const.ATTR_CONSTANT_VALUE) { // Default value + final String str = attributes[i].toString(); + // Reference attribute in _attributes.html + printWriter.print("= " + str + "\n"); + break; + } + } + printWriter.println(""); + } + + private void writeMethod(final Method method, final int methodNumber) { + // Get raw signature + final String signature = method.getSignature(); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + // Get method name + final String name = method.getName(); + String htmlName; + // Get method's access flags + String access = Utility.accessToString(method.getAccessFlags()); + // Get the method's attributes, the Code Attribute in particular + final Attribute[] attributes = method.getAttributes(); + /* + * HTML doesn't like names like and spaces are places to break lines. Both we don't want... + */ + access = Utility.replace(access, " ", " "); + htmlName = Class2HTML.toHTML(name); + printWriter.print("" + access + ""); + printWriter.print("" + Class2HTML.referenceType(type) + "" + "" + + htmlName + "\n("); + for (int i = 0; i < args.length; i++) { + printWriter.print(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + printWriter.print(", "); + } + } + printWriter.print(")"); + // Check for thrown exceptions + for (int i = 0; i < attributes.length; i++) { + attributeHtml.writeAttribute(attributes[i], "method" + methodNumber + "@" + i, methodNumber); + final byte tag = attributes[i].getTag(); + if (tag == Const.ATTR_EXCEPTIONS) { + printWriter.print("throws"); + final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable(); + for (int j = 0; j < exceptions.length; j++) { + printWriter.print(constantHtml.referenceConstant(exceptions[j])); + if (j < exceptions.length - 1) { + printWriter.print(", "); + } + } + printWriter.println(""); + } else if (tag == Const.ATTR_CODE) { + final Attribute[] attributeArray = ((Code) attributes[i]).getAttributes(); + for (int j = 0; j < attributeArray.length; j++) { + attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber); + } + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java new file mode 100644 index 0000000..2646a99 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java @@ -0,0 +1,141 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.DirectoryStream; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Wraps a Java 9 JEP 220 modular runtime image. Requires the JRT NIO file system. + * + * @since 6.3 + */ +public class ModularRuntimeImage implements Closeable { + + static final String MODULES_PATH = File.separator + "modules"; + static final String PACKAGES_PATH = File.separator + "packages"; + + private final URLClassLoader classLoader; + private final FileSystem fileSystem; + + /** + * Constructs a default instance. + */ + @SuppressWarnings("resource") // See #close() + public ModularRuntimeImage() { + this(null, FileSystems.getFileSystem(URI.create("jrt:/"))); + } + + /** + * Constructs an instance using the JRT file system implementation from a specific Java Home. + * + * @param javaHome Path to a Java 9 or greater home. + * @throws IOException an I/O error occurs accessing the file system + */ + public ModularRuntimeImage(final String javaHome) throws IOException { + final Map emptyMap = Collections.emptyMap(); + final Path jrePath = Paths.get(javaHome); + final Path jrtFsPath = jrePath.resolve("lib").resolve("jrt-fs.jar"); + this.classLoader = URLClassLoader.newInstance(new URL[]{jrtFsPath.toUri().toURL()}); + this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader); + } + + private ModularRuntimeImage(final URLClassLoader cl, final FileSystem fs) { + this.classLoader = cl; + this.fileSystem = fs; + } + + @Override + public void close() throws IOException { + if (classLoader != null) { + classLoader.close(); + } + if (fileSystem != null) { + fileSystem.close(); + } + } + + public FileSystem getFileSystem() { + return fileSystem; + } + + /** + * Lists all entries in the given directory. + * + * @param dirPath directory path. + * @return a list of dir entries if an I/O error occurs + * @throws IOException an I/O error occurs accessing the file system + */ + public List list(final Path dirPath) throws IOException { + final List list = new ArrayList<>(); + try (DirectoryStream ds = Files.newDirectoryStream(dirPath)) { + ds.forEach(list::add); + } + return list; + } + + /** + * Lists all entries in the given directory. + * + * @param dirName directory path. + * @return a list of dir entries if an I/O error occurs + * @throws IOException an I/O error occurs accessing the file system + */ + public List list(final String dirName) throws IOException { + return list(fileSystem.getPath(dirName)); + } + + /** + * Lists all modules. + * + * @return a list of modules + * @throws IOException an I/O error occurs accessing the file system + */ + public List modules() throws IOException { + return list(MODULES_PATH); + } + + /** + * Lists all packages. + * + * @return a list of modules + * @throws IOException an I/O error occurs accessing the file system + */ + public List packages() throws IOException { + return list(PACKAGES_PATH); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java new file mode 100644 index 0000000..ef6f934 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/Repository.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import com.sun.org.apache.bcel.internal.classfile.JavaClass; + +/** + * Abstract definition of a class repository. Instances may be used to load classes from different sources and may be + * used in the Repository.setRepository method. + * + * @LastModified: Feb 2023 + * @see org.apache.bcel.Repository + */ +public interface Repository { + + /** + * Clears all entries from cache. + */ + void clear(); + + /** + * Finds the class with the name provided, if the class isn't there, return NULL. + */ + JavaClass findClass(String className); + + /** + * Finds the JavaClass instance for the given run-time class object. + * + * @throws ClassNotFoundException if the class can't be found. + */ + JavaClass loadClass(Class clazz) throws ClassNotFoundException; + + /** + * Finds the class with the name provided, if the class isn't there, make an attempt to load it. + * + * @throws ClassNotFoundException if the class can't be found. + */ + JavaClass loadClass(String className) throws ClassNotFoundException; + + /** + * Removes class from repository + */ + void removeClass(JavaClass clazz); + + /** + * Stores the provided class under "clazz.getClassName()" + */ + void storeClass(JavaClass clazz); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java new file mode 100644 index 0000000..c40f70c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sun.org.apache.bcel.internal.util; + +import java.io.IOException; +import java.io.InputStream; + +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Utility; + +import java.lang.ref.SoftReference; +import java.util.HashMap; +import java.util.Map; + +/** + * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded + * from the file systems using the paths specified in the given class path. By default, this is the value returned by + * ClassPath.getClassPath(). + *

+ * This repository uses a factory design, allowing it to maintain a collection of different classpaths, and as such It + * is designed to be used as a singleton per classpath. + *

+ * + * @LastModified: Feb 2023 + * @see com.sun.org.apache.bcel.internal.Repository + */ +public class SyntheticRepository implements Repository { + + // CLASSNAME X JAVACLASS + private final Map> loadedClasses = new HashMap<>(); + + private SyntheticRepository() { + } + + public static SyntheticRepository getInstance() { + return new SyntheticRepository(); + } + + /** + * Clear all entries from cache. + */ + @Override + public void clear() { + loadedClasses.clear(); + } + + /** + * Find an already defined (cached) JavaClass object by name. + */ + @Override + public JavaClass findClass(final String className) { + final SoftReference ref = loadedClasses.get(className); + return ref == null ? null : ref.get(); + } + + /** + * Remove class from repository + */ + @Override + public void removeClass(final JavaClass clazz) { + loadedClasses.remove(clazz.getClassName()); + } + + /** + * Store a new JavaClass instance into this Repository. + */ + @Override + public void storeClass(final JavaClass clazz) { + // Not calling super.storeClass because this subclass maintains the mapping. + loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); + clazz.setRepository(this); + } + + /** + * Finds the JavaClass object for a runtime Class object. If a class with the same name is already in this Repository, + * the Repository version is returned. Otherwise, getResourceAsStream() is called on the Class object to find the + * class's representation. If the representation is found, it is added to the Repository. + * + * @param clazz the runtime Class object + * @return JavaClass object for given runtime class + * @throws ClassNotFoundException if the class is not in the Repository, and its representation could not be found + * @see Class + */ + @Override + public JavaClass loadClass(final Class clazz) throws ClassNotFoundException { + final String className = clazz.getName(); + final JavaClass repositoryClass = findClass(className); + if (repositoryClass != null) { + return repositoryClass; + } + String name = className; + final int i = name.lastIndexOf('.'); + if (i > 0) { + name = name.substring(i + 1); + } + + try (InputStream clsStream = clazz.getResourceAsStream(name + JavaClass.EXTENSION)) { + return loadClass(clsStream, className); + } catch (final IOException e) { + return null; + } + } + + private JavaClass loadClass(final InputStream inputStream, final String className) throws ClassNotFoundException { + try { + if (inputStream != null) { + final ClassParser parser = new ClassParser(inputStream, className); + final JavaClass clazz = parser.parse(); + storeClass(clazz); + return clazz; + } + } catch (final IOException e) { + throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e); + } + throw new ClassNotFoundException("ClassRepository could not load " + className); + } + + /** + * Finds a JavaClass object by name. If it is already in this Repository, the Repository version is returned. Otherwise, + * the Repository's classpath is searched for the class (and it is added to the Repository if found). + * + * @param className the name of the class + * @return the JavaClass object + * @throws ClassNotFoundException if the class is not in the Repository, and could not be found on the classpath + */ + @Override + public JavaClass loadClass(String className) throws ClassNotFoundException { + if (className == null || className.isEmpty()) { + throw new IllegalArgumentException("Invalid class name " + className); + } + className = Utility.pathToPackage(className); // Just in case, canonical form + final JavaClass clazz = findClass(className); + if (clazz != null) { + return clazz; + } + IOException e = new IOException("Couldn't find: " + className + ".class"); + throw new ClassNotFoundException("Exception while looking for class " + + className + ": " + e, e); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html new file mode 100644 index 0000000..07ebe58 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/bcel/internal/util/package.html @@ -0,0 +1,41 @@ + + + + + + + +

+ This package contains utility classes for the + Byte Code Engineering + Library, namely: +

+

+

    +
  • Collection classes for JavaClass objects
  • +
  • A converter for class files to HTML
  • +
  • A tool to find instructions patterns via regular expressions
  • +
  • A class to find classes as defined in the CLASSPATH
  • +
  • A class loader that allows to create classes at run time
  • +
+ +

+ + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java new file mode 100644 index 0000000..d3633eb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/ExpressionContext.java @@ -0,0 +1,97 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.extensions; + +import javax.xml.transform.ErrorListener; + +import com.sun.org.apache.xpath.internal.objects.XObject; + +import org.w3c.dom.Node; +import org.w3c.dom.traversal.NodeIterator; + +/** + * An object that implements this interface can supply + * information about the current XPath expression context. + */ +public interface ExpressionContext { + + /** + * Get the current context node. + * + * @return The current context node. + */ + public Node getContextNode(); + + /** + * Get the current context node list. + * + * @return An iterator for the current context list, as + * defined in XSLT. + */ + public NodeIterator getContextNodes(); + + /** + * Get the error listener. + * + * @return The registered error listener. + */ + public ErrorListener getErrorListener(); + + /** + * Get the value of a node as a number. + * + * @param n Node to be converted to a number. May be null. + * @return value of n as a number. + */ + public double toNumber(Node n); + + /** + * Get the value of a node as a string. + * + * @param n Node to be converted to a string. May be null. + * @return value of n as a string, or an empty string if n is null. + */ + public String toString(Node n); + + /** + * Get a variable based on it's qualified name. + * + * @param qname The qualified name of the variable. + * @return The evaluated value of the variable. + * @throws javax.xml.transform.TransformerException + */ + public XObject getVariableOrParam(com.sun.org.apache.xml.internal.utils.QName qname) + throws javax.xml.transform.TransformerException; + + /** + * Get the XPathContext that owns this ExpressionContext. + *

+ * Note: exslt:function requires the XPathContext to access + * the variable stack and TransformerImpl. + * + * @return The current XPathContext. + * @throws javax.xml.transform.TransformerException + */ + public com.sun.org.apache.xpath.internal.XPathContext getXPathContext() + throws javax.xml.transform.TransformerException; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html new file mode 100644 index 0000000..977ca53 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/extensions/package.html @@ -0,0 +1,29 @@ + + + + +Xalan Extension Mechanism Package. + +

Implementation of Xalan Extension Mechanism. +

+ + + + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java new file mode 100644 index 0000000..cf03a21 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltBase.java @@ -0,0 +1,75 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * The base class for some EXSLT extension classes. + * It contains common utility methods to be used by the sub-classes. + */ +public abstract class ExsltBase { + /** + * Return the string value of a Node + * + * @param n The Node. + * @return The string value of the Node + */ + protected static String toString(Node n) { + if (n instanceof DTMNodeProxy) + return ((DTMNodeProxy) n).getStringValue(); + else { + String value = n.getNodeValue(); + if (value == null) { + NodeList nodelist = n.getChildNodes(); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < nodelist.getLength(); i++) { + Node childNode = nodelist.item(i); + buf.append(toString(childNode)); + } + return buf.toString(); + } else + return value; + } + } + + /** + * Convert the string value of a Node to a number. + * Return NaN if the string is not a valid number. + * + * @param n The Node. + * @return The number value of the Node + */ + protected static double toNumber(Node n) { + double d = 0.0; + String str = toString(n); + try { + d = Double.valueOf(str).doubleValue(); + } catch (NumberFormatException e) { + d = Double.NaN; + } + return d; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java new file mode 100644 index 0000000..2c13575 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltCommon.java @@ -0,0 +1,99 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xml.internal.dtm.DTMIterator; +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeIterator; +import com.sun.org.apache.xpath.internal.NodeSet; + +/** + * This class contains EXSLT common extension functions. + * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:exslt="http://exslt.org/common"
+ * 
+ *

+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @see EXSLT + */ +public class ExsltCommon { + /** + * The exsl:object-type function returns a string giving the type of the object passed + * as the argument. The possible object types are: 'string', 'number', 'boolean', + * 'node-set', 'RTF', or 'external'. + *

+ * Most XSLT object types can be coerced to each other without error. However, there are + * certain coercions that raise errors, most importantly treating anything other than a + * node set as a node set. Authors of utilities such as named templates or user-defined + * extension functions may wish to give some flexibility in the parameter and argument values + * that are accepted by the utility; the exsl:object-type function enables them to do so. + *

+ * The Xalan extensions MethodResolver converts 'object-type' to 'objectType'. + * + * @param obj The object to be typed. + * @return objectType 'string', 'number', 'boolean', 'node-set', 'RTF', or 'external'. + * @see EXSLT + */ + public static String objectType(Object obj) { + if (obj instanceof String) + return "string"; + else if (obj instanceof Boolean) + return "boolean"; + else if (obj instanceof Number) + return "number"; + else if (obj instanceof DTMNodeIterator) { + DTMIterator dtmI = ((DTMNodeIterator) obj).getDTMIterator(); + if (dtmI instanceof com.sun.org.apache.xpath.internal.axes.RTFIterator) + return "RTF"; + else + return "node-set"; + } else + return "unknown"; + } + + /** + * The exsl:node-set function converts a result tree fragment (which is what you get + * when you use the content of xsl:variable rather than its select attribute to give + * a variable value) into a node set. This enables you to process the XML that you create + * within a variable, and therefore do multi-step processing. + *

+ * You can also use this function to turn a string into a text node, which is helpful + * if you want to pass a string to a function that only accepts a node set. + *

+ * The Xalan extensions MethodResolver converts 'node-set' to 'nodeSet'. + * + * @param myProcessor is passed in by the Xalan extension processor + * @param rtf The result tree fragment to be converted to a node-set. + * @return node-set with the contents of the result tree fragment. + *

+ * Note: Already implemented in the xalan namespace as nodeset. + * @see EXSLT + */ + public static NodeSet nodeSet(ExpressionContext myProcessor, Object rtf) { + return Extensions.nodeset(myProcessor, rtf); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java new file mode 100644 index 0000000..c8cc5d8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java @@ -0,0 +1,1032 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; + +/** + * This class contains EXSLT dates and times extension functions. + * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:datetime="http://exslt.org/dates-and-times"
+ * 
+ *

+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @LastModified: Nov 2017 + * @see EXSLT + */ + +public class ExsltDatetime { + // Datetime formats (era and zone handled separately). + static final String dt = "yyyy-MM-dd'T'HH:mm:ss"; + static final String d = "yyyy-MM-dd"; + static final String gym = "yyyy-MM"; + static final String gy = "yyyy"; + static final String gmd = "--MM-dd"; + static final String gm = "--MM--"; + static final String gd = "---dd"; + static final String t = "HH:mm:ss"; + static final String EMPTY_STR = ""; + + /** + * The date:date-time function returns the current date and time as a date/time string. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date/time string format must include a time zone, either a Z to indicate Coordinated + * Universal Time or a + or - followed by the difference between the difference from UTC + * represented as hh:mm. + */ + public static String dateTime() { + Calendar cal = Calendar.getInstance(); + Date datetime = cal.getTime(); + // Format for date and time. + SimpleDateFormat dateFormat = new SimpleDateFormat(dt); + + StringBuffer buff = new StringBuffer(dateFormat.format(datetime)); + // Must also include offset from UTF. + // Get the offset (in milliseconds). + int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); + // If there is no offset, we have "Coordinated + // Universal Time." + if (offset == 0) + buff.append("Z"); + else { + // Convert milliseconds to hours and minutes + int hrs = offset / (60 * 60 * 1000); + // In a few cases, the time zone may be +/-hh:30. + int min = offset % (60 * 60 * 1000); + char posneg = hrs < 0 ? '-' : '+'; + buff.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min)); + } + return buff.toString(); + } + + /** + * Represent the hours and minutes with two-digit strings. + * + * @param q hrs or minutes. + * @return two-digit String representation of hrs or minutes. + */ + private static String formatDigits(int q) { + String dd = String.valueOf(Math.abs(q)); + return dd.length() == 1 ? '0' + dd : dd; + } + + /** + * The date:date function returns the date specified in the date/time string given + * as the argument. If no argument is given, then the current local date/time, as + * returned by date:date-time is used as a default argument. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * If the argument is not in either of these formats, date:date returns an empty string (''). + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date is returned as a string with a lexical representation as defined for xs:date in + * [3.2.9 date] of [XML Schema Part 2: Datatypes]. The date format is basically CCYY-MM-DD, + * although implementers should consult [XML Schema Part 2: Datatypes] and [ISO 8601] for details. + * If no argument is given or the argument date/time specifies a time zone, then the date string + * format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - + * followed by the difference between the difference from UTC represented as hh:mm. If an argument + * is specified and it does not specify a time zone, then the date string format must not include + * a time zone. + */ + public static String date(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String leader = edz[0]; + String datetime = edz[1]; + String zone = edz[2]; + if (datetime == null || zone == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = d; + Date date = testFormats(datetime, formatsIn); + if (date == null) return EMPTY_STR; + + SimpleDateFormat dateFormat = new SimpleDateFormat(formatOut); + dateFormat.setLenient(false); + String dateOut = dateFormat.format(date); + if (dateOut.length() == 0) + return EMPTY_STR; + else + return (leader + dateOut + zone); + } + + + /** + * See above. + */ + public static String date() { + String datetime = dateTime().toString(); + String date = datetime.substring(0, datetime.indexOf("T")); + String zone = datetime.substring(getZoneStart(datetime)); + return (date + zone); + } + + /** + * The date:time function returns the time specified in the date/time string given + * as the argument. If no argument is given, then the current local date/time, as + * returned by date:date-time is used as a default argument. + * The date/time string that's returned must be a string in the format defined as the + * lexical representation of xs:dateTime in + * [3.2.7 dateTime] of + * [XML Schema Part 2: Datatypes]. + * If the argument string is not in this format, date:time returns an empty string (''). + * The date/time format is basically CCYY-MM-DDThh:mm:ss, although implementers should consult + * [XML Schema Part 2: Datatypes] and + * [ISO 8601] for details. + * The date is returned as a string with a lexical representation as defined for xs:time in + * [3.2.8 time] of [XML Schema Part 2: Datatypes]. + * The time format is basically hh:mm:ss, although implementers should consult [XML Schema Part 2: + * Datatypes] and [ISO 8601] for details. + * If no argument is given or the argument date/time specifies a time zone, then the time string + * format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - + * followed by the difference between the difference from UTC represented as hh:mm. If an argument + * is specified and it does not specify a time zone, then the time string format must not include + * a time zone. + */ + public static String time(String timeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(timeIn); + String time = edz[1]; + String zone = edz[2]; + if (time == null || zone == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, t}; + String formatOut = t; + Date date = testFormats(time, formatsIn); + if (date == null) return EMPTY_STR; + SimpleDateFormat dateFormat = new SimpleDateFormat(formatOut); + String out = dateFormat.format(date); + return (out + zone); + } + + /** + * See above. + */ + public static String time() { + String datetime = dateTime().toString(); + String time = datetime.substring(datetime.indexOf("T") + 1); + + // The datetime() function returns the zone on the datetime string. If we + // append it, we get the zone substring duplicated. + // Fix for JIRA 2013 + + // String zone = datetime.substring(getZoneStart(datetime)); + // return (time + zone); + return (time); + } + + /** + * The date:year function returns the year of a date as a number. If no + * argument is given, then the current local date/time, as returned by + * date:date-time is used as a default argument. + * The date/time string specified as the first argument must be a right-truncated + * string in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gYear (CCYY) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double year(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + boolean ad = edz[0].length() == 0; // AD (Common Era -- empty leader) + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d, gym, gy}; + double yr = getNumber(datetime, formats, Calendar.YEAR); + if (ad || yr == Double.NaN) + return yr; + else + return -yr; + } + + /** + * See above. + */ + public static double year() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.YEAR); + } + + /** + * The date:month-in-year function returns the month of a date as a number. If no argument + * is given, then the current local date/time, as returned by date:date-time is used + * as a default argument. + * The date/time string specified as the first argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in one of + * the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * xs:gMonthDay (--MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double monthInYear(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d, gym, gm, gmd}; + return getNumber(datetime, formats, Calendar.MONTH) + 1; + } + + /** + * See above. + */ + public static double monthInYear() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.MONTH) + 1; + } + + /** + * The date:week-in-year function returns the week of the year as a number. If no argument + * is given, then the current local date/time, as returned by date:date-time is used as the + * default argument. For the purposes of numbering, counting follows ISO 8601: week 1 in a year + * is the week containing the first Thursday of the year, with new weeks beginning on a Monday. + * The date/time string specified as the argument is a right-truncated string in the format + * defined as the lexical representation of xs:dateTime in one of the formats defined in + * [XML Schema Part 2: Datatypes]. The + * permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double weekInYear(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.WEEK_OF_YEAR); + } + + /** + * See above. + */ + public static double weekInYear() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.WEEK_OF_YEAR); + } + + /** + * The date:day-in-year function returns the day of a date in a year + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayInYear(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_YEAR); + } + + /** + * See above. + */ + public static double dayInYear() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_YEAR); + } + + + /** + * The date:day-in-month function returns the day of a date as a number. + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gMonthDay (--MM-DD) + * xs:gDay (---DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayInMonth(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + String[] formats = {dt, d, gmd, gd}; + double day = getNumber(datetime, formats, Calendar.DAY_OF_MONTH); + return day; + } + + /** + * See above. + */ + public static double dayInMonth() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_MONTH); + } + + /** + * The date:day-of-week-in-month function returns the day-of-the-week + * in a month of a date as a number (e.g. 3 for the 3rd Tuesday in May). + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated string + * in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double dayOfWeekInMonth(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_WEEK_IN_MONTH); + } + + /** + * See above. + */ + public static double dayOfWeekInMonth() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_WEEK_IN_MONTH); + } + + + /** + * The date:day-in-week function returns the day of the week given in a + * date as a number. If no argument is given, then the current local date/time, + * as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated string + * in the format defined as the lexical representation of xs:dateTime in one + * of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then NaN is returned. + * The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday. + */ + public static double dayInWeek(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, d}; + return getNumber(datetime, formats, Calendar.DAY_OF_WEEK); + } + + /** + * See above. + */ + public static double dayInWeek() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_WEEK); + } + + /** + * The date:hour-in-day function returns the hour of the day as a number. + * If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double hourInDay(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, t}; + return getNumber(datetime, formats, Calendar.HOUR_OF_DAY); + } + + /** + * See above. + */ + public static double hourInDay() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.HOUR_OF_DAY); + } + + /** + * The date:minute-in-hour function returns the minute of the hour + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double minuteInHour(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, t}; + return getNumber(datetime, formats, Calendar.MINUTE); + } + + /** + * See above. + */ + public static double minuteInHour() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.MINUTE); + } + + /** + * The date:second-in-minute function returns the second of the minute + * as a number. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:time (hh:mm:ss) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static double secondInMinute(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return Double.NaN; + + String[] formats = {dt, t}; + return getNumber(datetime, formats, Calendar.SECOND); + } + + /** + * See above. + */ + public static double secondInMinute() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.SECOND); + } + + /** + * The date:leap-year function returns true if the year given in a date + * is a leap year. If no argument is given, then the current local + * date/time, as returned by date:date-time is used as a default argument. + * The date/time string specified as the first argument must be a + * right-truncated string in the format defined as the lexical representation + * of xs:dateTime in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gYear (CCYY) + * If the date/time string is not in one of these formats, then NaN is returned. + */ + public static XObject leapYear(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return new XNumber(Double.NaN); + + String[] formats = {dt, d, gym, gy}; + double dbl = getNumber(datetime, formats, Calendar.YEAR); + if (dbl == Double.NaN) + return new XNumber(Double.NaN); + int yr = (int) dbl; + return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0)); + } + + /** + * See above. + */ + public static boolean leapYear() { + Calendar cal = Calendar.getInstance(); + int yr = cal.get(Calendar.YEAR); + return (yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0)); + } + + /** + * The date:month-name function returns the full name of the month of a date. + * If no argument is given, then the current local date/time, as returned by + * date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in + * one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * If the date/time string is not in one of these formats, then an empty string ('') + * is returned. + * The result is an English month name: one of 'January', 'February', 'March', + * 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November' + * or 'December'. + */ + public static String monthName(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, gym, gm}; + String formatOut = "MMMM"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String monthName() { + Calendar cal = Calendar.getInstance(); + String format = "MMMM"; + return getNameOrAbbrev(format); + } + + /** + * The date:month-abbreviation function returns the abbreviation of the month of + * a date. If no argument is given, then the current local date/time, as returned + * by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime in + * one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * xs:gYearMonth (CCYY-MM) + * xs:gMonth (--MM--) + * If the date/time string is not in one of these formats, then an empty string ('') + * is returned. + * The result is a three-letter English month abbreviation: one of 'Jan', 'Feb', 'Mar', + * 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov' or 'Dec'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String monthAbbreviation(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d, gym, gm}; + String formatOut = "MMM"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String monthAbbreviation() { + String format = "MMM"; + return getNameOrAbbrev(format); + } + + /** + * The date:day-name function returns the full name of the day of the week + * of a date. If no argument is given, then the current local date/time, + * as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then the empty string ('') + * is returned. + * The result is an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', + * 'Thursday' or 'Friday'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String dayName(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = "EEEE"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String dayName() { + String format = "EEEE"; + return getNameOrAbbrev(format); + } + + /** + * The date:day-abbreviation function returns the abbreviation of the day + * of the week of a date. If no argument is given, then the current local + * date/time, as returned by date:date-time is used the default argument. + * The date/time string specified as the argument is a left or right-truncated + * string in the format defined as the lexical representation of xs:dateTime + * in one of the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + * xs:dateTime (CCYY-MM-DDThh:mm:ss) + * xs:date (CCYY-MM-DD) + * If the date/time string is not in one of these formats, then the empty string + * ('') is returned. + * The result is a three-letter English day abbreviation: one of 'Sun', 'Mon', 'Tue', + * 'Wed', 'Thu' or 'Fri'. + * An implementation of this extension function in the EXSLT date namespace must conform + * to the behaviour described in this document. + */ + public static String dayAbbreviation(String datetimeIn) + throws ParseException { + String[] edz = getEraDatetimeZone(datetimeIn); + String datetime = edz[1]; + if (datetime == null) + return EMPTY_STR; + + String[] formatsIn = {dt, d}; + String formatOut = "EEE"; + return getNameOrAbbrev(datetimeIn, formatsIn, formatOut); + } + + /** + * See above. + */ + public static String dayAbbreviation() { + String format = "EEE"; + return getNameOrAbbrev(format); + } + + /** + * Returns an array with the 3 components that a datetime input string + * may contain: - (for BC era), datetime, and zone. If the zone is not + * valid, return null for that component. + */ + private static String[] getEraDatetimeZone(String in) { + String leader = ""; + String datetime = in; + String zone = ""; + if (in.charAt(0) == '-' && !in.startsWith("--")) { + leader = "-"; // '+' is implicit , not allowed + datetime = in.substring(1); + } + int z = getZoneStart(datetime); + if (z > 0) { + zone = datetime.substring(z); + datetime = datetime.substring(0, z); + } else if (z == -2) + zone = null; + //System.out.println("'" + leader + "' " + datetime + " " + zone); + return new String[]{leader, datetime, zone}; + } + + /** + * Get the start of zone information if the input ends + * with 'Z' or +/-hh:mm. If a zone string is not + * found, return -1; if the zone string is invalid, + * return -2. + */ + private static int getZoneStart(String datetime) { + if (datetime.indexOf("Z") == datetime.length() - 1) + return datetime.length() - 1; + else if (datetime.length() >= 6 + && datetime.charAt(datetime.length() - 3) == ':' + && (datetime.charAt(datetime.length() - 6) == '+' + || datetime.charAt(datetime.length() - 6) == '-')) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm"); + dateFormat.setLenient(false); + Date d = dateFormat.parse(datetime.substring(datetime.length() - 5)); + return datetime.length() - 6; + } catch (ParseException pe) { + System.out.println("ParseException " + pe.getErrorOffset()); + return -2; // Invalid. + } + + } + return -1; // No zone information. + } + + /** + * Attempt to parse an input string with the allowed formats, returning + * null if none of the formats work. + */ + private static Date testFormats(String in, String[] formats) + throws ParseException { + for (int i = 0; i < formats.length; i++) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat(formats[i]); + dateFormat.setLenient(false); + return dateFormat.parse(in); + } catch (ParseException pe) { + } + } + return null; + } + + + /** + * Parse the input string and return the corresponding calendar field + * number. + */ + private static double getNumber(String in, String[] formats, int calField) + throws ParseException { + Calendar cal = Calendar.getInstance(); + cal.setLenient(false); + // Try the allowed formats, from longest to shortest. + Date date = testFormats(in, formats); + if (date == null) return Double.NaN; + cal.setTime(date); + return cal.get(calField); + } + + /** + * Get the full name or abbreviation of the month or day. + */ + private static String getNameOrAbbrev(String in, + String[] formatsIn, + String formatOut) + throws ParseException { + for (int i = 0; i < formatsIn.length; i++) // from longest to shortest. + { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat(formatsIn[i], Locale.ENGLISH); + dateFormat.setLenient(false); + Date dt = dateFormat.parse(in); + dateFormat.applyPattern(formatOut); + return dateFormat.format(dt); + } catch (ParseException pe) { + } + } + return ""; + } + + /** + * Get the full name or abbreviation for the current month or day + * (no input string). + */ + private static String getNameOrAbbrev(String format) { + Calendar cal = Calendar.getInstance(); + SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH); + return dateFormat.format(cal.getTime()); + } + + /** + * The date:format-date function formats a date/time according to a pattern. + *

+ * The first argument to date:format-date specifies the date/time to be + * formatted. It must be right or left-truncated date/time strings in one of + * the formats defined in + * [XML Schema Part 2: Datatypes]. + * The permitted formats are as follows: + *

    + *
  • xs:dateTime (CCYY-MM-DDThh:mm:ss) + *
  • xs:date (CCYY-MM-DD) + *
  • xs:time (hh:mm:ss) + *
  • xs:gYearMonth (CCYY-MM) + *
  • xs:gYear (CCYY) + *
  • xs:gMonthDay (--MM-DD) + *
  • xs:gMonth (--MM--) + *
  • xs:gDay (---DD) + *
+ * The second argument is a string that gives the format pattern used to + * format the date. The format pattern must be in the syntax specified by + * the JDK 1.1 SimpleDateFormat class. The format pattern string is + * interpreted as described for the JDK 1.1 SimpleDateFormat class. + *

+ * If the date/time format is right-truncated (i.e. in a format other than + * xs:time, or xs:dateTime) then any missing components are assumed to be as + * follows: if no month is specified, it is given a month of 01; if no day + * is specified, it is given a day of 01; if no time is specified, it is + * given a time of 00:00:00. + *

+ * If the date/time format is left-truncated (i.e. xs:time, xs:gMonthDay, + * xs:gMonth or xs:gDay) and the format pattern has a token that uses a + * component that is missing from the date/time format used, then that token + * is replaced with an empty string ('') within the result. + *

+ * The author is Helg Bredow (helg.bredow@kalido.com) + */ + public static String formatDate(String dateTime, String pattern) { + final String yearSymbols = "Gy"; + final String monthSymbols = "M"; + final String daySymbols = "dDEFwW"; + TimeZone timeZone; + String zone; + + // Get the timezone information if it was supplied and modify the + // dateTime so that SimpleDateFormat will understand it. + if (dateTime.endsWith("Z") || dateTime.endsWith("z")) { + timeZone = TimeZone.getTimeZone("GMT"); + dateTime = dateTime.substring(0, dateTime.length() - 1) + "GMT"; + zone = "z"; + } else if ((dateTime.length() >= 6) + && (dateTime.charAt(dateTime.length() - 3) == ':') + && ((dateTime.charAt(dateTime.length() - 6) == '+') + || (dateTime.charAt(dateTime.length() - 6) == '-'))) { + String offset = dateTime.substring(dateTime.length() - 6); + + if ("+00:00".equals(offset) || "-00:00".equals(offset)) { + timeZone = TimeZone.getTimeZone("GMT"); + } else { + timeZone = TimeZone.getTimeZone("GMT" + offset); + } + zone = "z"; + // Need to adjust it since SimpleDateFormat requires GMT+hh:mm but + // we have +hh:mm. + dateTime = dateTime.substring(0, dateTime.length() - 6) + "GMT" + offset; + } else { + // Assume local time. + timeZone = TimeZone.getDefault(); + zone = ""; + // Leave off the timezone since SimpleDateFormat will assume local + // time if time zone is not included. + } + String[] formats = {dt + zone, d, gym, gy}; + + // Try the time format first. We need to do this to prevent + // SimpleDateFormat from interpreting a time as a year. i.e we just need + // to check if it's a time before we check it's a year. + try { + SimpleDateFormat inFormat = new SimpleDateFormat(t + zone); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip + (yearSymbols + monthSymbols + daySymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } catch (ParseException pe) { + } + + // Try the right truncated formats. + for (int i = 0; i < formats.length; i++) { + try { + SimpleDateFormat inFormat = new SimpleDateFormat(formats[i]); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(pattern); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } catch (ParseException pe) { + } + } + + // Now try the left truncated ones. The Java format() function doesn't + // return the correct strings in this case. We strip any pattern + // symbols that shouldn't be output so that they are not defaulted to + // inappropriate values in the output. + try { + SimpleDateFormat inFormat = new SimpleDateFormat(gmd); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } catch (ParseException pe) { + } + try { + SimpleDateFormat inFormat = new SimpleDateFormat(gm); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } catch (ParseException pe) { + } + try { + SimpleDateFormat inFormat = new SimpleDateFormat(gd); + inFormat.setLenient(false); + Date d = inFormat.parse(dateTime); + SimpleDateFormat outFormat = new SimpleDateFormat(strip(yearSymbols + monthSymbols, pattern)); + outFormat.setTimeZone(timeZone); + return outFormat.format(d); + } catch (ParseException pe) { + } + return EMPTY_STR; + } + + /** + * Strips occurrences of the given character from a date format pattern. + * + * @param symbols list of symbols to strip. + * @param pattern + * @return + */ + private static String strip(String symbols, String pattern) { + int quoteSemaphore = 0; + int i = 0; + StringBuffer result = new StringBuffer(pattern.length()); + + while (i < pattern.length()) { + char ch = pattern.charAt(i); + if (ch == '\'') { + // Assume it's an openening quote so simply copy the quoted + // text to the result. There is nothing to strip here. + int endQuote = pattern.indexOf('\'', i + 1); + if (endQuote == -1) { + endQuote = pattern.length(); + } + result.append(pattern.substring(i, endQuote)); + i = endQuote++; + } else if (symbols.indexOf(ch) > -1) { + // The char needs to be stripped. + i++; + } else { + result.append(ch); + i++; + } + } + return result.toString(); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java new file mode 100644 index 0000000..c92dbbf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltDynamic.java @@ -0,0 +1,563 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.TransformerException; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xalan.internal.res.XSLMessages; +import com.sun.org.apache.xalan.internal.res.XSLTErrorResources; +import com.sun.org.apache.xpath.internal.NodeSet; +import com.sun.org.apache.xpath.internal.NodeSetDTM; +import com.sun.org.apache.xpath.internal.XPath; +import com.sun.org.apache.xpath.internal.XPathContext; +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNodeSet; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; + +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import org.xml.sax.SAXNotSupportedException; + +/** + * This class contains EXSLT dynamic extension functions. + *

+ * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:dyn="http://exslt.org/dynamic"
+ * 
+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @see EXSLT + */ +public class ExsltDynamic extends ExsltBase { + + public static final String EXSL_URI = "http://exslt.org/common"; + + /** + * The dyn:max function calculates the maximum value for the nodes passed as + * the first argument, where the value of each node is calculated dynamically + * using an XPath expression passed as a string as the second argument. + *

+ * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:max function itself, except for the following: + *

+ *

    + *
  • the context node is the node whose value is being calculated.
  • + *
  • the context position is the position of the node within the node set passed as + * the first argument to the dyn:max function, arranged in document order.
  • + *
  • the context size is the number of nodes passed as the first argument to the + * dyn:max function.
  • + *
+ *

+ * The dyn:max function returns the maximum of these values, calculated in exactly + * the same way as for math:max. + *

+ * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns NaN. + *

+ * This function must take a second argument. To calculate the maximum of a set of + * nodes based on their string values, you should use the math:max function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * @return The maximum evaluation value + */ + public static double max(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException { + + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double maxValue = -Double.MAX_VALUE; + for (int i = 0; i < contextNodes.getLength(); i++) { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } catch (TransformerException e) { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + if (result > maxValue) + maxValue = result; + } + + xctxt.popContextNodeList(); + return maxValue; + + } + + /** + * The dyn:min function calculates the minimum value for the nodes passed as the + * first argument, where the value of each node is calculated dynamically using + * an XPath expression passed as a string as the second argument. + *

+ * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:min function itself, except for the following: + *

+ *

    + *
  • the context node is the node whose value is being calculated.
  • + *
  • the context position is the position of the node within the node set passed + * as the first argument to the dyn:min function, arranged in document order.
  • + *
  • the context size is the number of nodes passed as the first argument to the + * dyn:min function.
  • + *
+ *

+ * The dyn:min function returns the minimum of these values, calculated in exactly + * the same way as for math:min. + *

+ * If the expression string passed as the second argument is an invalid XPath expression + * (including an empty string), this function returns NaN. + *

+ * This function must take a second argument. To calculate the minimum of a set of + * nodes based on their string values, you should use the math:min function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * @return The minimum evaluation value + */ + public static double min(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException { + + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double minValue = Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } catch (TransformerException e) { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + if (result < minValue) + minValue = result; + } + + xctxt.popContextNodeList(); + return minValue; + + } + + /** + * The dyn:sum function calculates the sum for the nodes passed as the first argument, + * where the value of each node is calculated dynamically using an XPath expression + * passed as a string as the second argument. + *

+ * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:sum function itself, except for the following: + *

+ *

    + *
  • the context node is the node whose value is being calculated.
  • + *
  • the context position is the position of the node within the node set passed as + * the first argument to the dyn:sum function, arranged in document order.
  • + *
  • the context size is the number of nodes passed as the first argument to the + * dyn:sum function.
  • + *
+ *

+ * The dyn:sum function returns the sumimum of these values, calculated in exactly + * the same way as for sum. + *

+ * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns NaN. + *

+ * This function must take a second argument. To calculate the sumimum of a set of + * nodes based on their string values, you should use the sum function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * @return The sum of the evaluation value on each node + */ + public static double sum(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException { + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); + + if (expr == null || expr.length() == 0) + return Double.NaN; + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + double sum = 0; + for (int i = 0; i < nl.getLength(); i++) { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + double result = 0; + try { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num(); + } catch (TransformerException e) { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return Double.NaN; + } + + xctxt.popCurrentNode(); + + sum = sum + result; + + } + + xctxt.popContextNodeList(); + return sum; + } + + /** + * The dyn:map function evaluates the expression passed as the second argument for + * each of the nodes passed as the first argument, and returns a node set of those values. + *

+ * The expressions are evaluated relative to the nodes passed as the first argument. + * In other words, the value for each node is calculated by evaluating the XPath + * expression with all context information being the same as that for the call to + * the dyn:map function itself, except for the following: + *

+ *

    + *
  • The context node is the node whose value is being calculated.
  • + *
  • the context position is the position of the node within the node set passed + * as the first argument to the dyn:map function, arranged in document order.
  • + *
  • the context size is the number of nodes passed as the first argument to the + * dyn:map function.
  • + *
+ *

+ * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns an empty node set. + *

+ * If the XPath expression evaluates as a node set, the dyn:map function returns + * the union of the node sets returned by evaluating the expression for each of the + * nodes in the first argument. Note that this may mean that the node set resulting + * from the call to the dyn:map function contains a different number of nodes from + * the number in the node set passed as the first argument to the function. + *

+ * If the XPath expression evaluates as a number, the dyn:map function returns a + * node set containing one exsl:number element (namespace http://exslt.org/common) + * for each node in the node set passed as the first argument to the dyn:map function, + * in document order. The string value of each exsl:number element is the same as + * the result of converting the number resulting from evaluating the expression to + * a string as with the number function, with the exception that Infinity results + * in an exsl:number holding the highest number the implementation can store, and + * -Infinity results in an exsl:number holding the lowest number the implementation + * can store. + *

+ * If the XPath expression evaluates as a boolean, the dyn:map function returns a + * node set containing one exsl:boolean element (namespace http://exslt.org/common) + * for each node in the node set passed as the first argument to the dyn:map function, + * in document order. The string value of each exsl:boolean element is 'true' if the + * expression evaluates as true for the node, and '' if the expression evaluates as + * false. + *

+ * Otherwise, the dyn:map function returns a node set containing one exsl:string + * element (namespace http://exslt.org/common) for each node in the node set passed + * as the first argument to the dyn:map function, in document order. The string + * value of each exsl:string element is the same as the result of converting the + * result of evaluating the expression for the relevant node to a string as with + * the string function. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * @return The node set after evaluation + */ + public static NodeList map(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException { + XPathContext xctxt = null; + Document lDoc = null; + + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); + + if (expr == null || expr.length() == 0) + return new NodeSet(); + + NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt); + xctxt.pushContextNodeList(contextNodes); + + NodeSet resultSet = new NodeSet(); + resultSet.setShouldCacheNodes(true); + + for (int i = 0; i < nl.getLength(); i++) { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + XObject object = null; + try { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()); + + if (object instanceof XNodeSet) { + NodeList nodelist = null; + nodelist = ((XNodeSet) object).nodelist(); + + for (int k = 0; k < nodelist.getLength(); k++) { + Node n = nodelist.item(k); + if (!resultSet.contains(n)) + resultSet.addNode(n); + } + } else { + if (lDoc == null) { + lDoc = JdkXmlUtils.getDOMDocument(); + } + + Element element = null; + if (object instanceof XNumber) + element = lDoc.createElementNS(EXSL_URI, "exsl:number"); + else if (object instanceof XBoolean) + element = lDoc.createElementNS(EXSL_URI, "exsl:boolean"); + else + element = lDoc.createElementNS(EXSL_URI, "exsl:string"); + + Text textNode = lDoc.createTextNode(object.str()); + element.appendChild(textNode); + resultSet.addNode(element); + } + } catch (Exception e) { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + + xctxt.popCurrentNode(); + + } + + xctxt.popContextNodeList(); + return resultSet; + } + + /** + * The dyn:evaluate function evaluates a string as an XPath expression and returns + * the resulting value, which might be a boolean, number, string, node set, result + * tree fragment or external object. The sole argument is the string to be evaluated. + *

+ * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string), this function returns an empty node set. + *

+ * You should only use this function if the expression must be constructed dynamically, + * otherwise it is much more efficient to use the expression literally. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param xpathExpr The XPath expression string + * @return The evaluation result + */ + public static XObject evaluate(ExpressionContext myContext, String xpathExpr) + throws SAXNotSupportedException { + if (myContext instanceof XPathContext.XPathExpressionContext) { + XPathContext xctxt = null; + try { + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + + return dynamicXPath.execute(xctxt, myContext.getContextNode(), + xctxt.getNamespaceContext()); + } catch (TransformerException e) { + return new XNodeSet(xctxt.getDTMManager()); + } + } else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); //"Invalid context passed to evaluate " + } + + /** + * The dyn:closure function creates a node set resulting from transitive closure of + * evaluating the expression passed as the second argument on each of the nodes passed + * as the first argument, then on the node set resulting from that and so on until no + * more nodes are found. For example: + *

+     *  dyn:closure(., '*')
+     * 
+ * returns all the descendant elements of the node (its element children, their + * children, their children's children and so on). + *

+ * The expression is thus evaluated several times, each with a different node set + * acting as the context of the expression. The first time the expression is + * evaluated, the context node set is the first argument passed to the dyn:closure + * function. In other words, the node set for each node is calculated by evaluating + * the XPath expression with all context information being the same as that for + * the call to the dyn:closure function itself, except for the following: + *

+ *

    + *
  • the context node is the node whose value is being calculated.
  • + *
  • the context position is the position of the node within the node set passed + * as the first argument to the dyn:closure function, arranged in document order.
  • + *
  • the context size is the number of nodes passed as the first argument to the + * dyn:closure function.
  • + *
  • the current node is the node whose value is being calculated.
  • + *
+ *

+ * The result for a particular iteration is the union of the node sets resulting + * from evaluting the expression for each of the nodes in the source node set for + * that iteration. This result is then used as the source node set for the next + * iteration, and so on. The result of the function as a whole is the union of + * the node sets generated by each iteration. + *

+ * If the expression string passed as the second argument is an invalid XPath + * expression (including an empty string) or an expression that does not return a + * node set, this function returns an empty node set. + * + * @param myContext The ExpressionContext passed by the extension processor + * @param nl The node set + * @param expr The expression string + * @return The node set after evaluation + */ + public static NodeList closure(ExpressionContext myContext, NodeList nl, String expr) + throws SAXNotSupportedException { + XPathContext xctxt = null; + if (myContext instanceof XPathContext.XPathExpressionContext) + xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); + else + throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext})); + + if (expr == null || expr.length() == 0) + return new NodeSet(); + + NodeSet closureSet = new NodeSet(); + closureSet.setShouldCacheNodes(true); + + NodeList iterationList = nl; + do { + + NodeSet iterationSet = new NodeSet(); + + NodeSetDTM contextNodes = new NodeSetDTM(iterationList, xctxt); + xctxt.pushContextNodeList(contextNodes); + + for (int i = 0; i < iterationList.getLength(); i++) { + int contextNode = contextNodes.item(i); + xctxt.pushCurrentNode(contextNode); + + XObject object = null; + try { + XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), + xctxt.getNamespaceContext(), + XPath.SELECT); + object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()); + + if (object instanceof XNodeSet) { + NodeList nodelist = null; + nodelist = ((XNodeSet) object).nodelist(); + + for (int k = 0; k < nodelist.getLength(); k++) { + Node n = nodelist.item(k); + if (!iterationSet.contains(n)) + iterationSet.addNode(n); + } + } else { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + } catch (TransformerException e) { + xctxt.popCurrentNode(); + xctxt.popContextNodeList(); + return new NodeSet(); + } + + xctxt.popCurrentNode(); + + } + + xctxt.popContextNodeList(); + + iterationList = iterationSet; + + for (int i = 0; i < iterationList.getLength(); i++) { + Node n = iterationList.item(i); + if (!closureSet.contains(n)) + closureSet.addNode(n); + } + + } while (iterationList.getLength() > 0); + + return closureSet; + + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java new file mode 100644 index 0000000..8d17e83 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltMath.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xpath.internal.NodeSet; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * This class contains EXSLT math extension functions. + * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:math="http://exslt.org/math"
+ * 
+ *

+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @see EXSLT + */ +public class ExsltMath extends ExsltBase { + // Constants + private static String PI = "3.1415926535897932384626433832795028841971693993751"; + private static String E = "2.71828182845904523536028747135266249775724709369996"; + private static String SQRRT2 = "1.41421356237309504880168872420969807856967187537694"; + private static String LN2 = "0.69314718055994530941723212145817656807550013436025"; + private static String LN10 = "2.302585092994046"; + private static String LOG2E = "1.4426950408889633"; + private static String SQRT1_2 = "0.7071067811865476"; + + /** + * The math:max function returns the maximum value of the nodes passed as the argument. + * The maximum value is defined as follows. The node set passed as an argument is sorted + * in descending order as it would be by xsl:sort with a data type of number. The maximum + * is the result of converting the string value of the first node in this sorted list to + * a number using the number function. + *

+ * If the node set is empty, or if the result of converting the string values of any of the + * nodes to a number is NaN, then NaN is returned. + * + * @param nl The NodeList for the node-set to be evaluated. + * @return the maximum value found, NaN if any node cannot be converted to a number. + * @see EXSLT + */ + public static double max(NodeList nl) { + if (nl == null || nl.getLength() == 0) + return Double.NaN; + + double m = -Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + double d = toNumber(n); + if (Double.isNaN(d)) + return Double.NaN; + else if (d > m) + m = d; + } + + return m; + } + + /** + * The math:min function returns the minimum value of the nodes passed as the argument. + * The minimum value is defined as follows. The node set passed as an argument is sorted + * in ascending order as it would be by xsl:sort with a data type of number. The minimum + * is the result of converting the string value of the first node in this sorted list to + * a number using the number function. + *

+ * If the node set is empty, or if the result of converting the string values of any of + * the nodes to a number is NaN, then NaN is returned. + * + * @param nl The NodeList for the node-set to be evaluated. + * @return the minimum value found, NaN if any node cannot be converted to a number. + * @see EXSLT + */ + public static double min(NodeList nl) { + if (nl == null || nl.getLength() == 0) + return Double.NaN; + + double m = Double.MAX_VALUE; + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + double d = toNumber(n); + if (Double.isNaN(d)) + return Double.NaN; + else if (d < m) + m = d; + } + + return m; + } + + /** + * The math:highest function returns the nodes in the node set whose value is the maximum + * value for the node set. The maximum value for the node set is the same as the value as + * calculated by math:max. A node has this maximum value if the result of converting its + * string value to a number as if by the number function is equal to the maximum value, + * where the equality comparison is defined as a numerical comparison using the = operator. + *

+ * If any of the nodes in the node set has a non-numeric value, the math:max function will + * return NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any + * of the nodes in the node set has a non-numeric value, math:highest will return an empty + * node set. + * + * @param nl The NodeList for the node-set to be evaluated. + * @return node-set with nodes containing the maximum value found, an empty node-set + * if any node cannot be converted to a number. + */ + public static NodeList highest(NodeList nl) { + double maxValue = max(nl); + + NodeSet highNodes = new NodeSet(); + highNodes.setShouldCacheNodes(true); + + if (Double.isNaN(maxValue)) + return highNodes; // empty Nodeset + + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + double d = toNumber(n); + if (d == maxValue) + highNodes.addElement(n); + } + return highNodes; + } + + /** + * The math:lowest function returns the nodes in the node set whose value is the minimum value + * for the node set. The minimum value for the node set is the same as the value as calculated + * by math:min. A node has this minimum value if the result of converting its string value to + * a number as if by the number function is equal to the minimum value, where the equality + * comparison is defined as a numerical comparison using the = operator. + *

+ * If any of the nodes in the node set has a non-numeric value, the math:min function will return + * NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any of the nodes + * in the node set has a non-numeric value, math:lowest will return an empty node set. + * + * @param nl The NodeList for the node-set to be evaluated. + * @return node-set with nodes containing the minimum value found, an empty node-set + * if any node cannot be converted to a number. + */ + public static NodeList lowest(NodeList nl) { + double minValue = min(nl); + + NodeSet lowNodes = new NodeSet(); + lowNodes.setShouldCacheNodes(true); + + if (Double.isNaN(minValue)) + return lowNodes; // empty Nodeset + + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + double d = toNumber(n); + if (d == minValue) + lowNodes.addElement(n); + } + return lowNodes; + } + + /** + * The math:abs function returns the absolute value of a number. + * + * @param num A number + * @return The absolute value of the number + */ + public static double abs(double num) { + return Math.abs(num); + } + + /** + * The math:acos function returns the arccosine value of a number. + * + * @param num A number + * @return The arccosine value of the number + */ + public static double acos(double num) { + return Math.acos(num); + } + + /** + * The math:asin function returns the arcsine value of a number. + * + * @param num A number + * @return The arcsine value of the number + */ + public static double asin(double num) { + return Math.asin(num); + } + + /** + * The math:atan function returns the arctangent value of a number. + * + * @param num A number + * @return The arctangent value of the number + */ + public static double atan(double num) { + return Math.atan(num); + } + + /** + * The math:atan2 function returns the angle ( in radians ) from the X axis to a point (y,x). + * + * @param num1 The X axis value + * @param num2 The Y axis value + * @return The angle (in radians) from the X axis to a point (y,x) + */ + public static double atan2(double num1, double num2) { + return Math.atan2(num1, num2); + } + + /** + * The math:cos function returns cosine of the passed argument. + * + * @param num A number + * @return The cosine value of the number + */ + public static double cos(double num) { + return Math.cos(num); + } + + /** + * The math:exp function returns e (the base of natural logarithms) raised to a power. + * + * @param num A number + * @return The value of e raised to the given power + */ + public static double exp(double num) { + return Math.exp(num); + } + + /** + * The math:log function returns the natural logarithm of a number. + * + * @param num A number + * @return The natural logarithm of the number + */ + public static double log(double num) { + return Math.log(num); + } + + /** + * The math:power function returns the value of a base expression taken to a specified power. + * + * @param num1 The base + * @param num2 The power + * @return The value of the base expression taken to the specified power + */ + public static double power(double num1, double num2) { + return Math.pow(num1, num2); + } + + /** + * The math:random function returns a random number from 0 to 1. + * + * @return A random double from 0 to 1 + */ + public static double random() { + return Math.random(); + } + + /** + * The math:sin function returns the sine of the number. + * + * @param num A number + * @return The sine value of the number + */ + public static double sin(double num) { + return Math.sin(num); + } + + /** + * The math:sqrt function returns the square root of a number. + * + * @param num A number + * @return The square root of the number + */ + public static double sqrt(double num) { + return Math.sqrt(num); + } + + /** + * The math:tan function returns the tangent of the number passed as an argument. + * + * @param num A number + * @return The tangent value of the number + */ + public static double tan(double num) { + return Math.tan(num); + } + + /** + * The math:constant function returns the specified constant to a set precision. + * The possible constants are: + *

+     *  PI
+     *  E
+     *  SQRRT2
+     *  LN2
+     *  LN10
+     *  LOG2E
+     *  SQRT1_2
+     * 
+ * + * @param name The name of the constant + * @param precision The precision + * @return The value of the specified constant to the given precision + */ + public static double constant(String name, double precision) { + String value = null; + if (name.equals("PI")) + value = PI; + else if (name.equals("E")) + value = E; + else if (name.equals("SQRRT2")) + value = SQRRT2; + else if (name.equals("LN2")) + value = LN2; + else if (name.equals("LN10")) + value = LN10; + else if (name.equals("LOG2E")) + value = LOG2E; + else if (name.equals("SQRT1_2")) + value = SQRT1_2; + + if (value != null) { + int bits = (int) precision; + + if (bits <= value.length()) + value = value.substring(0, bits); + + return Double.parseDouble(value); + } else + return Double.NaN; + + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java new file mode 100644 index 0000000..25bdfd7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltSets.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: ExsltSets.java,v 1.1.2.1 2005/08/01 02:08:50 jeffsuttor Exp $ + */ +package com.sun.org.apache.xalan.internal.lib; + +import com.sun.org.apache.xml.internal.utils.DOM2Helper; +import com.sun.org.apache.xpath.internal.NodeSet; + +import java.util.HashMap; +import java.util.Map; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * This class contains EXSLT set extension functions. + * It is accessed by specifying a namespace URI as follows: + *
+ *    xmlns:set="http://exslt.org/sets"
+ * 
+ *

+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @see EXSLT + */ +public class ExsltSets extends ExsltBase { + /** + * The set:leading function returns the nodes in the node set passed as the first argument that + * precede, in document order, the first node in the node set passed as the second argument. If + * the first node in the second node set is not contained in the first node set, then an empty + * node set is returned. If the second node set is empty, then the first node set is returned. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that precede in document order the first + * node in nl2; an empty node-set if the first node in nl2 is not in nl1; all of nl1 if nl2 + * is empty. + * @see EXSLT + */ + public static NodeList leading(NodeList nl1, NodeList nl2) { + if (nl2.getLength() == 0) + return nl1; + + NodeSet ns1 = new NodeSet(nl1); + NodeSet leadNodes = new NodeSet(); + Node endNode = nl2.item(0); + if (!ns1.contains(endNode)) + return leadNodes; // empty NodeSet + + for (int i = 0; i < nl1.getLength(); i++) { + Node testNode = nl1.item(i); + if (DOM2Helper.isNodeAfter(testNode, endNode) + && !DOM2Helper.isNodeTheSame(testNode, endNode)) + leadNodes.addElement(testNode); + } + return leadNodes; + } + + /** + * The set:trailing function returns the nodes in the node set passed as the first argument that + * follow, in document order, the first node in the node set passed as the second argument. If + * the first node in the second node set is not contained in the first node set, then an empty + * node set is returned. If the second node set is empty, then the first node set is returned. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that follow in document order the first + * node in nl2; an empty node-set if the first node in nl2 is not in nl1; all of nl1 if nl2 + * is empty. + * @see EXSLT + */ + public static NodeList trailing(NodeList nl1, NodeList nl2) { + if (nl2.getLength() == 0) + return nl1; + + NodeSet ns1 = new NodeSet(nl1); + NodeSet trailNodes = new NodeSet(); + Node startNode = nl2.item(0); + if (!ns1.contains(startNode)) + return trailNodes; // empty NodeSet + + for (int i = 0; i < nl1.getLength(); i++) { + Node testNode = nl1.item(i); + if (DOM2Helper.isNodeAfter(startNode, testNode) + && !DOM2Helper.isNodeTheSame(startNode, testNode)) + trailNodes.addElement(testNode); + } + return trailNodes; + } + + /** + * The set:intersection function returns a node set comprising the nodes that are within + * both the node sets passed as arguments to it. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that are also + * in nl2. + * @see EXSLT + */ + public static NodeList intersection(NodeList nl1, NodeList nl2) { + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + NodeSet inter = new NodeSet(); + + inter.setShouldCacheNodes(true); + + for (int i = 0; i < ns1.getLength(); i++) { + Node n = ns1.elementAt(i); + + if (ns2.contains(n)) + inter.addElement(n); + } + + return inter; + } + + /** + * The set:difference function returns the difference between two node sets - those nodes that + * are in the node set passed as the first argument that are not in the node set passed as the + * second argument. + * + * @param nl1 NodeList for first node-set. + * @param nl2 NodeList for second node-set. + * @return a NodeList containing the nodes in nl1 that are not in nl2. + * @see EXSLT + */ + public static NodeList difference(NodeList nl1, NodeList nl2) { + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + NodeSet diff = new NodeSet(); + + diff.setShouldCacheNodes(true); + + for (int i = 0; i < ns1.getLength(); i++) { + Node n = ns1.elementAt(i); + + if (!ns2.contains(n)) + diff.addElement(n); + } + + return diff; + } + + /** + * The set:distinct function returns a subset of the nodes contained in the node-set NS passed + * as the first argument. Specifically, it selects a node N if there is no node in NS that has + * the same string value as N, and that precedes N in document order. + * + * @param nl NodeList for the node-set. + * @return a NodeList with nodes from nl containing distinct string values. + * In other words, if more than one node in nl contains the same string value, + * only include the first such node found. + * @see EXSLT + */ + public static NodeList distinct(NodeList nl) { + NodeSet dist = new NodeSet(); + dist.setShouldCacheNodes(true); + + Map stringTable = new HashMap<>(); + + for (int i = 0; i < nl.getLength(); i++) { + Node currNode = nl.item(i); + String key = toString(currNode); + + if (key == null) + dist.addElement(currNode); + else if (!stringTable.containsKey(key)) { + stringTable.put(key, currNode); + dist.addElement(currNode); + } + } + + return dist; + } + + /** + * The set:has-same-node function returns true if the node set passed as the first argument shares + * any nodes with the node set passed as the second argument. If there are no nodes that are in both + * node sets, then it returns false. + *

+ * The Xalan extensions MethodResolver converts 'has-same-node' to 'hasSameNode'. + *

+ * Note: Not to be confused with hasSameNodes in the Xalan namespace, which returns true if + * the two node sets contain the exactly the same nodes (perhaps in a different order), + * otherwise false. + * + * @see EXSLT + */ + public static boolean hasSameNode(NodeList nl1, NodeList nl2) { + + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + for (int i = 0; i < ns1.getLength(); i++) { + if (ns2.contains(ns1.elementAt(i))) + return true; + } + return false; + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java new file mode 100644 index 0000000..5817e18 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java @@ -0,0 +1,295 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import java.util.StringTokenizer; + +import com.sun.org.apache.xpath.internal.NodeSet; + +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +/** + * This class contains EXSLT strings extension functions. + *

+ * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:str="http://exslt.org/strings"
+ * 
+ * The documentation for each function has been copied from the relevant + * EXSLT Implementer page. + * + * @xsl.usage general + * @see EXSLT + */ +public class ExsltStrings extends ExsltBase { + + /** + * The str:align function aligns a string within another string. + *

+ * The first argument gives the target string to be aligned. The second argument gives + * the padding string within which it is to be aligned. + *

+ * If the target string is shorter than the padding string then a range of characters + * in the padding string are repaced with those in the target string. Which characters + * are replaced depends on the value of the third argument, which gives the type of + * alignment. It can be one of 'left', 'right' or 'center'. If no third argument is + * given or if it is not one of these values, then it defaults to left alignment. + *

+ * With left alignment, the range of characters replaced by the target string begins + * with the first character in the padding string. With right alignment, the range of + * characters replaced by the target string ends with the last character in the padding + * string. With center alignment, the range of characters replaced by the target string + * is in the middle of the padding string, such that either the number of unreplaced + * characters on either side of the range is the same or there is one less on the left + * than there is on the right. + *

+ * If the target string is longer than the padding string, then it is truncated to be + * the same length as the padding string and returned. + * + * @param targetStr The target string + * @param paddingStr The padding string + * @param type The type of alignment + * @return The string after alignment + */ + public static String align(String targetStr, String paddingStr, String type) { + if (targetStr.length() >= paddingStr.length()) + return targetStr.substring(0, paddingStr.length()); + + if (type.equals("right")) { + return paddingStr.substring(0, paddingStr.length() - targetStr.length()) + targetStr; + } else if (type.equals("center")) { + int startIndex = (paddingStr.length() - targetStr.length()) / 2; + return paddingStr.substring(0, startIndex) + targetStr + paddingStr.substring(startIndex + targetStr.length()); + } + // Default is left + else { + return targetStr + paddingStr.substring(targetStr.length()); + } + } + + /** + * See above + */ + public static String align(String targetStr, String paddingStr) { + return align(targetStr, paddingStr, "left"); + } + + /** + * The str:concat function takes a node set and returns the concatenation of the + * string values of the nodes in that node set. If the node set is empty, it returns + * an empty string. + * + * @param nl A node set + * @return The concatenation of the string values of the nodes in that node set + */ + public static String concat(NodeList nl) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < nl.getLength(); i++) { + Node node = nl.item(i); + String value = toString(node); + + if (value != null && value.length() > 0) + sb.append(value); + } + + return sb.toString(); + } + + /** + * The str:padding function creates a padding string of a certain length. + * The first argument gives the length of the padding string to be created. + * The second argument gives a string to be used to create the padding. This + * string is repeated as many times as is necessary to create a string of the + * length specified by the first argument; if the string is more than a character + * long, it may have to be truncated to produce the required length. If no second + * argument is specified, it defaults to a space (' '). If the second argument is + * an empty string, str:padding returns an empty string. + * + * @param length The length of the padding string to be created + * @param pattern The string to be used as pattern + * @return A padding string of the given length + */ + public static String padding(double length, String pattern) { + if (pattern == null || pattern.length() == 0) + return ""; + + StringBuffer sb = new StringBuffer(); + int len = (int) length; + int numAdded = 0; + int index = 0; + while (numAdded < len) { + if (index == pattern.length()) + index = 0; + + sb.append(pattern.charAt(index)); + index++; + numAdded++; + } + + return sb.toString(); + } + + /** + * See above + */ + public static String padding(double length) { + return padding(length, " "); + } + + /** + * The str:split function splits up a string and returns a node set of token + * elements, each containing one token from the string. + *

+ * The first argument is the string to be split. The second argument is a pattern + * string. The string given by the first argument is split at any occurrence of + * this pattern. For example: + *

+     * str:split('a, simple, list', ', ') gives the node set consisting of:
+     *
+     * a
+     * simple
+     * list
+     * 
+ * If the second argument is omitted, the default is the string ' ' (i.e. a space). + * + * @param str The string to be split + * @param pattern The pattern + * @return A node set of split tokens + */ + public static NodeList split(String str, String pattern) { + + + NodeSet resultSet = new NodeSet(); + resultSet.setShouldCacheNodes(true); + + boolean done = false; + int fromIndex = 0; + int matchIndex = 0; + String token = null; + + while (!done && fromIndex < str.length()) { + matchIndex = str.indexOf(pattern, fromIndex); + if (matchIndex >= 0) { + token = str.substring(fromIndex, matchIndex); + fromIndex = matchIndex + pattern.length(); + } else { + done = true; + token = str.substring(fromIndex); + } + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) { + Element element = doc.createElement("token"); + Text text = doc.createTextNode(token); + element.appendChild(text); + resultSet.addNode(element); + } + } + + return resultSet; + } + + /** + * See above + */ + public static NodeList split(String str) { + return split(str, " "); + } + + /** + * The str:tokenize function splits up a string and returns a node set of token + * elements, each containing one token from the string. + *

+ * The first argument is the string to be tokenized. The second argument is a + * string consisting of a number of characters. Each character in this string is + * taken as a delimiting character. The string given by the first argument is split + * at any occurrence of any of these characters. For example: + *

+     * str:tokenize('2001-06-03T11:40:23', '-T:') gives the node set consisting of:
+     *
+     * 2001
+     * 06
+     * 03
+     * 11
+     * 40
+     * 23
+     * 
+ * If the second argument is omitted, the default is the string ' ' + * (i.e. whitespace characters). + *

+ * If the second argument is an empty string, the function returns a set of token + * elements, each of which holds a single character. + *

+ * Note: This one is different from the tokenize extension function in the Xalan + * namespace. The one in Xalan returns a set of Text nodes, while this one wraps + * the Text nodes inside the token Element nodes. + * + * @param toTokenize The string to be tokenized + * @param delims The delimiter string + * @return A node set of split token elements + */ + public static NodeList tokenize(String toTokenize, String delims) { + + + NodeSet resultSet = new NodeSet(); + + if (delims != null && delims.length() > 0) { + StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) { + while (lTokenizer.hasMoreTokens()) { + Element element = doc.createElement("token"); + element.appendChild(doc.createTextNode(lTokenizer.nextToken())); + resultSet.addNode(element); + } + } + } + // If the delimiter is an empty string, create one token Element for + // every single character. + else { + + Document doc = JdkXmlUtils.getDOMDocument(); + synchronized (doc) { + for (int i = 0; i < toTokenize.length(); i++) { + Element element = doc.createElement("token"); + element.appendChild(doc.createTextNode(toTokenize.substring(i, i + 1))); + resultSet.addNode(element); + } + } + } + + return resultSet; + } + + /** + * See above + */ + public static NodeList tokenize(String toTokenize) { + return tokenize(toTokenize, " \t\n\r"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java new file mode 100644 index 0000000..24f348f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/Extensions.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import java.util.StringTokenizer; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xpath.internal.NodeSet; +import com.sun.org.apache.xpath.internal.objects.XBoolean; +import com.sun.org.apache.xpath.internal.objects.XNumber; +import com.sun.org.apache.xpath.internal.objects.XObject; + +import jdk.xml.internal.JdkXmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.DocumentFragment; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; +import org.w3c.dom.traversal.NodeIterator; + +import org.xml.sax.SAXNotSupportedException; + +/** + * This class contains many of the Xalan-supplied extensions. + * It is accessed by specifying a namespace URI as follows: + *

+ *    xmlns:xalan="http://xml.apache.org/xalan"
+ * 
+ * + * @xsl.usage general + */ +public class Extensions { + /** + * Constructor Extensions + */ + private Extensions() { + } // Make sure class cannot be instantiated + + /** + * This method is an extension that implements as a Xalan extension + * the node-set function also found in xt and saxon. + * If the argument is a Result Tree Fragment, then nodeset + * returns a node-set consisting of a single root node as described in + * section 11.1 of the XSLT 1.0 Recommendation. If the argument is a + * node-set, nodeset returns a node-set. If the argument + * is a string, number, or boolean, then nodeset returns + * a node-set consisting of a single root node with a single text node + * child that is the result of calling the XPath string() function on the + * passed parameter. If the argument is anything else, then a node-set + * is returned consisting of a single root node with a single text node + * child that is the result of calling the java toString() + * method on the passed argument. + * Most of the + * actual work here is done in MethodResolver and + * XRTreeFrag. + * + * @param myProcessor Context passed by the extension processor + * @param rtf Argument in the stylesheet to the nodeset extension function + *

+ * NEEDSDOC ($objectName$) @return + */ + public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf) { + + String textNodeValue; + + if (rtf instanceof NodeIterator) { + return new NodeSet((NodeIterator) rtf); + } else { + if (rtf instanceof String) { + textNodeValue = (String) rtf; + } else if (rtf instanceof Boolean) { + textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str(); + } else if (rtf instanceof Double) { + textNodeValue = new XNumber(((Double) rtf).doubleValue()).str(); + } else { + textNodeValue = rtf.toString(); + } + + // This no longer will work right since the DTM. + // Document myDoc = myProcessor.getContextNode().getOwnerDocument(); + Document myDoc = JdkXmlUtils.getDOMDocument(); + + Text textNode = myDoc.createTextNode(textNodeValue); + DocumentFragment docFrag = myDoc.createDocumentFragment(); + + docFrag.appendChild(textNode); + + return new NodeSet(docFrag); + } + } + + /** + * Returns the intersection of two node-sets. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return a NodeList containing the nodes in nl1 that are also in nl2 + *

+ * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList intersection(NodeList nl1, NodeList nl2) { + return ExsltSets.intersection(nl1, nl2); + } + + /** + * Returns the difference between two node-sets. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return a NodeList containing the nodes in nl1 that are not in nl2 + *

+ * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList difference(NodeList nl1, NodeList nl2) { + return ExsltSets.difference(nl1, nl2); + } + + /** + * Returns node-set containing distinct string values. + * + * @param nl NodeList for node-set + * @return a NodeList with nodes from nl containing distinct string values. + * In other words, if more than one node in nl contains the same string value, + * only include the first such node found. + *

+ * Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT sets extension + * (http://exslt.org/sets). + */ + public static NodeList distinct(NodeList nl) { + return ExsltSets.distinct(nl); + } + + /** + * Returns true if both node-sets contain the same set of nodes. + * + * @param nl1 NodeList for first node-set + * @param nl2 NodeList for second node-set + * @return true if nl1 and nl2 contain exactly the same set of nodes. + */ + public static boolean hasSameNodes(NodeList nl1, NodeList nl2) { + + NodeSet ns1 = new NodeSet(nl1); + NodeSet ns2 = new NodeSet(nl2); + + if (ns1.getLength() != ns2.getLength()) + return false; + + for (int i = 0; i < ns1.getLength(); i++) { + Node n = ns1.elementAt(i); + + if (!ns2.contains(n)) + return false; + } + + return true; + } + + /** + * Returns the result of evaluating the argument as a string containing + * an XPath expression. Used where the XPath expression is not known until + * run-time. The expression is evaluated as if the run-time value of the + * argument appeared in place of the evaluate function call at compile time. + * + * @param myContext an ExpressionContext passed in by the + * extension mechanism. This must be an XPathContext. + * @param xpathExpr The XPath expression to be evaluated. + * @return the XObject resulting from evaluating the XPath + * @throws SAXNotSupportedException Note: The usage of this extension function in the xalan namespace + * is deprecated. Please use the same function in the EXSLT dynamic extension + * (http://exslt.org/dynamic). + */ + public static XObject evaluate(ExpressionContext myContext, String xpathExpr) + throws SAXNotSupportedException { + return ExsltDynamic.evaluate(myContext, xpathExpr); + } + + /** + * Returns a NodeSet containing one text node for each token in the first argument. + * Delimiters are specified in the second argument. + * Tokens are determined by a call to StringTokenizer. + * If the first argument is an empty string or contains only delimiters, the result + * will be an empty NodeSet. + *

+ * Contributed to XalanJ1 by Benoit Cerrina. + * + * @param toTokenize The string to be split into text tokens. + * @param delims The delimiters to use. + * @return a NodeSet as described above. + */ + public static NodeList tokenize(String toTokenize, String delims) { + + Document doc = JdkXmlUtils.getDOMDocument(); + + StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); + NodeSet resultSet = new NodeSet(); + + synchronized (doc) { + while (lTokenizer.hasMoreTokens()) { + resultSet.addNode(doc.createTextNode(lTokenizer.nextToken())); + } + } + + return resultSet; + } + + /** + * Returns a NodeSet containing one text node for each token in the first argument. + * Delimiters are whitespace. That is, the delimiters that are used are tab ( ), + * linefeed ( ), return ( ), and space ( ). + * Tokens are determined by a call to StringTokenizer. + * If the first argument is an empty string or contains only delimiters, the result + * will be an empty NodeSet. + *

+ * Contributed to XalanJ1 by Benoit Cerrina. + * + * @param toTokenize The string to be split into text tokens. + * @return a NodeSet as described above. + */ + public static NodeList tokenize(String toTokenize) { + return tokenize(toTokenize, " \t\n\r"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java new file mode 100644 index 0000000..c61db7f --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/NodeInfo.java @@ -0,0 +1,239 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.lib; + +import javax.xml.transform.SourceLocator; + +import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * NodeInfo defines a set of XSLT extension functions to be + * used from stylesheets. + * + * @author Ovidiu Predescu + * @since May 24, 2001 + */ +public class NodeInfo { + /** + * systemId returns the system id of the current + * context node. + * + * @param context an ExpressionContext value + * @return a String value + */ + public static String systemId(ExpressionContext context) { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy) contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getSystemId(); + else + return null; + } + + /** + * systemId returns the system id of the node passed as + * argument. If a node set is passed as argument, the system id of + * the first node in the set is returned. + * + * @param nodeList a NodeList value + * @return a String value + */ + public static String systemId(NodeList nodeList) { + if (nodeList == null || nodeList.getLength() == 0) + return null; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy) node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getSystemId(); + else + return null; + } + + /** + * publicId returns the public identifier of the current + * context node. + *

+ * Xalan does not currently record this value, and will return null. + * + * @param context an ExpressionContext value + * @return a String value + */ + public static String publicId(ExpressionContext context) { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy) contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getPublicId(); + else + return null; + } + + /** + * publicId returns the public identifier of the node passed as + * argument. If a node set is passed as argument, the public identifier of + * the first node in the set is returned. + *

+ * Xalan does not currently record this value, and will return null. + * + * @param nodeList a NodeList value + * @return a String value + */ + public static String publicId(NodeList nodeList) { + if (nodeList == null || nodeList.getLength() == 0) + return null; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy) node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getPublicId(); + else + return null; + } + + /** + * lineNumber returns the line number of the current + * context node. + *

+ * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param context an ExpressionContext value + * @return an int value. This may be -1 to indicate that the + * line number is not known. + */ + public static int lineNumber(ExpressionContext context) { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy) contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getLineNumber(); + else + return -1; + } + + /** + * lineNumber returns the line number of the node + * passed as argument. If a node set is passed as argument, the line + * number of the first node in the set is returned. + *

+ * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param nodeList a NodeList value + * @return an int value. This may be -1 to indicate that the + * line number is not known. + */ + public static int lineNumber(NodeList nodeList) { + if (nodeList == null || nodeList.getLength() == 0) + return -1; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy) node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getLineNumber(); + else + return -1; + } + + /** + * columnNumber returns the column number of the + * current context node. + *

+ * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param context an ExpressionContext value + * @return an int value. This may be -1 to indicate that the + * column number is not known. + */ + public static int columnNumber(ExpressionContext context) { + Node contextNode = context.getContextNode(); + int nodeHandler = ((DTMNodeProxy) contextNode).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) contextNode).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getColumnNumber(); + else + return -1; + } + + /** + * columnNumber returns the column number of the node + * passed as argument. If a node set is passed as argument, the line + * number of the first node in the set is returned. + *

+ * NOTE: Xalan does not normally record location information for each node. + * To obtain it, you must set the custom TrAX attribute + * "http://xml.apache.org/xalan/features/source_location" + * true in the TransformerFactory before generating the Transformer and executing + * the stylesheet. Storage cost per node will be noticably increased in this mode. + * + * @param nodeList a NodeList value + * @return an int value. This may be -1 to indicate that the + * column number is not known. + */ + public static int columnNumber(NodeList nodeList) { + if (nodeList == null || nodeList.getLength() == 0) + return -1; + + Node node = nodeList.item(0); + int nodeHandler = ((DTMNodeProxy) node).getDTMNodeNumber(); + SourceLocator locator = ((DTMNodeProxy) node).getDTM() + .getSourceLocatorFor(nodeHandler); + + if (locator != null) + return locator.getColumnNumber(); + else + return -1; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html new file mode 100644 index 0000000..4327e92 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/lib/package.html @@ -0,0 +1,30 @@ + + + + +Xalan and EXSLT Extensions. + +

Extension elements and functions shipped with Xalan-Java, including EXSLT functions.

+

We are adding extensions to this package. +

+ + + + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java new file mode 100644 index 0000000..f3e7dcc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLMessages.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import com.sun.org.apache.xpath.internal.res.XPATHMessages; + +import java.util.ResourceBundle; + +import jdk.xml.internal.SecuritySupport; + +/** + * Sets things up for issuing error messages. This class is misnamed, and should + * be called XalanMessages, or some such. + * + * @xsl.usage internal + * @LastModified: Sep 2017 + */ +public class XSLMessages extends XPATHMessages { + + /** + * The language specific resource object for Xalan messages. + */ + private static ResourceBundle XSLTBundle = null; + /** + * The class name of the Xalan error message string table. + */ + private static final String XSLT_ERROR_RESOURCES = + "com.sun.org.apache.xalan.internal.res.XSLTErrorResources"; + + /** + * Creates a message from the specified key and replacement arguments, + * localized to the given locale. + * + * @param msgKey The key for the message text. + * @param args The arguments to be used as replacement text in the message + * created. + * @return The formatted message string. + */ + public static String createMessage(String msgKey, Object args[]) //throws Exception + { + if (XSLTBundle == null) { + XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES); + } + + if (XSLTBundle != null) { + return createMsg(XSLTBundle, msgKey, args); + } else { + return "Could not load any resource bundles."; + } + } + + /** + * Creates a message from the specified key and replacement arguments, + * localized to the given locale. + * + * @param msgKey The key for the message text. + * @param args The arguments to be used as replacement text in the message + * created. + * @return The formatted warning string. + */ + public static String createWarning(String msgKey, Object args[]) //throws Exception + { + if (XSLTBundle == null) { + XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES); + } + + if (XSLTBundle != null) { + return createMsg(XSLTBundle, msgKey, args); + } else { + return "Could not load any resource bundles."; + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java new file mode 100644 index 0000000..c697dd6 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java @@ -0,0 +1,1429 @@ +/* + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + * + * @LastModified: May 2022 + */ +public class XSLTErrorResources extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Error: Can not have '{' within expression"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} has an illegal attribute: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode is null in xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "Can not add {0} to {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode is null in handleApplyTemplatesInstruction!"}, + + {ER_NO_NAME_ATTRIB, + "{0} must have a name attribute."}, + + {ER_TEMPLATE_NOT_FOUND, + "Could not find template named: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Could not resolve name AVT in xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} requires attribute: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} must have a ''test'' attribute."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Bad value on level attribute: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction name can not be 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction name must be a valid NCName: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} must have a match attribute if it has a mode."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} requires either a name or a match attribute."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Can not resolve namespace prefix: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space has an illegal value: {0}"}, + + {ER_NO_OWNERDOC, + "Child node does not have an owner document!"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement error: {0}"}, + + {ER_NULL_CHILD, + "Trying to add a null child!"}, + + {ER_NEED_SELECT_ATTRIB, + "{0} requires a select attribute."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when must have a 'test' attribute."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param must have a 'name' attribute."}, + + {ER_NO_CONTEXT_OWNERDOC, + "context does not have an owner document!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Could not create XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Process was not successful."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: was not successful."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Encoding not supported: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Could not create TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key requires a 'name' attribute!"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key requires a 'match' attribute!"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key requires a 'use' attribute!"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} requires an ''elements'' attribute!"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} attribute ''prefix'' is missing"}, + + {ER_BAD_STYLESHEET_URL, + "Stylesheet URL is bad: {0}"}, + + {ER_FILE_NOT_FOUND, + "Stylesheet file was not found: {0}"}, + + {ER_IOEXCEPTION, + "Had IO Exception with stylesheet file: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Could not find href attribute for {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} is directly or indirectly including itself!"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude error, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} attribute ''lang'' is missing"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) misplaced {0} element?? Missing container element ''component''"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Can only output to an Element, DocumentFragment, Document, or PrintWriter."}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process error"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode error: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Error! Did not find xpath select expression (-select)."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Can not serialize an XSLProcessor!"}, + + {ER_NO_INPUT_STYLESHEET, + "Stylesheet input was not specified!"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Failed to process stylesheet!"}, + + {ER_COULDNT_PARSE_DOC, + "Could not parse {0} document!"}, + + {ER_COULDNT_FIND_FRAGMENT, + "Could not find fragment: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "Node pointed to by fragment identifier was not an element: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each must have either a match or name attribute"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates must have either a match or name attribute"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "No clone of a document fragment!"}, + + {ER_CANT_CREATE_ITEM, + "Can not create item in result tree: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space in the source XML has an illegal value: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "There is no xsl:key declaration for {0}!"}, + + {ER_CANT_CREATE_URL, + "Error! Cannot create url for: {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions is unsupported"}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory Error"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} not allowed inside a stylesheet!"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns no longer supported! Use xsl:output instead."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space no longer supported! Use xsl:strip-space or xsl:preserve-space instead."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result no longer supported! Use xsl:output instead."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} has an illegal attribute: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Unknown XSL element: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort can only be used with xsl:apply-templates or xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) misplaced xsl:when!"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when not parented by xsl:choose!"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) misplaced xsl:otherwise!"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise not parented by xsl:choose!"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} is not allowed inside a template!"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} extension namespace prefix {1} unknown"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Imports can only occur as the first elements in the stylesheet!"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} is directly or indirectly importing itself!"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) " + "xml:space has an illegal value: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet not succesfull!"}, + + {ER_SAX_EXCEPTION, + "SAX Exception"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Function not supported!"}, + + {ER_XSLT_ERROR, + "XSLT Error"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "currency sign is not allowed in format pattern string"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Document function not supported in Stylesheet DOM!"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Can't resolve prefix of non-Prefix resolver!"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirect extension: Could not get filename - file or select attribute must return vald string."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Can not build FormatterListener in Redirect extension!"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Prefix in exclude-result-prefixes is not valid: {0}"}, + + {ER_MISSING_NS_URI, + "Missing namespace URI for specified prefix"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Missing argument for option: {0}"}, + + {ER_INVALID_OPTION, + "Invalid option: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Malformed format string: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet requires a 'version' attribute!"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribute: {0} has an illegal value: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose requires an xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports not allowed in a xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "Cannot use a DTMLiaison for an output DOM node... pass a com.sun.org.apache.xpath.internal.DOM2Helper instead!"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "Cannot use a DTMLiaison for a input DOM node... pass a com.sun.org.apache.xpath.internal.DOM2Helper instead!"}, + + {ER_CALL_TO_EXT_FAILED, + "Call to extension element failed: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "Prefix must resolve to a namespace: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Invalid UTF-16 surrogate detected: {0} ?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} used itself, which will cause an infinite loop."}, + + {ER_CANNOT_MIX_XERCESDOM, + "Can not mix non Xerces-DOM input with Xerces-DOM output!"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Found more than one template named: {0}"}, + + {ER_INVALID_KEY_CALL, + "Invalid function call: recursive key() calls are not allowed"}, + + {ER_REFERENCING_ITSELF, + "Variable {0} is directly or indirectly referencing itself!"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "The input node can not be null for a DOMSource for newTemplates!"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "Class file not found for option {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "Required Element not found: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream cannot be null"}, + + {ER_URI_CANNOT_BE_NULL, + "URI cannot be null"}, + + {ER_FILE_CANNOT_BE_NULL, + "File cannot be null"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource cannot be null"}, + + {ER_CANNOT_INIT_BSFMGR, + "Could not initialize BSF Manager"}, + + {ER_CANNOT_CMPL_EXTENSN, + "Could not compile extension"}, + + {ER_CANNOT_CREATE_EXTENSN, + "Could not create extension: {0} because of: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "Instance method call to method {0} requires an Object instance as first argument"}, + + {ER_INVALID_ELEMENT_NAME, + "Invalid element name specified {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "Element name method must be static {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "Extension function {0} : {1} is unknown"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "More than one best match for constructor for {0}"}, + + {ER_MORE_MATCH_METHOD, + "More than one best match for method {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "More than one best match for element method {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Invalid context passed to evaluate {0}"}, + + {ER_POOL_EXISTS, + "Pool already exists"}, + + {ER_NO_DRIVER_NAME, + "No driver Name specified"}, + + {ER_NO_URL, + "No URL specified"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "Pool size is less than one!"}, + + {ER_INVALID_DRIVER, + "Invalid driver name specified!"}, + + {ER_NO_STYLESHEETROOT, + "Did not find the stylesheet root!"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Illegal value for xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode failed"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "The resource [ {0} ] could not load: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Buffer size <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Unknown error when calling extension"}, + + {ER_NO_NAMESPACE_DECL, + "Prefix {0} does not have a corresponding namespace declaration"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Element content not allowed for lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Stylesheet directed termination"}, + + {ER_ONE_OR_TWO, + "1 or 2"}, + + {ER_TWO_OR_THREE, + "2 or 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "Could not load {0} (check CLASSPATH), now using just the defaults"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Cannot initialize default templates"}, + + {ER_RESULT_NULL, + "Result should not be null"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "Result could not be set"}, + + {ER_NO_OUTPUT_SPECIFIED, + "No output specified"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Can''t transform to a Result of type {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Can''t transform a Source of type {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Null content handler"}, + + {ER_NULL_ERROR_HANDLER, + "Null error handler"}, + + {ER_CANNOT_CALL_PARSE, + "parse can not be called if the ContentHandler has not been set"}, + + {ER_NO_PARENT_FOR_FILTER, + "No parent for filter"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "No stylesheet found in: {0}, media= {1}"}, + + {ER_NO_STYLESHEET_PI, + "No xml-stylesheet PI found in: {0}"}, + + {ER_NOT_SUPPORTED, + "Not supported: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "Value for property {0} should be a Boolean instance"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Could not get to external script at {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "The resource [ {0} ] could not be found.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Output property not recognized: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Failed creating ElemLiteralResult instance"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "Value for {0} should contain a parsable number"}, + + {ER_VALUE_SHOULD_EQUAL, + "Value for {0} should equal yes or no"}, + + {ER_FAILED_CALLING_METHOD, + "Failed calling {0} method"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Failed creating ElemTemplateElement instance"}, + + {ER_CHARS_NOT_ALLOWED, + "Characters are not allowed at this point in the document"}, + + {ER_ATTR_NOT_ALLOWED, + "\"{0}\" attribute is not allowed on the {1} element!"}, + + {ER_BAD_VALUE, + "{0} bad value {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "{0} attribute value not found "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} attribute value not recognized "}, + + {ER_NULL_URI_NAMESPACE, + "Attempting to generate a namespace prefix with a null URI"}, + + {ER_NUMBER_TOO_BIG, + "Attempting to format a number bigger than the largest Long integer"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "Cannot find SAX1 driver class {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "SAX1 driver class {0} found but cannot be loaded"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1 driver class {0} loaded but cannot be instantiated"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 driver class {0} does not implement org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "System property org.xml.sax.parser not specified"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "Parser argument must not be null"}, + + {ER_FEATURE, + "Feature: {0}"}, + + {ER_PROPERTY, + "Property: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Null entity resolver"}, + + {ER_NULL_DTD_HANDLER, + "Null DTD handler"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "No Driver Name Specified!"}, + + {ER_NO_URL_SPECIFIED, + "No URL Specified!"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "Pool size is less than 1!"}, + + {ER_INVALID_DRIVER_NAME, + "Invalid Driver Name Specified!"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmer's error! The expression has no ElemTemplateElement parent!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmer''s assertion in RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} is not allowed in this position in the stylesheet!"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Non-whitespace text is not allowed in this position in the stylesheet!"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Illegal value: {1} used for CHAR attribute: {0}. An attribute of type CHAR must be only 1 character!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Illegal value: {1} used for QNAME attribute: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Illegal value: {1} used for ENUM attribute: {0}. Valid values are: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Illegal value: {1} used for NMTOKEN attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Illegal value: {1} used for NCNAME attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Illegal value: {1} used for boolean attribute: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Illegal value: {1} used for number attribute: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "Argument to {0} in match pattern must be a literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Duplicate global variable declaration."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Duplicate variable declaration."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template must have a name or match attribute (or both)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "Prefix in exclude-result-prefixes is not valid: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "attribute-set named {0} does not exist"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "The function named {0} does not exist"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "The {0} element must not have both content and a select attribute."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "The value of param {0} must be a valid Java Object"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "The result-prefix attribute of an xsl:namespace-alias element has the value '#default', but there is no declaration of the default namespace in scope for the element"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "The result-prefix attribute of an xsl:namespace-alias element has the value ''{0}'', but there is no namespace declaration for the prefix ''{0}'' in scope for the element."}, + + {ER_SET_FEATURE_NULL_NAME, + "The feature name cannot be null in TransformerFactory.setFeature(String name, boolean value)."}, + + {ER_GET_FEATURE_NULL_NAME, + "The feature name cannot be null in TransformerFactory.getFeature(String name)."}, + + {ER_UNSUPPORTED_FEATURE, + "Cannot set the feature ''{0}'' on this TransformerFactory."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Use of the extension element ''{0}'' is not allowed when the secure processing feature is set to true."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Cannot get the prefix for a null namespace uri."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Cannot get the namespace uri for null prefix."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "The function name cannot be null."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "The arity cannot be negative."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "Found '}' but no attribute template open!"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Warning: count attribute does not match an ancestor in xsl:number! Target = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Old syntax: The name of the 'expr' attribute has been changed to 'select'."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan doesn't yet handle the locale name in the format-number function."}, + + {WG_LOCALE_NOT_FOUND, + "Warning: Could not find locale for xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "Can not make URL from: {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "Can not load requested doc: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "Could not find Collator for >>>>>> Xalan Version "}, + {"version2", "<<<<<<<"}, + {"yes", "yes"}, + {"line", "Line #"}, + {"column", "Column #"}, + {"xsldone", "XSLProcessor: done"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J command line Process class options:"}, + {"xslProc_invalid_xsltc_option", "The option {0} is not supported in XSLTC mode."}, + {"xslProc_invalid_xalan_option", "The option {0} can only be used with -XSLTC."}, + {"xslProc_no_input", "Error: No stylesheet or input xml is specified. Run this command without any option for usage instructions."}, + {"xslProc_common_options", "-Common Options-"}, + {"xslProc_xalan_options", "-Options for Xalan-"}, + {"xslProc_xsltc_options", "-Options for XSLTC-"}, + {"xslProc_return_to_continue", "(press to continue)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (use XSLTC for transformation)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + {"optionE", " [-E (Do not expand entity refs)]"}, + {"optionV", " [-E (Do not expand entity refs)]"}, + {"optionQC", " [-QC (Quiet Pattern Conflicts Warnings)]"}, + {"optionQ", " [-Q (Quiet Mode)]"}, + {"optionLF", " [-LF (Use linefeeds only on output {default is CR/LF})]"}, + {"optionCR", " [-CR (Use carriage returns only on output {default is CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Which characters to escape {default is <>&\"\'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (Control how many spaces to indent {default is 0})]"}, + {"optionTT", " [-TT (Trace the templates as they are being called.)]"}, + {"optionTG", " [-TG (Trace each generation event.)]"}, + {"optionTS", " [-TS (Trace each selection event.)]"}, + {"optionTTC", " [-TTC (Trace the template children as they are being processed.)]"}, + {"optionTCLASS", " [-TCLASS (TraceListener class for trace extensions.)]"}, + {"optionVALIDATE", " [-VALIDATE (Set whether validation occurs. Validation is off by default.)]"}, + {"optionEDUMP", " [-EDUMP {optional filename} (Do stackdump on error.)]"}, + {"optionXML", " [-XML (Use XML formatter and add XML header.)]"}, + {"optionTEXT", " [-TEXT (Use simple Text formatter.)]"}, + {"optionHTML", " [-HTML (Use HTML formatter.)]"}, + {"optionPARAM", " [-PARAM name expression (Set a stylesheet parameter)]"}, + {"noParsermsg1", "XSL Process was not successful."}, + {"noParsermsg2", "** Could not find parser **"}, + {"noParsermsg3", "Please check your classpath."}, + {"noParsermsg4", "If you don't have IBM's XML Parser for Java, you can download it from"}, + {"noParsermsg5", "IBM's AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]"}, + {"optionLINENUMBERS", " [-L use line numbers for source document]"}, + {"optionSECUREPROCESSING", " [-SECURE (set the secure processing feature to true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Print overall milliseconds transform took.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (request incremental DTM construction by setting http://xml.apache.org/xalan/features/incremental true.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (request no stylesheet optimization processing by setting http://xml.apache.org/xalan/features/optimize false.)]"}, + {"optionRL", " [-RL recursionlimit (assert numeric limit on stylesheet recursion depth.)]"}, + {"optionXO", " [-XO [transletName] (assign the name to the generated translet)]"}, + {"optionXD", " [-XD destinationDirectory (specify a destination directory for translet)]"}, + {"optionXJ", " [-XJ jarfile (packages translet classes into a jar file of name )]"}, + {"optionXP", " [-XP package (specifies a package name prefix for all generated translet classes)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (enables template inlining)]"}, + {"optionXX", " [-XX (turns on additional debugging message output)]"}, + {"optionXT", " [-XT (use translet to transform if possible)]"}, + {"diagTiming", " --------- Transform of {0} via {1} took {2} ms"}, + {"recursionTooDeep", "Template nesting too deep. nesting = {0}, template {1} {2}"}, + {"nameIs", "name is"}, + {"matchPatternIs", "match pattern is"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java new file mode 100644 index 0000000..f51d839 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_de extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Fehler: \"{\" darf nicht im Ausdruck enthalten sein"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} hat ein ung\u00FCltiges Attribut: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode ist null in xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "{0} kann nicht zu {1} hinzugef\u00FCgt werden"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode ist null in handleApplyTemplatesInstruction."}, + + {ER_NO_NAME_ATTRIB, + "{0} muss \u00FCber ein \"name\"-Attribut verf\u00FCgen."}, + + {ER_TEMPLATE_NOT_FOUND, + "Vorlage mit Namen {0} konnte nicht gefunden werden"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Namens-AVT in xsl:call-template konnte nicht aufgel\u00F6st werden."}, + + {ER_REQUIRES_ATTRIB, + "{0} erfordert Attribut: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} muss \u00FCber ein \"test\"-Attribut verf\u00FCgen."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Ung\u00FCltiger Wert bei Ebenenattribut: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction-Name darf nicht \"xml\" lauten"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction-Name muss ein g\u00FCltiger NCName sein: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} muss \u00FCber ein \"match\"-Attribut verf\u00FCgen, wenn ein Modus vorhanden ist."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} erfordert entweder ein \"name\"- oder ein \"match\"-Attribut."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Namespace-Pr\u00E4fix kann nicht aufgel\u00F6st werden: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space hat einen ung\u00FCltigen Wert: {0}"}, + + {ER_NO_OWNERDOC, + "Der untergeordnete Knoten hat kein Eigent\u00FCmerdokument."}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement-Fehler: {0}"}, + + {ER_NULL_CHILD, + "Es wird versucht, ein leeres untergeordnetes Element hinzuzuf\u00FCgen."}, + + {ER_NEED_SELECT_ATTRIB, + "{0} erfordert ein \"select\"-Attribut."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when muss \u00FCber ein \"test\"-Attribut verf\u00FCgen."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param muss \u00FCber ein \"name\"-Attribut verf\u00FCgen."}, + + {ER_NO_CONTEXT_OWNERDOC, + "Kontext hat kein Eigent\u00FCmerdokument."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML-TransformerFactory-Liaison konnte nicht erstellt werden: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Prozess war nicht erfolgreich."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: War nicht erfolgreich."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Codierung nicht unterst\u00FCtzt: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener konnte nicht erstellt werden: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key erfordert ein \"name\"-Attribut."}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key erfordert ein \"match\"-Attribut."}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key erfordert ein \"use\"-Attribut."}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} erfordert ein \"elements\"-Attribut."}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} Attribut \"prefix\" fehlt"}, + + {ER_BAD_STYLESHEET_URL, + "Stylesheet-URL ist ung\u00FCltig: {0}"}, + + {ER_FILE_NOT_FOUND, + "Stylesheet-Datei wurde nicht gefunden: {0}"}, + + {ER_IOEXCEPTION, + "IO-Ausnahme bei Stylesheet-Datei: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \"href\"-Attribut f\u00FCr {0} konnte nicht gefunden werden"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} schlie\u00DFt sich direkt oder indirekt selbst mit ein."}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude-Fehler, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0}: Das Attribut \"lang\" fehlt"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) Element {0} an falscher Position?? Fehlendes Containerelement ''component''"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Ausgabe kann nur an ein Element, DocumentFragment, Dokument oder PrintWriter erfolgen."}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process-Fehler"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode-Fehler: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Fehler. xpath-Auswahlausdruck (-select) nicht gefunden."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor kann nicht serialisiert werden."}, + + {ER_NO_INPUT_STYLESHEET, + "Stylesheet-Eingabe wurde nicht angegeben."}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Verarbeitung des Stylesheet nicht erfolgreich."}, + + {ER_COULDNT_PARSE_DOC, + "{0}-Dokument konnte nicht geparst werden."}, + + {ER_COULDNT_FIND_FRAGMENT, + "Fragment konnte nicht gefunden werden: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "Fragment-ID verwies auf einen Knoten, der kein Element war: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each muss entweder ein \"match\"- oder ein \"name\"-Attribut haben"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "Vorlagen m\u00FCssen entweder ein \"match\"- oder ein \"name\"-Attribut haben"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Kein Clone eines Dokumentfragments."}, + + {ER_CANT_CREATE_ITEM, + "Element in Ergebnisbaum kann nicht erstellt werden: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space in Quell-XML hat einen ung\u00FCltigen Wert: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "Keine xsl:key-Deklaration f\u00FCr {0} vorhanden."}, + + {ER_CANT_CREATE_URL, + "Fehler. URL f\u00FCr {0} kann nicht erstellt werden"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions nicht unterst\u00FCtzt"}, + + {ER_PROCESSOR_ERROR, + "XSLT-TransformerFactory-Fehler"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} nicht zul\u00E4ssig in einem Stylesheet."}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:output."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:strip-space oder xsl:preserve-space."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result wird nicht mehr unterst\u00FCtzt. Verwenden Sie stattdessen xsl:output."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} hat ein ung\u00FCltiges Attribut: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Unbekanntes XSL-Element: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort kann nur mit xsl:apply-templates oder xsl:for-each verwendet werden."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when steht an der falschen Position."}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when hat nicht das \u00FCbergeordnete Element xsl:choose."}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise steht an der falschen Position."}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise hat nicht das \u00FCbergeordnete Element xsl:choose."}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} nicht zul\u00E4ssig in einer Vorlage."}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0}: Erweiterung des Namespace-Pr\u00E4fixes {1} ist unbekannt"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Importe k\u00F6nnen nur als erste Elemente in einem Stylesheet auftreten."}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importiert sich direkt oder indirekt selbst."}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space hat einen ung\u00FCltigen Wert: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet nicht erfolgreich."}, + + {ER_SAX_EXCEPTION, + "SAX-Ausnahme"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Funktion nicht unterst\u00FCtzt."}, + + {ER_XSLT_ERROR, + "XSLT-Fehler"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "W\u00E4hrungssymbol nicht zul\u00E4ssig in Formatmuster-Zeichenfolge"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Dokumentfunktion nicht unterst\u00FCtzt in DOM-Stylesheet."}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Pr\u00E4fix eines Non-Pr\u00E4fix-Resolver kann nicht aufgel\u00F6st werden."}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Umleitungserweiterung: Dateiname konnte nicht abgerufen werden. \"file\"- oder \"select\"-Attribut muss eine g\u00FCltige Zeichenfolge zur\u00FCckgeben."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "FormatterListener kann nicht in Umleitungserweiterung erstellt werden."}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Pr\u00E4fix in exclude-result-prefixes ist nicht g\u00FCltig: {0}"}, + + {ER_MISSING_NS_URI, + "Fehlender Namespace-URI f\u00FCr angegebenes Pr\u00E4fix"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Fehlendes Argument f\u00FCr Option: {0}"}, + + {ER_INVALID_OPTION, + "Ung\u00FCltige Option: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Fehlerhafte Formatzeichenfolge: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet erfordert ein \"version\"-Attribut."}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribut {0} hat einen ung\u00FCltigen Wert: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose erfordert xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports nicht zul\u00E4ssig in xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "DTMLiaison kann nicht f\u00FCr einen Ausgabe-DOM-Knoten verwendet werden. \u00DCbergeben Sie stattdessen einen com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "DTMLiaison kann nicht f\u00FCr einen Eingabe-DOM-Knoten verwendet werden. \u00DCbergeben Sie stattdessen einen com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CALL_TO_EXT_FAILED, + "Aufruf von Erweiterungselement nicht erfolgreich: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "Pr\u00E4fix muss in einen Namespace aufgel\u00F6st werden: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Ung\u00FCltige UTF-16-Ersetzung festgestellt: {0}?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} hat sich selbst verwendet. Dies f\u00FChrt zu einer Endlosschleife."}, + + {ER_CANNOT_MIX_XERCESDOM, + "Nicht-Xerces-DOM-Eingabe kann nicht mit Xerces-DOM-Ausgabe gemischt werden."}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Mehrere Vorlagen mit den Namen {0} gefunden"}, + + {ER_INVALID_KEY_CALL, + "Ung\u00FCltiger Funktionsaufruf: Rekursive key()-Aufrufe sind nicht zul\u00E4ssig"}, + + {ER_REFERENCING_ITSELF, + "Variable {0} verweist direkt oder indirekt auf sich selbst."}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "Der Eingabeknoten darf nicht null sein f\u00FCr eine DOMSource f\u00FCr newTemplates."}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "Klassendatei nicht gefunden f\u00FCr Option {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "Erforderliches Element nicht gefunden: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream darf nicht null sein"}, + + {ER_URI_CANNOT_BE_NULL, + "URI darf nicht null sein"}, + + {ER_FILE_CANNOT_BE_NULL, + "Datei darf nicht null sein"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource darf nicht null sein"}, + + {ER_CANNOT_INIT_BSFMGR, + "BSF-Manager konnte nicht initialisiert werden"}, + + {ER_CANNOT_CMPL_EXTENSN, + "Erweiterung konnte nicht kompiliert werden"}, + + {ER_CANNOT_CREATE_EXTENSN, + "Erweiterung {0} konnte nicht erstellt werden; Grund: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "Der Aufruf einer Instanzmethode von Methode {0} erfordert eine Objektinstanz als erstes Argument"}, + + {ER_INVALID_ELEMENT_NAME, + "Ung\u00FCltiger Elementname angegeben {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "Elementnamenmethode muss statisch sein {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "Erweiterungsfunktion {0} : {1} ist unbekannt"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Constructor f\u00FCr {0}"}, + + {ER_MORE_MATCH_METHOD, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Methode {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "Mehrere passende \u00DCbereinstimmungen f\u00FCr Elementmethode {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Ung\u00FCltiger Kontext zur Auswertung von {0} \u00FCbergeben"}, + + {ER_POOL_EXISTS, + "Pool ist bereits vorhanden"}, + + {ER_NO_DRIVER_NAME, + "Kein Treibername angegeben"}, + + {ER_NO_URL, + "Keine URL angegeben"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "Poolgr\u00F6\u00DFe ist kleiner als eins."}, + + {ER_INVALID_DRIVER, + "Ung\u00FCltiger Treibername angegeben."}, + + {ER_NO_STYLESHEETROOT, + "Stylesheet-Root wurde nicht gefunden."}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Ung\u00FCltiger Wert f\u00FCr xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode nicht erfolgreich"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "Ressource [ {0} ] konnte nicht geladen werden: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Puffergr\u00F6\u00DFe <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Unbekannter Fehler bei Aufruf von Erweiterung"}, + + {ER_NO_NAMESPACE_DECL, + "Pr\u00E4fix {0} hat keine entsprechende Namespace-Deklaration"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Element-Content nicht zul\u00E4ssig f\u00FCr lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Stylesheet f\u00FChrte zu Abbruch"}, + + {ER_ONE_OR_TWO, + "1 oder 2"}, + + {ER_TWO_OR_THREE, + "2 oder 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "{0} konnte nicht geladen werden (CLASSPATH pr\u00FCfen); die Standardwerte werden verwendet"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Standardvorlagen k\u00F6nnen nicht initialisiert werden"}, + + {ER_RESULT_NULL, + "Ergebnis darf nicht null sein"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "Ergebnis konnte nicht festgelegt werden"}, + + {ER_NO_OUTPUT_SPECIFIED, + "Keine Ausgabe angegeben"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Transformation in ein Ergebnis mit Typ {0} nicht m\u00F6glich"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Transformation einer Quelle mit Typ {0} nicht m\u00F6glich"}, + + {ER_NULL_CONTENT_HANDLER, + "Null-Content-Handler"}, + + {ER_NULL_ERROR_HANDLER, + "Null-Error Handler"}, + + {ER_CANNOT_CALL_PARSE, + "Parsen kann nicht aufgerufen werden, wenn der ContentHandler nicht festgelegt wurde"}, + + {ER_NO_PARENT_FOR_FILTER, + "Kein \u00FCbergeordnetes Objekt f\u00FCr Filter"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "Kein Stylesheet gefunden in: {0}, Datentr\u00E4ger = {1}"}, + + {ER_NO_STYLESHEET_PI, + "Keine Verarbeitungsanweisung f\u00FCr xml-stylesheet gefunden in: {0}"}, + + {ER_NOT_SUPPORTED, + "Nicht unterst\u00FCtzt: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "Wert f\u00FCr Eigenschaft {0} muss eine boolesche Instanz sein"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Externes Skript bei {0} konnte nicht abgerufen werden"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "Ressource [ {0} ] konnte nicht gefunden werden.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Ausgabeeigenschaft nicht erkannt: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult-Instanz konnte nicht erstellt werden"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "Wert f\u00FCr {0} sollte eine parsef\u00E4hige Zahl enthalten"}, + + {ER_VALUE_SHOULD_EQUAL, + "Wert f\u00FCr {0} muss \"Ja\" oder \"Nein\" entsprechen"}, + + {ER_FAILED_CALLING_METHOD, + "{0}-Methode konnte nicht aufgerufen werden"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement-Instanz konnte nicht erstellt werden"}, + + {ER_CHARS_NOT_ALLOWED, + "An dieser Stelle im Dokument sind keine Zeichen zul\u00E4ssig"}, + + {ER_ATTR_NOT_ALLOWED, + "\"{0}\"-Attribut ist nicht zul\u00E4ssig beim {1}-Element."}, + + {ER_BAD_VALUE, + "{0} ung\u00FCltiger Wert {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "{0}-Attributwert nicht gefunden "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0}-Attributwert nicht erkannt "}, + + {ER_NULL_URI_NAMESPACE, + "Versuch, ein Namespace-Pr\u00E4fix mit einem Null-URI zu generieren"}, + + {ER_NUMBER_TOO_BIG, + "Versuch, eine Zahl zu formatieren, die gr\u00F6\u00DFer als die gr\u00F6\u00DFte Long-Ganzzahl ist"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1-Treiberklasse {0} kann nicht gefunden werden"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "SAX1-Treiberklasse {0} gefunden, kann aber nicht geladen werden"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1-Treiberklasse {0} geladen, kann aber nicht instanziiert werden"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1-Treiberklasse {0} implementiert org.xml.sax.Parser nicht"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Systemeigenschaft \"org.xml.sax.parser\" nicht angegeben"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "Parserargument darf nicht null sein"}, + + {ER_FEATURE, + "Feature: {0}"}, + + {ER_PROPERTY, + "Eigenschaft: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Null-Entity-Resolver"}, + + {ER_NULL_DTD_HANDLER, + "Null-DTD-Handler"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "Kein Treibername angegeben."}, + + {ER_NO_URL_SPECIFIED, + "Keine URL angegeben."}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "Poolgr\u00F6\u00DFe ist kleiner als 1."}, + + {ER_INVALID_DRIVER_NAME, + "Ung\u00FCltiger Treibername angegeben."}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmiererfehler. Der Ausdruck hat kein \u00FCbergeordnetes ElemTemplateElement-Objekt."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmierer-Assertion in RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} ist an dieser Position im Stylesheet nicht zul\u00E4ssig."}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Anderer Text als Leerstellen ist an dieser Position im Stylesheet nicht zul\u00E4ssig."}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Ung\u00FCltiger Wert {1} f\u00FCr CHAR-Attribut {0} verwendet. Ein Attribut des Typs CHAR darf nur 1 Zeichen enthalten."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Ung\u00FCltiger Wert {1} f\u00FCr QNAME-Attribut {0} verwendet"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Ung\u00FCltiger Wert {1} f\u00FCr ENUM-Attribut {0} verwendet. G\u00FCltige Werte sind: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Ung\u00FCltiger Wert {1} f\u00FCr NMTOKEN-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Ung\u00FCltiger Wert {1} f\u00FCr NCNAME-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Ung\u00FCltiger Wert {1} f\u00FCr \"Boolean\"-Attribut {0} verwendet "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Ung\u00FCltiger Wert {1} f\u00FCr \"Number\"-Attribut {0} verwendet "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "Argument f\u00FCr {0} in Vergleichsmuster muss ein Literal sein."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Doppelte Deklaration einer globalen Variable."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Doppelte Variablendeklaration."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template muss ein \"name\"- oder \"match\"-Attribut (oder beides) haben"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "Pr\u00E4fix in exclude-result-prefixes ist nicht g\u00FCltig: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "attribute-set mit Namen {0} ist nicht vorhanden"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "Funktion mit Namen {0} ist nicht vorhanden"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}-Element darf weder Content noch ein \"select\"-Attribut enthalten."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "Wert von Parameter {0} muss ein g\u00FCltiges Java-Objekt sein"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "Das result-prefix-Attribut eines xsl:namespace-alias-Elements hat den Wert \"#default\", es ist aber keine Deklaration des Standard-Namespace im G\u00FCltigkeitsbereich f\u00FCr das Element vorhanden"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "Das result-prefix-Attribut eines xsl:namespace-alias-Elements hat den Wert \"{0}\", es ist aber keine Namespace-Deklaration f\u00FCr das Pr\u00E4fix \"{0}\" im G\u00FCltigkeitsbereich f\u00FCr das Element vorhanden."}, + + {ER_SET_FEATURE_NULL_NAME, + "Der Featurename darf nicht null in TransformerFactory.setFeature(Zeichenfolgenname, boolescher Wert) sein."}, + + {ER_GET_FEATURE_NULL_NAME, + "Der Featurename darf nicht null in TransformerFactory.getFeature(Zeichenfolgenname) sein."}, + + {ER_UNSUPPORTED_FEATURE, + "Das Feature \"{0}\" kann nicht f\u00FCr diese TransformerFactory festgelegt werden."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Verwendung des Erweiterungselements \"{0}\" ist nicht zul\u00E4ssig, wenn das Feature f\u00FCr die sichere Verarbeitung auf \"true\" gesetzt ist."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Pr\u00E4fix f\u00FCr Null-Namespace-URI kann nicht abgerufen werden."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Namespace-URI f\u00FCr Nullpr\u00E4fix kann nicht abgerufen werden."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "Funktionsname darf nicht null sein."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Argumentanzahl darf nicht negativ sein."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "\"}\" gefunden, aber keine Attributvorlage ist ge\u00F6ffnet."}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Warnung: \"count\"-Attribut entspricht keinem Vorg\u00E4nger in xsl:number. Ziel = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Alte Syntax: Der Name des \"expr\"-Attributs wurde in \"select\" ge\u00E4ndert."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan verarbeitet noch nicht den Gebietsschemanamen in der format-number-Funktion."}, + + {WG_LOCALE_NOT_FOUND, + "Warnung: Gebietsschema f\u00FCr xml:lang={0} konnte nicht gefunden werden"}, + + {WG_CANNOT_MAKE_URL_FROM, + "URL kann nicht erstellt werden aus: {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "Angefordertes Dokument kann nicht geladen werden: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "Collator f\u00FCr >>>>>> Xalan-Version "}, + {"version2", "<<<<<<<"}, + {"yes", "Ja"}, + {"line", "Zeilennummer"}, + {"column", "Spaltennummer"}, + {"xsldone", "XSLProcessor: Fertig"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J-Befehlszeile - \"Process\"-Klassenoptionen:"}, + {"xslProc_option", "Xalan-J-Befehlszeile - \"Process\"-Klassenoptionen:"}, + {"xslProc_invalid_xsltc_option", "Option {0} wird im XSLTC-Modus nicht unterst\u00FCtzt."}, + {"xslProc_invalid_xalan_option", "Option {0} kann nur mit -XSLTC verwendet werden."}, + {"xslProc_no_input", "Fehler: Kein Stylesheet und keine Eingabe-XML angegeben. F\u00FChren Sie diesen Befehl ohne Optionen f\u00FCr Verwendungsanweisungen aus."}, + {"xslProc_common_options", "-Allgemeine Optionen-"}, + {"xslProc_xalan_options", "-Optionen f\u00FCr Xalan-"}, + {"xslProc_xsltc_options", "-Optionen f\u00FCr XSLTC-"}, + {"xslProc_return_to_continue", "(dr\u00FCcken Sie die , um fortzufahren)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (XSLTC f\u00FCr Transformation verwenden)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + {"optionE", " [-E (Entityreferenzen nicht einblenden)]"}, + {"optionV", " [-E (Entityreferenzen nicht einblenden)]"}, + {"optionQC", " [-QC (Stille Musterkonfliktwarnungen)]"}, + {"optionQ", " [-Q (Silent-Modus)]"}, + {"optionLF", " [-LF (Nur Zeilenvorsch\u00FCbe bei Ausgabe verwenden {Standard ist CR/LF})]"}, + {"optionCR", " [-CR (Nur Zeilenschaltungen bei Ausgabe verwenden {Standard ist CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Escapezeichen {Standard ist <>&\"'\r\n}]"}, + {"optionINDENT", " [-INDENT (Steuern, wie viele Leerzeichen der Einzug enthalten soll {Standard ist 0})]"}, + {"optionTT", " [-TT (Vorlagen verfolgen, wenn diese aufgerufen werden.)]"}, + {"optionTG", " [-TG (Jedes Generierungsereignis verfolgen.)]"}, + {"optionTS", " [-TS (Jedes Auswahlereignis verfolgen.)]"}, + {"optionTTC", " [-TTC (Untergeordnete Vorlagen verfolgen, wenn diese verarbeitet werden.)]"}, + {"optionTCLASS", " [-TCLASS (TraceListener-Klasse f\u00FCr Traceerweiterungen.)]"}, + {"optionVALIDATE", " [-VALIDATE (Festlegen, ob die Validierung ausgef\u00FChrt wird. Validierung ist standardm\u00E4\u00DFig ausgeschaltet.)]"}, + {"optionEDUMP", " [-EDUMP {optionaler Dateiname} (Stack Dump bei Fehler vornehmen.)]"}, + {"optionXML", " [-XML (XML-Formatter verwenden und XML-Header hinzuf\u00FCgen.)]"}, + {"optionTEXT", " [-TEXT (Einfachen Text-Formatter verwenden.)]"}, + {"optionHTML", " [-HTML (HTML-Formatter verwenden.)]"}, + {"optionPARAM", " [-PARAM name expression (Stylesheet-Parameter festlegen)]"}, + {"noParsermsg1", "XSL-Prozess war nicht erfolgreich."}, + {"noParsermsg2", "** Parser konnte nicht gefunden werden **"}, + {"noParsermsg3", "Pr\u00FCfen Sie den Classpath."}, + {"noParsermsg4", "Wenn Sie nicht \u00FCber den XML-Parser f\u00FCr Java von IBM verf\u00FCgen, k\u00F6nnen Sie ihn hier herunterladen:"}, + {"noParsermsg5", "IBMs AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER full class name (URIResolver f\u00FCr die Aufl\u00F6sung von URIs)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (EntityResolver f\u00FCr die Aufl\u00F6sung von Entitys)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (ContentHandler f\u00FCr die Serialisierung der Ausgabe)]"}, + {"optionLINENUMBERS", " [-L use line numbers for source document]"}, + {"optionSECUREPROCESSING", " [-SECURE (Feature f\u00FCr die sichere Verarbeitung auf \"true\" setzen.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (\"media\"-Attribut verwenden, um mit einem Dokument verkn\u00FCpftes Stylesheet zu finden.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (s2s=SAX oder d2d=DOM explizit f\u00FCr Transformation verwenden.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Gesamtdauer der Transformation in Millisekunden drucken.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (inkrementelle DTM-Konstruktion anfordern, indem http://xml.apache.org/xalan/features/incremental auf \"true\" gesetzt wird.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (keine Stylesheet-Optimierungsverarbeitung anfordern, indem http://xml.apache.org/xalan/features/optimize auf \"false\" gesetzt wird.)]"}, + {"optionRL", " [-RL recursionlimit (numerischen Grenzwert f\u00FCr Stylesheet-Rekursionstiefe bekannt machen.)]"}, + {"optionXO", " [-XO [transletName] (Name dem generierten Translet zuweisen)]"}, + {"optionXD", " [-XD destinationDirectory (Zielverzeichnis f\u00FCr Translet angeben)]"}, + {"optionXJ", " [-XJ jarfile (verpackt Translet-Klassen in einer JAR-Datei mit dem Namen )]"}, + {"optionXP", " [-XP package (gibt ein Packagenamenspr\u00E4fix f\u00FCr alle generierten Translet-Klassen an)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (aktiviert Vorlagen-Inlining)]"}, + {"optionXX", " [-XX (schaltet die zus\u00E4tzliche Debugging-Meldungsausgabe ein)]"}, + {"optionXT", " [-XT (wenn m\u00F6glich, Translet f\u00FCr Transformation verwenden)]"}, + {"diagTiming", " --------- Transformation von {0} \u00FCber {1} dauerte {2} ms"}, + {"recursionTooDeep", "Vorlagenverschachtelung zu tief. Verschachtelung = {0}, Vorlage {1} {2}"}, + {"nameIs", "Name ist"}, + {"matchPatternIs", "Vergleichsmuster ist"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java new file mode 100644 index 0000000..c6399b2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_en.java @@ -0,0 +1,32 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + + +/** + * Default implementation of XSLTErrorResources. This is just + * an empty class. + * + * @xsl.usage advanced + */ +public class XSLTErrorResources_en extends XSLTErrorResources { +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java new file mode 100644 index 0000000..14af5fd --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_es extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Error: no puede haber'{' en la expresi\u00F3n"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} tiene un atributo no permitido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode es nulo en xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "No se puede agregar {0} a {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode es nulo en handleApplyTemplatesInstruction"}, + + {ER_NO_NAME_ATTRIB, + "{0} debe tener un atributo name."}, + + {ER_TEMPLATE_NOT_FOUND, + "No se ha encontrado la plantilla llamada: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "No se ha podido resolver el AVT del nombre en xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} necesita el atributo: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} debe tener un atributo ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valor err\u00F3neo en el atributo level: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "el nombre de instrucci\u00F3n de procesamiento no puede ser 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "el nombre de instrucci\u00F3n de procesamiento debe ser un NCName v\u00E1lido: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} debe tener un atributo match si tiene un modo."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} necesita un atributo name o match."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "No se puede resolver el prefijo de espacio de nombres: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space tiene un valor no permitido: {0}"}, + + {ER_NO_OWNERDOC, + "El nodo secundario no tiene un documento de propietario."}, + + {ER_ELEMTEMPLATEELEM_ERR, + "Error de ElemTemplateElement: {0}"}, + + {ER_NULL_CHILD, + "Intentando agregar un secundario nulo."}, + + {ER_NEED_SELECT_ATTRIB, + "{0} necesita un atributo select."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when debe tener un atributo 'test'."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param debe tener un atributo 'name'."}, + + {ER_NO_CONTEXT_OWNERDOC, + "El contexto no tiene un documento de propietario."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "No se ha podido crear el enlace TransformerFactory XML: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: el proceso no se ha realizado correctamente."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: no se ha realizado correctamente."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Codificaci\u00F3n no soportada: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "No se ha podido crear TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key necesita un atributo 'name'."}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key necesita un atributo 'match'."}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key necesita un atributo 'use'."}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} necesita un atributo ''elements''."}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) Falta el valor de ''prefix'' del atributo {0}"}, + + {ER_BAD_STYLESHEET_URL, + "La URL de hoja de estilo no es v\u00E1lida: {0}"}, + + {ER_FILE_NOT_FOUND, + "No se ha encontrado el archivo de hoja de estilo: {0}"}, + + {ER_IOEXCEPTION, + "Ten\u00EDa una excepci\u00F3n de E/S con el archivo de hoja de estilo: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) No se ha encontrado el atributo href para {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} se incluye directa o indirectamente."}, + + {ER_PROCESSINCLUDE_ERROR, + "Error de StylesheetHandler.processInclude, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) Falta el atributo ''lang'' {0}"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) \u00BFElemento {0} mal colocado? Falta el elemento contenedor ''component''"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "La salida s\u00F3lo puede realizarse en Element, DocumentFragment, Document o PrintWriter."}, + + {ER_PROCESS_ERROR, + "Error de StylesheetRoot.process"}, + + {ER_UNIMPLNODE_ERROR, + "Error de UnImplNode: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "\u00A1Error! No se ha encontrado la expresi\u00F3n de selecci\u00F3n xpath (-select)."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "No se puede serializar un procesador XSL."}, + + {ER_NO_INPUT_STYLESHEET, + "No se ha especificado la entrada de hoja de estilo."}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Fallo al procesar la hoja de estilo."}, + + {ER_COULDNT_PARSE_DOC, + "No se ha podido analizar el documento {0}."}, + + {ER_COULDNT_FIND_FRAGMENT, + "No se ha encontrado el fragmento: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "El nodo apuntado por el identificador de fragmento no era un elemento: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each debe tener un atributo name o match."}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "las plantillas deben tener un atributo name o match."}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "No hay ninguna clonaci\u00F3n de un fragmento de documento."}, + + {ER_CANT_CREATE_ITEM, + "No se puede crear el elemento en el \u00E1rbol de resultados: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space en el XML de origen tiene un valor no v\u00E1lido: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "No hay ninguna declaraci\u00F3n xsl:key para {0}."}, + + {ER_CANT_CREATE_URL, + "Error. No se puede crear la URL para: {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions no est\u00E1 soportado"}, + + {ER_PROCESSOR_ERROR, + "Error de TransformerFactory de XSLT"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} no permitido en una hoja de estilo."}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns ya no est\u00E1 soportado. Utilice xsl:output en su lugar."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space ya no est\u00E1 soportado. Utilice xsl:strip-space o xsl:preserve-space en su lugar."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result ya no est\u00E1 soportado. Utilice xsl:output en su lugar."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} tiene un atributo no permitido: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Elemento XSL desconocido: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort s\u00F3lo se puede utilizar con xsl:apply-templates o xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) ha colocado xsl:when incorrectamente."}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when sin principal de xsl:choose."}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) ha colocado xsl:otherwise de forma incorrecta."}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise sin principal de xsl:choose."}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} no est\u00E1 permitido en una plantilla."}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) prefijo {1} de espacio de nombres de extensi\u00F3n {0} desconocido"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Las importaciones s\u00F3lo se pueden realizar como los primeros elementos en la hoja de estilo."}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} se est\u00E1 importando directa o indirectamente."}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space tiene un valor no permitido: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet no se ha realizado correctamente."}, + + {ER_SAX_EXCEPTION, + "Excepci\u00F3n SAX"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Funci\u00F3n no soportada."}, + + {ER_XSLT_ERROR, + "Error de XSLT"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "el s\u00EDmbolo de moneda no est\u00E1 permitido en la cadena de patr\u00F3n de formato"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "La funci\u00F3n de documento no est\u00E1 soportada en DOM de la hoja de estilo."}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "No se puede resolver el prefijo del sistema de resoluci\u00F3n sin prefijo."}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Extensi\u00F3n de redireccionamiento: no se ha podido obtener el nombre de archivo - el atributo file o select debe devolver una cadena v\u00E1lida."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "No se puede crear FormatterListener en la extensi\u00F3n de redireccionamiento."}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "El prefijo en exclude-result-prefixes no es v\u00E1lido: {0}"}, + + {ER_MISSING_NS_URI, + "Falta el URI del espacio de nombres para el prefijo especificado"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Falta un argumento para la opci\u00F3n: {0}"}, + + {ER_INVALID_OPTION, + "Opci\u00F3n no v\u00E1lida: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Cadena con formato incorrecto: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet necesita un atributo 'version'."}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "El atributo: {0} tiene un valor no permitido: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose necesita un xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports no permitido en un xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "No se puede utilizar un DTMLiaison para un nodo DOM de salida... transfiera com.sun.org.apache.xpath.internal.DOM2Helper en su lugar,"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "No se puede utilizar un DTMLiaison para un nodo DOM de entrada... transfiera com.sun.org.apache.xpath.internal.DOM2Helper en su lugar,"}, + + {ER_CALL_TO_EXT_FAILED, + "Fallo de la llamada al elemento de extensi\u00F3n: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "El prefijo se debe resolver en un espacio de nombres: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "\u00BFSe ha detectado un sustituto UTF-16 no v\u00E1lido: {0}?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} se utiliza a s\u00ED mismo, lo que causar\u00E1 un bucle infinito."}, + + {ER_CANNOT_MIX_XERCESDOM, + "No se puede mezclar una entrada DOM que no es de Xerces con una salida DOM de Xerces."}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "En ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Se ha encontrado m\u00E1s de una plantilla con el nombre: {0}"}, + + {ER_INVALID_KEY_CALL, + "Llamada de funci\u00F3n no v\u00E1lida: las llamadas recursive key() no est\u00E1n permitidas"}, + + {ER_REFERENCING_ITSELF, + "La variable {0} hace referencia a s\u00ED misma de forma directa o indirecta."}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "El nodo de entrada no puede ser nulo para un DOMSource de nuevas plantillas."}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "No se ha encontrado el archivo de clase para la opci\u00F3n {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "No se ha encontrado el elemento necesario: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream no puede ser nulo"}, + + {ER_URI_CANNOT_BE_NULL, + "El URI no puede ser nulo"}, + + {ER_FILE_CANNOT_BE_NULL, + "El archivo no puede ser nulo"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource no puede ser nulo"}, + + {ER_CANNOT_INIT_BSFMGR, + "No se ha podido inicializar el gestor de BSF"}, + + {ER_CANNOT_CMPL_EXTENSN, + "No se ha podido compilar la extensi\u00F3n"}, + + {ER_CANNOT_CREATE_EXTENSN, + "No se ha podido crear la extensi\u00F3n: {0} debido a: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "La llamada del m\u00E9todo de instancia al m\u00E9todo {0} necesita una instancia de objeto como primer argumento"}, + + {ER_INVALID_ELEMENT_NAME, + "Se ha especificado un nombre de elemento no v\u00E1lido {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "El m\u00E9todo del nombre del elemento debe ser est\u00E1tico {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "La funci\u00F3n de extensi\u00F3n {0} : {1} es desconocida"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "Hay m\u00E1s de una mejor coincidencia para el constructor de {0}"}, + + {ER_MORE_MATCH_METHOD, + "Hay m\u00E1s de una mejor coincidencia para el m\u00E9todo {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "Hay m\u00E1s de una mejor coincidencia para el m\u00E9todo de elemento {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Se ha transferido un contexto no v\u00E1lido para evaluar {0}"}, + + {ER_POOL_EXISTS, + "El pool ya existe"}, + + {ER_NO_DRIVER_NAME, + "No se ha especificado ning\u00FAn nombre de controlador"}, + + {ER_NO_URL, + "No se ha especificado ninguna URL"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "El tama\u00F1o del pool es inferior a uno."}, + + {ER_INVALID_DRIVER, + "Se ha especificado un nombre de controlador no v\u00E1lido."}, + + {ER_NO_STYLESHEETROOT, + "No se ha encontrado la ra\u00EDz de la hoja de estilo."}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Valor no permitido para xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "Fallo de processFromNode"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "No se ha podido cargar el recurso [ {0} ]: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Tama\u00F1o de buffer menor o igual que 0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Error desconocido al llamar a la extensi\u00F3n"}, + + {ER_NO_NAMESPACE_DECL, + "El prefijo {0} no tiene una declaraci\u00F3n de espacio de nombres correspondiente"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenido de elemento no permitido para lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Terminaci\u00F3n dirigida de hoja de estilo"}, + + {ER_ONE_OR_TWO, + "1 o 2"}, + + {ER_TWO_OR_THREE, + "2 o 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "No se ha podido cargar {0} (marcar CLASSPATH), actualmente s\u00F3lo se utilizan los valores por defecto"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "No se pueden inicializar las plantillas por defecto"}, + + {ER_RESULT_NULL, + "El resultado no debe ser nulo"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "No se ha podido definir el resultado"}, + + {ER_NO_OUTPUT_SPECIFIED, + "No se ha especificado ninguna salida"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "No se puede transformar en un resultado de tipo {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "No se puede transformar en un origen de tipo {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Manejador de contenido nulo"}, + + {ER_NULL_ERROR_HANDLER, + "Manejador de errores nulo"}, + + {ER_CANNOT_CALL_PARSE, + "no se puede realizar el an\u00E1lisis si no se ha definido el manejador de contenido"}, + + {ER_NO_PARENT_FOR_FILTER, + "Ning\u00FAn principal para el filtro"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "No se ha encontrado ninguna hoja de estilo en: {0}, soporte= {1}"}, + + {ER_NO_STYLESHEET_PI, + "No se ha encontrado ning\u00FAn PI de hoja de estilo XML en: {0}"}, + + {ER_NOT_SUPPORTED, + "No soportado: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "El valor para la propiedad {0} debe ser una instancia booleana"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "No se ha podido obtener un script externo en {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "No se ha encontrado el recurso [ {0} ].\n{1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propiedad de salida no reconocida: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Fallo al crear la instancia ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "El valor para {0} no debe contener un n\u00FAmero que pueda analizarse"}, + + {ER_VALUE_SHOULD_EQUAL, + "El valor para {0} debe ser igual a s\u00ED o no."}, + + {ER_FAILED_CALLING_METHOD, + "Fallo al llamar al m\u00E9todo {0}"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Fallo al crear la instancia ElemTemplateElement"}, + + {ER_CHARS_NOT_ALLOWED, + "En este momento, no se permite el uso de caracteres en el documento"}, + + {ER_ATTR_NOT_ALLOWED, + "El atributo \"{0}\" no est\u00E1 permitido en el elemento {1}."}, + + {ER_BAD_VALUE, + "{0} valor incorrecto {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "No se ha encontrado el valor del atributo {0} "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "El valor del atributo {0} no se ha reconocido "}, + + {ER_NULL_URI_NAMESPACE, + "Se est\u00E1 intentando generar un prefijo de espacio de nombres con un URI nulo"}, + + {ER_NUMBER_TOO_BIG, + "Se est\u00E1 intentando formatear un n\u00FAmero superior al entero largo m\u00E1s grande"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "No se ha encontrado la clase de controlador SAX1 {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "Se ha encontrado la clase de controlador SAX1 {0} pero no se puede cargar"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "Se ha cargado la clase de controlador SAX1 {0} pero no se puede instanciar"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La clase de controlador SAX1 {0} no implanta org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "No se ha especificado la propiedad del sistema org.xml.sax.parser"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "El argumento del analizador no debe ser nulo"}, + + {ER_FEATURE, + "Funci\u00F3n: {0}"}, + + {ER_PROPERTY, + "Propiedad: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Sistema de resoluci\u00F3n de entidades nulo"}, + + {ER_NULL_DTD_HANDLER, + "Manejador DTD nulo"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "No se ha especificado ning\u00FAn nombre de controlador"}, + + {ER_NO_URL_SPECIFIED, + "No se ha especificado ninguna URL"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "El tama\u00F1o del pool es inferior a 1."}, + + {ER_INVALID_DRIVER_NAME, + "Se ha especificado un nombre de controlador no v\u00E1lido."}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Error del programador. La expresi\u00F3n no tiene el principal ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Afirmaci\u00F3n del programador en RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} no est\u00E1 permitido en esta posici\u00F3n de la hoja de estilo."}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "El texto distinto de un espacio en blanco no est\u00E1 permitido en esta posici\u00F3n de la hoja de estilo."}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Valor no permitido: {1} utilizado para el atributo CHAR: {0}. Un atributo del tipo CHAR debe tener s\u00F3lo 1 car\u00E1cter."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Valor no permitido: {1} utilizado para el atributo QNAME: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Valor no permitido: {1} utilizado para el atributo ENUM: {0}. Los valores v\u00E1lidos son: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Valor no permitido: {1} utilizado para el atributo NMTOKEN: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Valor no permitido: {1} utilizado para el atributo NCNAME: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Valor no permitido: {1} utilizado para el atributo boolean: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Valor no permitido: {1} utilizado para el atributo number: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "El argumento para {0} en el patr\u00F3n de coincidencia no debe ser un valor literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Duplicar declaraci\u00F3n de variable global."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Duplicar declaraci\u00F3n de variable."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template debe tener un atributo name o match (o ambos)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "El prefijo en exclude-result-prefixes no es v\u00E1lido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "El juego de atributos con el nombre {0} no existe"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "La funci\u00F3n con el nombre {0} no existe"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "El elemento {0} no debe tener contenido ni un atributo select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "El valor del par\u00E1metro {0} debe tener un objeto Java v\u00E1lido"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "El atributo result-prefix de un elemento xsl:namespace-alias tiene el valor ''#default', pero no hay ninguna declaraci\u00F3n del espacio de nombres por defecto en el \u00E1mbito para el elemento"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "El atributo result-prefix de un elemento xsl:namespace-alias tiene el valor ''{0}'', pero no hay ninguna declaraci\u00F3n del espacio de nombres para el prefijo ''{0}'' en el \u00E1mbito para el elemento."}, + + {ER_SET_FEATURE_NULL_NAME, + "El nombre de funci\u00F3n no puede ser nulo en TransformerFactory.setFeature (nombre de cadena, valor booleano)."}, + + {ER_GET_FEATURE_NULL_NAME, + "El nombre de funci\u00F3n no puede ser nulo en TransformerFactory.getFeature (nombre de cadena)."}, + + {ER_UNSUPPORTED_FEATURE, + "No se puede definir la funci\u00F3n ''{0}''en esta f\u00E1brica del transformador."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "La utilizaci\u00F3n del elemento de extensi\u00F3n ''{0}'' no est\u00E1 permitida cuando la funci\u00F3n de procesamiento seguro se ha definido en true."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "No se puede obtener el prefijo para un URI de espacio de nombres nulo."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "No se puede obtener el URI de espacio de nombres para un prefijo nulo."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "El nombre de la funci\u00F3n no puede ser nulo."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "El n\u00FAmero de argumentos no puede ser negativo."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "Se han encontrado '}' pero no hay ninguna plantilla de atributos abierta."}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Advertencia: el atributo count no coincide con un ascendiente en el destino xsl:number! = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintaxis anterior: el nombre del atributo 'expr' se ha cambiado por el de 'select'."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan no maneja a\u00FAn el nombre de configuraci\u00F3n regional en la funci\u00F3n format-number."}, + + {WG_LOCALE_NOT_FOUND, + "Advertencia: no se ha encontrado la configuraci\u00F3n regional para xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "No se puede crear la URL desde: {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "No se puede cargar el documento solicitado: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "No se ha encontrado el intercalador para >>>>>> Versi\u00F3n Xalan "}, + {"version2", "<<<<<<<"}, + {"yes", "s\u00ED"}, + {"line", "N\u00BA de L\u00EDnea"}, + {"column", "N\u00BA de Columna"}, + {"xsldone", "XSLProcessor: listo"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Opciones de la clase Process de la l\u00EDnea de comandos Xalan-J :"}, + {"xslProc_option", "Opciones de la clase Process de la l\u00EDnea de comandos Xalan-J :"}, + {"xslProc_invalid_xsltc_option", "La opci\u00F3n {0} no est\u00E1 soportada en el modo XSLTC."}, + {"xslProc_invalid_xalan_option", "La opci\u00F3n {0} s\u00F3lo puede utilizarse con -XSLTC."}, + {"xslProc_no_input", "Error: no se ha especificado ninguna hoja de estilo o XML de entrada. Ejecute este comando sin ninguna opci\u00F3n para las instrucciones de uso."}, + {"xslProc_common_options", "-Opciones Comunes-"}, + {"xslProc_xalan_options", "-Opciones para Xalan-"}, + {"xslProc_xsltc_options", "-Opciones para XSLTC-"}, + {"xslProc_return_to_continue", "(pulse para continuar)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (utilizar XSLTC para la transformaci\u00F3n)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER nombre de clase totalmente cualificado de enlace de analizador]"}, + {"optionE", " [-E (No ampliar referencias de entidad)]"}, + {"optionV", " [-E (No ampliar referencias de entidad)]"}, + {"optionQC", " [-QC (Advertencias de Conflictos de Patr\u00F3n Silencioso)]"}, + {"optionQ", " [-Q (Modo Silencioso)]"}, + {"optionLF", " [-LF (Utilizar saltos de l\u00EDnea s\u00F3lo en la salida {el valor por defecto es CR/LF})]"}, + {"optionCR", " [-CR (Utilizar retornos de carro s\u00F3lo en la salida {el valor por defecto es CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Caracteres para introducir escape {el valor por defecto es <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (Control del n\u00FAmero de espacios para el sangrado {el valor por defecto es 0})]"}, + {"optionTT", " [-TT (Rastrear las plantillas como si se estuviesen llamando.)]"}, + {"optionTG", " [-TG (Rastrear cada evento de generaci\u00F3n.)]"}, + {"optionTS", " [-TS (Rastrear cada evento de selecci\u00F3n.)]"}, + {"optionTTC", " [-TTC (Rastrear los secundarios de plantilla como si se estuviesen procesando.)]"}, + {"optionTCLASS", " [-TCLASS (Clase TraceListener para las extensiones de rastreo.)]"}, + {"optionVALIDATE", " [-VALIDATE (Determinar si se produce la validaci\u00F3n. La validaci\u00F3n est\u00E1 desactivada por defecto.)]"}, + {"optionEDUMP", " [-EDUMP {nombre de archivo opcional} (Realizar volcado de pila si se produce el error.)]"}, + {"optionXML", " [-XML (Utilizar el formateador XML y agregar una cabecera XML.)]"}, + {"optionTEXT", " [-TEXT (Utilizar el formateador de texto simple.)]"}, + {"optionHTML", " [-HTML (Utilizar el formateador HTML.)]"}, + {"optionPARAM", " [-PARAM expresi\u00F3n de nombre (Definir un par\u00E1metro de hoja de estilo)]"}, + {"noParsermsg1", "El proceso XSL no se ha realizado correctamente."}, + {"noParsermsg2", "** No se ha encontrado el analizador **"}, + {"noParsermsg3", "Compruebe la classpath."}, + {"noParsermsg4", "Si no tiene un analizador XML de IBM para Java, puede descargarlo de"}, + {"noParsermsg5", "AlphaWorks de IBM: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER nombre de clase completo (URIResolver se puede utilizar para resolver los URI)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER nombre de clase completo (EntityResolver utilizado para resolver entidades)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER nombre de clase completo (ContentHandler utilizado para serializar la salida)]"}, + {"optionLINENUMBERS", " [-L utilizar n\u00FAmeros de l\u00EDnea para el documento de origen]"}, + {"optionSECUREPROCESSING", " [-SECURE (definir la funci\u00F3n de procesamiento seguro en true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (utilice el atributo media para buscar la hoja de estilo asociada a un documento.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (Utilizar expl\u00EDcitamente s2s=SAX o d2d=DOM para realizar la transformaci\u00F3n.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Imprimir tiempo total en milisegundos para la transformaci\u00F3n.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (para solicitar la construcci\u00F3n DTM incremental, defina http://xml.apache.org/xalan/features/incremental en true.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (para solicitar que no se produzca ning\u00FAn procesamiento de optimizaci\u00F3n de hoja de estilo, defina http://xml.apache.org/xalan/features/optimize en false.)]"}, + {"optionRL", " [-RL recursionlimit (afirmar l\u00EDmite num\u00E9rico en la profundidad de recursi\u00F3n de la hoja de estilo.)]"}, + {"optionXO", " [-XO [transletName] (asignar el nombre al translet generado)]"}, + {"optionXD", " [-XD destinationDirectory (especificar un directorio de destino para translet)]"}, + {"optionXJ", " [-XJ jarfile (empaqueta las clases de translet en un archivo jar llamado )]"}, + {"optionXP", " [-XP package (especifica un prefijo de nombre de paquete para todas las clases de translet generadas)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (permite poner en l\u00EDnea la plantilla)]"}, + {"optionXX", " [-XX (activa una salida de mensaje de depuraci\u00F3n adicional)]"}, + {"optionXT", " [-XT (utilizar translet para la transformaci\u00F3n si es posible)]"}, + {"diagTiming", " --------- La transformaci\u00F3n de {0} mediante {1} ha tardado {2} ms"}, + {"recursionTooDeep", "El anidamiento de plantilla es demasiado profundo. Anidamiento = {0}, plantilla {1} {2}"}, + {"nameIs", "el nombre es"}, + {"matchPatternIs", "el patr\u00F3n de coincidencia es"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java new file mode 100644 index 0000000..71e8961 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_fr extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Erreur : l'expression ne peut pas contenir le caract\u00E8re '{'"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} a un attribut non admis : {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "La valeur de sourceNode est NULL dans xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "Impossible d''ajouter {0} \u00E0 {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "La valeur de sourceNode est NULL dans handleApplyTemplatesInstruction."}, + + {ER_NO_NAME_ATTRIB, + "{0} doit avoir un attribut ''name''."}, + + {ER_TEMPLATE_NOT_FOUND, + "Mod\u00E8le nomm\u00E9 {0} introuvable"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Impossible de r\u00E9soudre le nom AVT dans xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} exige l''attribut : {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} doit avoir un attribut ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valeur incorrecte sur l''attribut de niveau : {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "Le nom de processing-instruction ne peut pas \u00EAtre 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "Le nom de processing-instruction doit \u00EAtre un NCName valide : {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} doit avoir un attribut de correspondance s''il a un mode."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} exige un nom ou un attribut de correspondance."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Impossible de r\u00E9soudre le pr\u00E9fixe de l''espace de noms : {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space a une valeur non admise : {0}"}, + + {ER_NO_OWNERDOC, + "Le noeud enfant ne poss\u00E8de pas de document propri\u00E9taire."}, + + {ER_ELEMTEMPLATEELEM_ERR, + "Erreur ElemTemplateElement : {0}"}, + + {ER_NULL_CHILD, + "Tentative d'ajout d'un enfant NULL."}, + + {ER_NEED_SELECT_ATTRIB, + "{0} exige un attribut \"select\"."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when doit avoir un attribut \"test\"."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param doit avoir un attribut \"name\"."}, + + {ER_NO_CONTEXT_OWNERDOC, + "le contexte ne poss\u00E8de pas de document propri\u00E9taire."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Impossible de cr\u00E9er la liaison XML?? TransformerFactory : {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan : le processus a \u00E9chou\u00E9."}, + + {ER_NOT_SUCCESSFUL, + "Xalan : \u00E9chec."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Encodage non pris en charge : {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Impossible de cr\u00E9er TraceListener : {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key exige un attribut \"name\"."}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key exige un attribut \"match\"."}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key exige un attribut \"use\"."}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} exige un attribut ''elements''."}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) L''attribut ''prefix'' {0} est manquant"}, + + {ER_BAD_STYLESHEET_URL, + "L''URL de feuille de style est incorrecte : {0}"}, + + {ER_FILE_NOT_FOUND, + "Fichier de feuille de style introuvable : {0}"}, + + {ER_IOEXCEPTION, + "Exception d''E/S avec le fichier de feuille de style : {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Attribut href introuvable pour {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} s''inclut directement ou indirectement lui-m\u00EAme."}, + + {ER_PROCESSINCLUDE_ERROR, + "Erreur StylesheetHandler.processInclude, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) L''attribut \"lang\" {0} est manquant"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) l''\u00E9l\u00E9ment {0} est-il mal plac\u00E9? El\u00E9ment ''component'' du conteneur manquant"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Sortie unique vers Element, DocumentFragment, Document ou PrintWriter."}, + + {ER_PROCESS_ERROR, + "Erreur StylesheetRoot.process"}, + + {ER_UNIMPLNODE_ERROR, + "Erreur UnImplNode : {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Erreur : expression de s\u00E9lection Xpath introuvable (-select)."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Impossible de s\u00E9rialiser un processeur XSL."}, + + {ER_NO_INPUT_STYLESHEET, + "L'entr\u00E9e de feuille de style n'a pas \u00E9t\u00E9 sp\u00E9cifi\u00E9e."}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Echec du traitement de la feuille de style."}, + + {ER_COULDNT_PARSE_DOC, + "Impossible d''analyser le document {0}."}, + + {ER_COULDNT_FIND_FRAGMENT, + "Fragment introuvable : {0}"}, + + {ER_NODE_NOT_ELEMENT, + "Le noeud sur lequel pointe l''identificateur de fragment n''\u00E9tait pas un \u00E9l\u00E9ment : {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "l'\u00E9l\u00E9ment for-each doit avoir un attribut de nom ou de correspondance"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "les mod\u00E8les doivent avoir un attribut de nom ou de correspondance"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Aucun clone d'un fragment de document."}, + + {ER_CANT_CREATE_ITEM, + "Impossible de cr\u00E9er l''\u00E9l\u00E9ment dans l''arborescence de r\u00E9sultats : {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space dans le fichier XML source a une valeur non admise : {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "Il n''existe aucune d\u00E9claration xsl:key pour {0}."}, + + {ER_CANT_CREATE_URL, + "Erreur : impossible de cr\u00E9er l''URL pour : {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions n'est pas pris en charge"}, + + {ER_PROCESSOR_ERROR, + "Erreur TransformerFactory XSLT"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} non autoris\u00E9 dans une feuille de style."}, + + {ER_RESULTNS_NOT_SUPPORTED, + "\u00E9l\u00E9ment result-ns plus pris en charge. Utilisez plut\u00F4t xsl:output."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u00E9l\u00E9ment default-space plus pris en charge. Utilisez plut\u00F4t xsl:strip-space ou xsl:preserve-space."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "\u00E9l\u00E9ment indent-result plus pris en charge. Utilisez plut\u00F4t xsl:output."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} a un attribut non admis : {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "El\u00E9ment XSL inconnu : {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort ne peut \u00EAtre utilis\u00E9 qu'avec xsl:apply-templates ou xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when mal plac\u00E9."}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:choose n'a affect\u00E9 aucun parent \u00E0 xsl:when."}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise mal plac\u00E9."}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:choose n'a affect\u00E9 aucun parent \u00E0 xsl:otherwise."}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} n''est pas autoris\u00E9 dans un mod\u00E8le."}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) Pr\u00E9fixe {1} de l''espace de noms de l''extension {0} inconnu"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Les imports ne peuvent s'appliquer que sur les premiers \u00E9l\u00E9ments de la feuille de style."}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} s''importe directement ou indirectement lui-m\u00EAme."}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space a une valeur non admise : {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "Echec de processStylesheet."}, + + {ER_SAX_EXCEPTION, + "Exception SAX"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Fonction non prise en charge."}, + + {ER_XSLT_ERROR, + "Erreur XSLT"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "le symbole de devise n'est pas autoris\u00E9 dans la cha\u00EEne du mod\u00E8le de format"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Fonction de document non prise en charge dans l'objet DOM de la feuille de style."}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Impossible de r\u00E9soudre le pr\u00E9fixe du r\u00E9solveur non-Prefix."}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Extension Redirect : impossible d'obtenir le nom de fichier. L'attribut \"file\" ou \"select\" doit renvoyer une cha\u00EEne valide."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Impossible de cr\u00E9er FormatterListener dans l'extension Redirect."}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Le pr\u00E9fixe de l''\u00E9l\u00E9ment exclude-result-prefixes n''est pas valide : {0}"}, + + {ER_MISSING_NS_URI, + "URI d'espace de noms manquant pour le pr\u00E9fixe sp\u00E9cifi\u00E9"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Argument manquant pour l''option : {0}"}, + + {ER_INVALID_OPTION, + "Option non valide : {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Format de cha\u00EEne incorrect : {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet exige un attribut de version."}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "L''attribut {0} a une valeur non admise : {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose exige un \u00E9l\u00E9ment xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports non autoris\u00E9 dans un \u00E9l\u00E9ment xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "Impossible d'utiliser un \u00E9l\u00E9ment DTMLiaison pour un noeud DOM de sortie... Transmettez plut\u00F4t un \u00E9l\u00E9ment com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "Impossible d'utiliser un \u00E9l\u00E9ment DTMLiaison pour un noeud DOM d'entr\u00E9e... Transmettez plut\u00F4t un \u00E9l\u00E9ment com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CALL_TO_EXT_FAILED, + "Echec de l''appel de l''\u00E9l\u00E9ment d''extension : {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "Le pr\u00E9fixe doit \u00EAtre r\u00E9solu en espace de noms : {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Substitut UTF-16 non valide d\u00E9tect\u00E9 : {0} ?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} s''est utilis\u00E9 lui-m\u00EAme, ce qui g\u00E9n\u00E8re une boucle sans fin."}, + + {ER_CANNOT_MIX_XERCESDOM, + "Impossible de combiner une entr\u00E9e non Xerces-DOM et une sortie Xerces-DOM."}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "Dans ElemTemplateElement.readObject : {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Plusieurs mod\u00E8les nomm\u00E9s {0} ont \u00E9t\u00E9 trouv\u00E9s"}, + + {ER_INVALID_KEY_CALL, + "Appel de fonction non valide : les appels de touche r\u00E9cursive () ne sont pas autoris\u00E9s"}, + + {ER_REFERENCING_ITSELF, + "La variable {0} fait directement ou indirectement r\u00E9f\u00E9rence \u00E0 elle-m\u00EAme."}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "Le noeud d'entr\u00E9e ne peut pas \u00EAtre NULL pour un \u00E9l\u00E9ment DOMSource de newTemplates."}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "Fichier de classe introuvable pour l''option {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "El\u00E9ment obligatoire introuvable : {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream ne peut pas \u00EAtre NULL"}, + + {ER_URI_CANNOT_BE_NULL, + "L'URI ne peut pas \u00EAtre NULL"}, + + {ER_FILE_CANNOT_BE_NULL, + "Le fichier ne peut pas \u00EAtre NULL"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource ne peut pas \u00EAtre NULL"}, + + {ER_CANNOT_INIT_BSFMGR, + "Impossible d'initialiser le gestionnaire BSF"}, + + {ER_CANNOT_CMPL_EXTENSN, + "Impossible de compiler l'extension"}, + + {ER_CANNOT_CREATE_EXTENSN, + "Impossible de cr\u00E9er l''extension {0}. Cause : {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "L''appel de la m\u00E9thode d''instance {0} exige une instance d''objet comme premier argument"}, + + {ER_INVALID_ELEMENT_NAME, + "Nom d''\u00E9l\u00E9ment sp\u00E9cifi\u00E9 {0} non valide"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "La m\u00E9thode du nom d''\u00E9l\u00E9ment doit \u00EAtre statique {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "La fonction d''extension {0} : {1} est inconnue"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "Plusieurs meilleures concordances du constructeur pour {0}"}, + + {ER_MORE_MATCH_METHOD, + "Plusieurs meilleures concordances pour la m\u00E9thode {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "Plusieurs meilleures concordances pour la m\u00E9thode d''\u00E9l\u00E9ment {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Contexte transmis pour \u00E9valuation {0} non valide"}, + + {ER_POOL_EXISTS, + "Le pool existe d\u00E9j\u00E0"}, + + {ER_NO_DRIVER_NAME, + "Aucun nom de pilote indiqu\u00E9"}, + + {ER_NO_URL, + "Aucune URL indiqu\u00E9e"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "La taille de pool est inf\u00E9rieure \u00E0 1."}, + + {ER_INVALID_DRIVER, + "Nom de pilote indiqu\u00E9 non valide."}, + + {ER_NO_STYLESHEETROOT, + "Racine de la feuille de style introuvable."}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Valeur non admise pour xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "Echec de processFromNode"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "La ressource [ {0} ] n''a pas pu charger : {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Taille du tampon <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Erreur inconnue lors de l'appel de l'extension"}, + + {ER_NO_NAMESPACE_DECL, + "Le pr\u00E9fixe {0} n''a pas de d\u00E9claration d''espace de noms correspondante"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenu d''\u00E9l\u00E9ment non autoris\u00E9 pour lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Fin du r\u00E9acheminement de la feuille de style"}, + + {ER_ONE_OR_TWO, + "1 ou 2"}, + + {ER_TWO_OR_THREE, + "2 ou 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "Impossible de charger {0} (v\u00E9rifier CLASSPATH), les valeurs par d\u00E9faut sont donc employ\u00E9es"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Impossible d'initialiser les mod\u00E8les default"}, + + {ER_RESULT_NULL, + "Le r\u00E9sultat ne doit pas \u00EAtre NULL"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "Le r\u00E9sultat n'a pas pu \u00EAtre d\u00E9fini"}, + + {ER_NO_OUTPUT_SPECIFIED, + "Aucune sortie sp\u00E9cifi\u00E9e"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Impossible de transformer le r\u00E9sultat en r\u00E9sultat de type {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Impossible de transformer une source de type {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Gestionnaire de contenu NULL"}, + + {ER_NULL_ERROR_HANDLER, + "Gestionnaire d'erreurs NULL"}, + + {ER_CANNOT_CALL_PARSE, + "impossible d'appeler l'analyse si le gestionnaire de contenu n'est pas d\u00E9fini"}, + + {ER_NO_PARENT_FOR_FILTER, + "Aucun parent pour le filtre"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "Aucune feuille de style trouv\u00E9e dans : {0}, support = {1}"}, + + {ER_NO_STYLESHEET_PI, + "Aucune instruction de traitement (PI) xml-stylesheet trouv\u00E9e dans : {0}"}, + + {ER_NOT_SUPPORTED, + "Non pris en charge : {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "La valeur de la propri\u00E9t\u00E9 {0} doit \u00EAtre une instance Boolean"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Impossible d''acc\u00E9der au script externe \u00E0 {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "La ressource [ {0} ] est introuvable.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propri\u00E9t\u00E9 de sortie non reconnue : {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Echec de la cr\u00E9ation de l'instance ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "La valeur de {0} doit contenir un nombre pouvant \u00EAtre analys\u00E9"}, + + {ER_VALUE_SHOULD_EQUAL, + "La valeur de {0} doit \u00EAtre \u00E9gale \u00E0 oui ou non"}, + + {ER_FAILED_CALLING_METHOD, + "Echec de l''appel de la m\u00E9thode {0}"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Echec de la cr\u00E9ation de l'instance ElemTemplateElement"}, + + {ER_CHARS_NOT_ALLOWED, + "Les caract\u00E8res ne sont pas autoris\u00E9s \u00E0 ce point du document"}, + + {ER_ATTR_NOT_ALLOWED, + "L''attribut \"{0}\" n''est pas autoris\u00E9 sur l''\u00E9l\u00E9ment {1}."}, + + {ER_BAD_VALUE, + "Valeur incorrecte de {0} : {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "Valeur d''attribut {0} introuvable "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Valeur d''attribut {0} non reconnue "}, + + {ER_NULL_URI_NAMESPACE, + "Tentative de g\u00E9n\u00E9ration d'un pr\u00E9fixe d'espace de noms avec un URI NULL"}, + + {ER_NUMBER_TOO_BIG, + "Tentative de formatage d'un nombre sup\u00E9rieur \u00E0 l'entier de type Long le plus grand"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "Classe de pilote SAX1 {0} introuvable"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "Classe de pilote SAX1 {0} trouv\u00E9e mais pas charg\u00E9e"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "Classe de pilote SAX1 {0} charg\u00E9e mais pas instanci\u00E9e"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La classe de pilote SAX1 {0} n''impl\u00E9mente pas org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Propri\u00E9t\u00E9 syst\u00E8me org.xml.sax.parser non indiqu\u00E9e"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "L'argument d'analyseur ne doit pas \u00EAtre NULL"}, + + {ER_FEATURE, + "Fonctionnalit\u00E9 : {0}"}, + + {ER_PROPERTY, + "Propri\u00E9t\u00E9 : {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "R\u00E9solveur d'entit\u00E9 NULL"}, + + {ER_NULL_DTD_HANDLER, + "Gestionnaire DTD NULL"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "Aucun nom de pilote indiqu\u00E9."}, + + {ER_NO_URL_SPECIFIED, + "Aucune URL indiqu\u00E9e."}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "La taille de pool est inf\u00E9rieure \u00E0 1."}, + + {ER_INVALID_DRIVER_NAME, + "Nom de pilote indiqu\u00E9 non valide."}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Erreur du programmeur. L'expression n'a pas de parent ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Assertion du programmeur dans RedundentExprEliminator : {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} n''est pas autoris\u00E9 \u00E0 cet emplacement de la feuille de style."}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Le texte imprimable n'est pas autoris\u00E9 \u00E0 cet emplacement de la feuille de style."}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Valeur non admise {1} utilis\u00E9e pour l''attribut CHAR : {0}. Un attribut de type CHAR ne doit \u00EAtre compos\u00E9 que d''un caract\u00E8re."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Valeur non admise {1} utilis\u00E9e pour l''attribut QNAME : {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Valeur non admise {1} utilis\u00E9e pour l''attribut ENUM : {0}. Les valeurs valides sont les suivantes : {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Valeur non admise {1} utilis\u00E9e pour l''attribut NMTOKEN : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Valeur non admise {1} utilis\u00E9e pour l''attribut NCNAME : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Valeur non admise {1} utilis\u00E9e pour l''attribut \"boolean\" : {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Valeur non admise {1} utilis\u00E9e pour l''attribut \"number\" : {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "L''argument pour {0} dans le mod\u00E8le de recherche doit \u00EAtre un litt\u00E9ral."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "D\u00E9claration de variable globale en double."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "D\u00E9claration de variable en double."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template doit avoir un attribut \"name\" ou \"match\" (ou les deux)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "Le pr\u00E9fixe de l''\u00E9l\u00E9ment exclude-result-prefixes n''est pas valide : {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "L''ensemble d''attributs nomm\u00E9 {0} n''existe pas"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "La fonction nomm\u00E9e {0} n''existe pas"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "L''\u00E9l\u00E9ment {0} ne doit pas avoir \u00E0 la fois un attribut \"select\" et un attribut de contenu."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "La valeur du param\u00E8tre {0} doit \u00EAtre un objet Java valide"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "L'attribut result-prefix d'un \u00E9l\u00E9ment xsl:namespace-alias a la valeur \"#default\", mais il n'existe aucune d\u00E9claration de l'espace de noms par d\u00E9faut dans la port\u00E9e pour l'\u00E9l\u00E9ment"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "L''attribut result-prefix d''un \u00E9l\u00E9ment xsl:namespace-alias a la valeur ''{0}'', mais il n''existe aucune d\u00E9claration d''espace de noms pour le pr\u00E9fixe ''{0}'' dans la port\u00E9e pour l''\u00E9l\u00E9ment."}, + + {ER_SET_FEATURE_NULL_NAME, + "Le nom de la fonctionnalit\u00E9 ne peut pas \u00EAtre NULL dans TransformerFactory.setFeature (cha\u00EEne pour le nom, valeur bool\u00E9enne)."}, + + {ER_GET_FEATURE_NULL_NAME, + "Le nom de la fonctionnalit\u00E9 ne peut pas \u00EAtre NULL dans TransformerFactory.getFeature (cha\u00EEne pour le nom)."}, + + {ER_UNSUPPORTED_FEATURE, + "Impossible de d\u00E9finir la fonctionnalit\u00E9 ''{0}'' sur cette propri\u00E9t\u00E9 TransformerFactory."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "L''utilisation de l''\u00E9l\u00E9ment d''extension ''{0}'' n''est pas autoris\u00E9e lorsque la fonctionnalit\u00E9 de traitement s\u00E9curis\u00E9 est d\u00E9finie sur True."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Impossible d'obtenir le pr\u00E9fixe pour un URI d'espace de noms NULL."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Impossible d'obtenir l'URI d'espace de noms pour le pr\u00E9fixe NULL."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "Le nom de fonction ne peut pas \u00EAtre NULL."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "L'arit\u00E9 ne peut pas \u00EAtre n\u00E9gative."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "'}' trouv\u00E9 mais aucun mod\u00E8le d'attribut ouvert."}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Avertissement : l''attribut \"count\" ne correspond pas \u00E0 un anc\u00EAtre dans xsl:number ! Cible = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Ancienne syntaxe : le nom de l'attribut \"expr\" a \u00E9t\u00E9 modifi\u00E9 en \"select\"."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan ne g\u00E8re pas encore le nom de l'environnement local dans la fonction format-number."}, + + {WG_LOCALE_NOT_FOUND, + "Avertissement : environnement local introuvable pour xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "Impossible de cr\u00E9er une URL \u00E0 partir de : {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "Impossible de charger le document demand\u00E9 : {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "Collator introuvable pour >>>>>> Version Xalan "}, + {"version2", "<<<<<<<"}, + {"yes", "oui"}, + {"line", "Ligne n\u00B0"}, + {"column", "Colonne n\u00B0"}, + {"xsldone", "XSLProcessor : termin\u00E9"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Options de classe \"Process\" de ligne de commande Xalan-J :"}, + {"xslProc_option", "Options de classe \"Process\" de ligne de commande Xalan-J :"}, + {"xslProc_invalid_xsltc_option", "L''option {0} n''est pas prise en charge dans le mode XSLTC."}, + {"xslProc_invalid_xalan_option", "L''option {0} ne peut \u00EAtre utilis\u00E9e qu''avec -XSLTC."}, + {"xslProc_no_input", "Erreur : aucune feuille de style ou aucun fichier XML d'entr\u00E9e n'est sp\u00E9cifi\u00E9. Ex\u00E9cutez cette commande sans option concernant les instructions d'utilisation."}, + {"xslProc_common_options", "-Options communes-"}, + {"xslProc_xalan_options", "-Options pour Xalan-"}, + {"xslProc_xsltc_options", "-Options pour XSLTC-"}, + {"xslProc_return_to_continue", "(appuyez sur la touche pour continuer)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (utiliser XSLTC pour la transformation)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [Nom de classe qualifi\u00E9 complet -PARSER de liaison d'analyseur]"}, + {"optionE", " [-E (Ne pas d\u00E9velopper les r\u00E9f\u00E9rences d'entit\u00E9)]"}, + {"optionV", " [-E (Ne pas d\u00E9velopper les r\u00E9f\u00E9rences d'entit\u00E9)]"}, + {"optionQC", " [-QC (Avertissements de conflits de mod\u00E8les en mode silencieux)]"}, + {"optionQ", " [-Q (Mode silencieux)]"}, + {"optionLF", " [-LF (Utiliser les retours \u00E0 la ligne uniquement en sortie {valeur par d\u00E9faut : CR/LF})]"}, + {"optionCR", " [-CR (Utiliser les retours chariot uniquement en sortie {valeur par d\u00E9faut : CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Avec caract\u00E8res d'espacement {valeur par d\u00E9faut : <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (Contr\u00F4ler le nombre d'espaces \u00E0 mettre en retrait {valeur par d\u00E9faut : 0})]"}, + {"optionTT", " [-TT (G\u00E9n\u00E9rer une trace des mod\u00E8les pendant qu'ils sont appel\u00E9s.)]"}, + {"optionTG", " [-TG (G\u00E9n\u00E9rer une trace de chaque \u00E9v\u00E9nement de g\u00E9n\u00E9ration.)]"}, + {"optionTS", " [-TS (G\u00E9n\u00E9rer une trace de chaque \u00E9v\u00E9nement de s\u00E9lection.)]"}, + {"optionTTC", " [-TTC (G\u00E9n\u00E9rer une trace des enfants de mod\u00E8le pendant qu'ils sont trait\u00E9s.)]"}, + {"optionTCLASS", " [-TCLASS (Classe TraceListener pour les extensions de trace.)]"}, + {"optionVALIDATE", " [-VALIDATE (D\u00E9finir si la validation est effectu\u00E9e. Par d\u00E9faut, la validation est d\u00E9sactiv\u00E9e.)]"}, + {"optionEDUMP", " [-EDUMP {nom de fichier facultatif} (Effectuer le vidage de la pile sur l'erreur.)]"}, + {"optionXML", " [-XML (Utiliser le programme de formatage XML et ajouter un en-t\u00EAte XML.)]"}, + {"optionTEXT", " [-TEXT (Utiliser le formatage de texte simple.)]"}, + {"optionHTML", " [-HTML (Utiliser le formatage HTML.)]"}, + {"optionPARAM", " [-PARAM Expression de nom (D\u00E9finir un param\u00E8tre de feuille de style)]"}, + {"noParsermsg1", "Echec du processus XSL."}, + {"noParsermsg2", "** Analyseur introuvable **"}, + {"noParsermsg3", "V\u00E9rifiez votre variable d'environnement CLASSPATH."}, + {"noParsermsg4", "Si vous ne disposez pas de l'analyseur XML pour Java d'IBM, vous pouvez le t\u00E9l\u00E9charger sur le site"}, + {"noParsermsg5", "AlphaWorks d'IBM : http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER Nom de classe complet (URIResolver \u00E0 utiliser pour r\u00E9soudre les URI)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER Nom de classe complet (EntityResolver \u00E0 utiliser pour r\u00E9soudre les entit\u00E9s)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER Nom de classe complet (ContentHandler \u00E0 utiliser pour s\u00E9rialiser la sortie)]"}, + {"optionLINENUMBERS", " [-L Utiliser les num\u00E9ros de ligne pour le document source]"}, + {"optionSECUREPROCESSING", " [-SECURE (D\u00E9finir la fonctionnalit\u00E9 de traitement s\u00E9curis\u00E9 sur True)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (Utiliser l'attribut de support pour trouver la feuille de style associ\u00E9e \u00E0 un document)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (Utiliser explicitement s2s=SAX ou d2d=DOM pour effectuer la transformation)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Afficher la dur\u00E9e totale de la transformation, en millisecondes)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (Demander la construction DTM incr\u00E9mentielle en d\u00E9finissant http://xml.apache.org/xalan/features/incremental true)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (Ne demander aucune optimisation de la feuille de style en d\u00E9finissant http://xml.apache.org/xalan/features/optimize false)]"}, + {"optionRL", " [-RL recursionlimit (Assertion d'une limite num\u00E9rique sur la profondeur de r\u00E9cursivit\u00E9 de la feuille de style)]"}, + {"optionXO", " [-XO [transletName] (Affecter le nom au translet g\u00E9n\u00E9r\u00E9)]"}, + {"optionXD", " [-XD destinationDirectory (Indiquer un r\u00E9pertoire de destination pour le translet)]"}, + {"optionXJ", " [-XJ jarfile (Packager les classes de translet dans un fichier JAR nomm\u00E9 )]"}, + {"optionXP", " [-XP package (Indique un pr\u00E9fixe de nom de package pour toutes les classes de translet g\u00E9n\u00E9r\u00E9es)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (Activer automatiquement l'image \"inline\" du mod\u00E8le)]"}, + {"optionXX", " [-XX (Activer la sortie de messages de d\u00E9bogage suppl\u00E9mentaires)]"}, + {"optionXT", " [-XT (Utiliser le translet pour la transformation si possible)]"}, + {"diagTiming", " --------- La transformation de {0} via {1} a pris {2} ms"}, + {"recursionTooDeep", "Imbrication de mod\u00E8le trop profonde. Imbrication = {0}, mod\u00E8le {1} {2}"}, + {"nameIs", "le nom est"}, + {"matchPatternIs", "le mod\u00E8le de recherche est"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java new file mode 100644 index 0000000..11def14 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_it extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Errore: '{' non pu\u00F2 esistere nell'espressione"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} ha un attributo non valido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode nullo in xsl:apply-imports."}, + + {ER_CANNOT_ADD, + "Impossibile aggiungere {0} a {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode nullo in handleApplyTemplatesInstruction."}, + + {ER_NO_NAME_ATTRIB, + "{0} deve avere un attributo name."}, + + {ER_TEMPLATE_NOT_FOUND, + "Impossibile trovare il modello denominato {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Impossibile risolvere l'AVT del nome in xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} richiede l''attributo: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} deve avere un attributo \"test\"."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valore non valido per l''attributo level: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "il nome processing-instruction non pu\u00F2 essere 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "il nome processing-instruction deve essere un NCName valido: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} deve avere un attributo match se dispone di una modalit\u00E0."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} richiede un nome o un attributo match."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Impossibile risolvere il prefisso spazio di nomi {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space ha un valore non valido {0}"}, + + {ER_NO_OWNERDOC, + "Il nodo figlio non dispone di un documento proprietario."}, + + {ER_ELEMTEMPLATEELEM_ERR, + "Errore di ElemTemplateElement: {0}"}, + + {ER_NULL_CHILD, + "Tentativo di aggiungere un elemento figlio nullo."}, + + {ER_NEED_SELECT_ATTRIB, + "{0} richiede un attributo select."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when deve avere un attributo 'test'."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param deve avere un attributo 'name'."}, + + {ER_NO_CONTEXT_OWNERDOC, + "il contesto non dispone di un documento proprietario."}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Impossibile creare la relazione TransformerFactory XML {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: processo non riuscito."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: operazione non riuscita."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Codifica non supportata: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Impossibile creare TraceListener {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key richiede un attributo 'name'."}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key richiede un attributo 'match'."}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key richiede un attributo 'use'."}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} richiede un attributo ''elements''."}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} attributo ''prefix'' mancante"}, + + {ER_BAD_STYLESHEET_URL, + "URL del foglio di stile non valido: {0}"}, + + {ER_FILE_NOT_FOUND, + "File del foglio di stile non trovato: {0}"}, + + {ER_IOEXCEPTION, + "Eccezione IO con il file foglio di stile: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Impossibile trovare l''attributo href per {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} include s\u00E9 stesso direttamente o indirettamente."}, + + {ER_PROCESSINCLUDE_ERROR, + "Errore di StylesheetHandler.processInclude: {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} attributo ''lang'' mancante"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) posizione errata dell''elemento {0}. Elemento ''component'' del contenitore mancante."}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "L'output pu\u00F2 essere eseguito solo su Element, DocumentFragment, Document o PrintWriter."}, + + {ER_PROCESS_ERROR, + "Errore di StylesheetRoot.process"}, + + {ER_UNIMPLNODE_ERROR, + "Errore di UnImplNode: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Errore. L'espressione di selezione dell'xpath (-select) non \u00E8 stata trovata."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Impossibile serializzare un XSLProcessor."}, + + {ER_NO_INPUT_STYLESHEET, + "Input del foglio di stile non specificato."}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Elaborazione del foglio di stile non riuscita."}, + + {ER_COULDNT_PARSE_DOC, + "Impossibile analizzare il documento {0}"}, + + {ER_COULDNT_FIND_FRAGMENT, + "Impossibile trovare il frammento {0}"}, + + {ER_NODE_NOT_ELEMENT, + "Il nodo a cui punta l''identificativo di frammento non \u00E8 un elemento: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each deve avere un attributo match o name"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates deve avere un attributo match o name"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Nessun duplicato di un frammento di documento."}, + + {ER_CANT_CREATE_ITEM, + "Impossibile creare una voce nella struttura dei risultati: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space nell''XML di origine ha un valore non valido {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "Nessuna dichiarazione xsl:key per {0}."}, + + {ER_CANT_CREATE_URL, + "Errore. Impossibile creare l''URL per {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions non supportato"}, + + {ER_PROCESSOR_ERROR, + "Errore di TransformerFactory XSLT"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} non consentito in un foglio di stile."}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns non pi\u00F9 supportato. Utilizzare xsl:output."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space non pi\u00F9 supportato. Utilizzare xsl:strip-space o xsl:preserve-space."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result non pi\u00F9 supportato. Utilizzare xsl:output."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} ha un attributo non valido: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Elemento XSL sconosciuto: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort pu\u00F2 essere utilizzato solo con xsl:apply-templates o xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) posizione errata di xsl:when."}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when non associato da xsl:choose."}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) posizione errata di xsl:otherwise."}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise non associato da xsl:choose."}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} non consentito in un modello."}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} prefisso spazio di nomi estensione {1} sconosciuto"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Le importazioni possono essere eseguite solo come primi elementi nel foglio di stile."}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importa s\u00E9 stesso direttamente o indirettamente."}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space ha un valore non valido {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet non riuscito."}, + + {ER_SAX_EXCEPTION, + "Eccezione SAX"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Funzione non supportata."}, + + {ER_XSLT_ERROR, + "Errore XSLT"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "il simbolo della valuta non \u00E8 consentito in una stringa di pattern di formato"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Funzione del documento non supportata nel DOM del foglio di stile."}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Impossibile risolvere il prefisso di un resolver senza prefissi."}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Estensione di reindirizzamento: impossibile trovare il nome file. L'attributo file o select deve restituire una stringa valida."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Impossibile creare FormatterListener nell'estensione di reindirizzamento."}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Il prefisso in exclude-result-prefixes non \u00E8 valido: {0}"}, + + {ER_MISSING_NS_URI, + "URI dello spazio di nomi mancante per il prefisso specificato"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Argomento mancante per l''opzione: {0}"}, + + {ER_INVALID_OPTION, + "Opzione non valida: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Stringa con formato errato: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet richiede un attributo 'version'."}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "L''attributo {0} ha un valore non valido {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose richiede xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports non consentito in xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "Impossibile utilizzare DTMLiaison per un nodo DOM di output... Passare com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "Impossibile utilizzare DTMLiaison per un nodo DOM di input... Passare com.sun.org.apache.xpath.internal.DOM2Helper."}, + + {ER_CALL_TO_EXT_FAILED, + "Chiamata all''elemento di estensione non riuscita: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "Il prefisso deve essere risolto in uno spazio di nomi: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Rilevato surrogato UTF-16 non valido: {0}?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} utilizza s\u00E9 stesso, il che pu\u00F2 causare un loop infinito."}, + + {ER_CANNOT_MIX_XERCESDOM, + "Impossibile unire input non Xerces-DOM con output Xerces-DOM."}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "In ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Sono stati trovati pi\u00F9 modelli denominati {0}"}, + + {ER_INVALID_KEY_CALL, + "Chiamata di funzione non valida: non sono consentite chiamate recursive key()"}, + + {ER_REFERENCING_ITSELF, + "La variabile {0} fa riferimento a s\u00E9 stessa direttamente o indirettamente."}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "Il nodo di input non pu\u00F2 essere nullo per un DOMSource per newTemplates."}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "File di classe non trovato per l''opzione {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "Elemento richiesto non trovato: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream non pu\u00F2 essere nullo"}, + + {ER_URI_CANNOT_BE_NULL, + "L'URI non pu\u00F2 essere nullo"}, + + {ER_FILE_CANNOT_BE_NULL, + "Il file non pu\u00F2 essere nullo"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource non pu\u00F2 essere nullo"}, + + {ER_CANNOT_INIT_BSFMGR, + "Impossibile inizializzare BSF Manager"}, + + {ER_CANNOT_CMPL_EXTENSN, + "Impossibile compilare l'estensione"}, + + {ER_CANNOT_CREATE_EXTENSN, + "Impossibile creare l''estensione {0}. Motivo: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "La chiamata del metodo di istanza {0} richiede un''istanza di oggetto come primo argomento"}, + + {ER_INVALID_ELEMENT_NAME, + "Specificato nome elemento {0} non valido"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "Il metodo di nome elemento deve essere statico {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "Funzione di estensione {0} : {1} sconosciuta"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "Esistono pi\u00F9 corrispondenze migliori per il costruttore di {0}"}, + + {ER_MORE_MATCH_METHOD, + "Esistono pi\u00F9 corrispondenze migliori per il metodo {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "Esistono pi\u00F9 corrispondenze migliori per il metodo di elemento {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Passato contesto non valido per valutare {0}"}, + + {ER_POOL_EXISTS, + "Il pool esiste gi\u00E0"}, + + {ER_NO_DRIVER_NAME, + "Nessun nome driver specificato"}, + + {ER_NO_URL, + "Nessun URL specificato"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "La dimensione del pool \u00E8 minore di uno."}, + + {ER_INVALID_DRIVER, + "Specificato nome driver non valido."}, + + {ER_NO_STYLESHEETROOT, + "Radice del foglio di stile non trovata."}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Valore non valido per xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode non riuscito"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "Impossibile caricare la risorsa [ {0} ]: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Dimensione buffer <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Errore sconosciuto durante la chiamata dell'estensione"}, + + {ER_NO_NAMESPACE_DECL, + "Il prefisso {0} non ha una dichiarazione di spazio di nomi corrispondente"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Contenuto di elemento non consentito per lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Il foglio di stile ha causato l'interruzione"}, + + {ER_ONE_OR_TWO, + "1 o 2"}, + + {ER_TWO_OR_THREE, + "2 o 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "Impossibile caricare {0} (verificare CLASSPATH); verranno utilizzati i valori predefiniti"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Impossibile inizializzare i modelli predefiniti"}, + + {ER_RESULT_NULL, + "Il risultato non deve essere nullo"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "Impossibile impostare il risultato"}, + + {ER_NO_OUTPUT_SPECIFIED, + "Nessun output specificato"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Impossibile eseguire la trasformazione in un risultato di tipo {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Impossibile eseguire la trasformazione in un''origine di tipo {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Handler dei contenuti nullo"}, + + {ER_NULL_ERROR_HANDLER, + "Handler degli errori nullo"}, + + {ER_CANNOT_CALL_PARSE, + "impossibile richiamare parse se non \u00E8 stato impostato ContentHandler"}, + + {ER_NO_PARENT_FOR_FILTER, + "Nessun elemento padre per il filtro"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "Nessun foglio di stile trovato in {0}, media= {1}."}, + + {ER_NO_STYLESHEET_PI, + "Nessun PI xml-stylesheet trovato in {0}"}, + + {ER_NOT_SUPPORTED, + "Non supportato: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "Il valore della propriet\u00E0 {0} deve essere un''istanza booleana"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Impossibile recuperare lo script esterno in {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "Risorsa [ {0} ] non trovata.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propriet\u00E0 di output non riconosciuta: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Creazione dell'istanza ElemLiteralResult non riuscita"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "Il valore per {0} deve contenere un numero analizzabile"}, + + {ER_VALUE_SHOULD_EQUAL, + "Il valore per {0} deve corrispondere a yes o no"}, + + {ER_FAILED_CALLING_METHOD, + "Richiamo del metodo {0} non riuscito"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Creazione dell'istanza ElemTemplateElement non riuscita"}, + + {ER_CHARS_NOT_ALLOWED, + "Non sono consentiti caratteri in questo punto del documento"}, + + {ER_ATTR_NOT_ALLOWED, + "L''attributo \"{0}\" non \u00E8 consentito nell''elemento {1}."}, + + {ER_BAD_VALUE, + "{0} valore non valido {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "{0} valore di attributo non trovato "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} valore di attributo non riconosciuto "}, + + {ER_NULL_URI_NAMESPACE, + "Tentativo di generare un prefisso spazio di nomi con URI nullo"}, + + {ER_NUMBER_TOO_BIG, + "Tentativo di formattare un numero superiore a quello del numero intero di tipo Long pi\u00F9 grande"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "Impossibile trovare la classe di driver SAX1 {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "La classe di driver SAX1 {0} \u00E8 stata trovata, ma non pu\u00F2 essere caricata."}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "La classe di driver SAX1 {0} \u00E8 stata caricata, ma non \u00E8 possibile creare un''istanza."}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "La classe di driver SAX1 {0} non implementa org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Propriet\u00E0 di sistema org.xml.sax.parser non specificata"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "L'argomento del parser non deve essere nullo"}, + + {ER_FEATURE, + "Funzione: {0}"}, + + {ER_PROPERTY, + "Propriet\u00E0: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Resolver di entit\u00E0 nullo"}, + + {ER_NULL_DTD_HANDLER, + "Handler DTD nullo"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "Nessun nome driver specificato."}, + + {ER_NO_URL_SPECIFIED, + "Nessun URL specificato."}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "La dimensione del pool \u00E8 minore di uno."}, + + {ER_INVALID_DRIVER_NAME, + "Specificato nome driver non valido."}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Errore del programmatore. L'espressione non ha un elemento padre ElemTemplateElement."}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Asserzione del programmatore in RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} non consentito in questa posizione nel figlio di stile."}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Testo senza spazi non consentito in questa posizione nel figlio di stile."}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Valore non valido {1} utilizzato per l''attributo CHAR {0}. Un attributo di tipo CHAR deve avere un solo carattere."}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Valore non valido {1} utilizzato per l''attributo QNAME {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Valore non valido {1} utilizzato per l''attributo ENUM {0}. Valori validi: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Valore non valido {1} utilizzato per l''attributo NMTOKEN {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Valore non valido {1} utilizzato per l''attributo NCNAME {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Valore non valido {1} utilizzato per l''attributo booleano {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Valore non valido {1} utilizzato per l''attributo numerico {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "L''argomento per {0} nel pattern di corrispondenza deve essere un valore."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Dichiarazione di variabili globali duplicate."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Dichiarazione di variabili duplicate."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template deve avere un attributo name o match o entrambi"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "Il prefisso in exclude-result-prefixes non \u00E8 valido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "il set di attributi denominato {0} non esiste"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "La funzione denominata {0} non esiste"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "L''elemento {0} non deve avere entrambi gli attributi content e select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "Il valore del parametro {0} deve essere un oggetto Java valido"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "L'attributo result-prefix di un elemento xsl:namespace-alias ha il valore '#default', ma non esiste alcuna dichiarazione dello spazio di nomi predefinito nell'ambito per l'elemento."}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "L''attributo result-prefix di un elemento xsl:namespace-alias ha il valore ''{0}'', ma non esiste alcuna dichiarazione dello spazio di nomi per il prefisso ''{0}'' nell''ambito per l''elemento."}, + + {ER_SET_FEATURE_NULL_NAME, + "Il nome funzione non pu\u00F2 essere nullo in TransformerFactory.setFeature (nome stringa, valore booleano)."}, + + {ER_GET_FEATURE_NULL_NAME, + "Il nome funzione non pu\u00F2 essere nullo in TransformerFactory.getFeature (nome stringa)."}, + + {ER_UNSUPPORTED_FEATURE, + "Impossibile impostare la funzione ''{0}'' in questo TransformerFactory."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Non \u00E8 consentito utilizzare l''elemento di estensione ''{0}'' se la funzione di elaborazione sicura \u00E8 impostata su true."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Impossibile recuperare il prefisso per un URI di spazio di nomi nullo."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Impossibile recuperare l'URI di spazio di nomi per un prefisso nullo."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "Il nome funzione non pu\u00F2 essere nullo."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "L'arity non pu\u00F2 essere negativa."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "Trovato '}', ma non esistono modelli di attributo aperti."}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Avvertenza: l''attributo count non corrisponde a un predecessore in xsl:number. Destinazione = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintassi obsoleta: il nome dell'attributo 'expr' \u00E8 stato cambiato in 'select'."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan non gestisce ancora il nome di impostazioni nazionali nella funzione format-number."}, + + {WG_LOCALE_NOT_FOUND, + "Avvertenza: impossibile trovare le impostazioni nazionali per xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "Impossibile creare un URL da {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "Impossibile caricare il documento richiesto: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "Impossibile trovare Collator per >>>>>> Versione Xalan "}, + {"version2", "<<<<<<<"}, + {"yes", "s\u00EC"}, + {"line", "N. riga"}, + {"column", "N. colonna"}, + {"xsldone", "XSLProcessor: operazione completata"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Opzioni classe di processo per riga di comando Xalan-J:"}, + {"xslProc_option", "Opzioni classe di processo per riga di comando Xalan-J:"}, + {"xslProc_invalid_xsltc_option", "Opzione {0} non supportata in modalit\u00E0 XSLTC."}, + {"xslProc_invalid_xalan_option", "L''opzione {0} pu\u00F2 essere utilizzata solo con -XSLTC."}, + {"xslProc_no_input", "Errore: non \u00E8 stato specificato alcun foglio di stile o XML di input. Eseguire questo comando senza opzioni per visualizzare le istruzioni sull'uso."}, + {"xslProc_common_options", "-Opzioni comuni-"}, + {"xslProc_xalan_options", "-Opzioni per Xalan-"}, + {"xslProc_xsltc_options", "-Opzioni per XSLTC-"}, + {"xslProc_return_to_continue", "(premere per continuare)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (usa XSLTC per la trasformazione)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER nome classe completamente qualificato per la relazione del parser]"}, + {"optionE", " [-E (non espande i riferimenti alle entit\u00E0)]"}, + {"optionV", " [-E (non espande i riferimenti alle entit\u00E0)]"}, + {"optionQC", " [-QC (avvertenze silenziose per i conflitti di pattern)]"}, + {"optionQ", " [-Q (modalit\u00E0 silenziosa)]"}, + {"optionLF", " [-LF (usa avanzamenti riga solo nell'output {il valore predefinito \u00E8 CR/LF})]"}, + {"optionCR", " [-CR (usa ritorni a capo solo nell'output {il valore predefinito \u00E8 CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (caratteri da sottoporre a escape {il valore predefinito \u00E8 <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (determina il numero di spazi da indentare {il valore predefinito \u00E8 0})]"}, + {"optionTT", " [-TT (tiene traccia dei modelli mentre vengono richiamati.)]"}, + {"optionTG", " [-TG (tiene traccia di ogni evento di generazione.)]"}, + {"optionTS", " [-TS (tiene traccia di ogni evento di selezione.)]"}, + {"optionTTC", " [-TTC (tiene traccia degli elementi secondari di modello mentre vengono elaborati.)]"}, + {"optionTCLASS", " [-TCLASS (classe TraceListener per tenere traccia delle estensioni.)]"}, + {"optionVALIDATE", " [-VALIDATE (imposta se viene eseguita la convalida che, per impostazione predefinita, \u00E8 disattivata.)]"}, + {"optionEDUMP", " [-EDUMP {nome file facoltativo} (esegue stackdump in caso di errore.)]"}, + {"optionXML", " [-XML (usa il formatter XML e aggiunge l'intestazione XML.)]"}, + {"optionTEXT", " [-TEXT (usa il formatter di testo semplice.)]"}, + {"optionHTML", " [-HTML (usa il formatter HTML.)]"}, + {"optionPARAM", " [-PARAM espressione nome (imposta un parametro di foglio di stile)]"}, + {"noParsermsg1", "Processo XSL non riuscito."}, + {"noParsermsg2", "** Impossibile trovare il parser **"}, + {"noParsermsg3", "Controllare il classpath."}, + {"noParsermsg4", "Se non \u00E8 disponibile un parser XML di IBM per Java, \u00E8 possibile scaricarlo da"}, + {"noParsermsg5", "AlphaWorks di IBM: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER nome classe completo (URIResolver da utilizzare per risolvere gli URI)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER nome classe completo (EntityResolver da utilizzare per risolvere le entit\u00E0)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER nome classe completo (ContentHandler da utilizzare per serializzare l'output)]"}, + {"optionLINENUMBERS", " [-L utilizza i numeri di riga per il documento di origine]"}, + {"optionSECUREPROCESSING", " [-SECURE (imposta la funzione di elaborazione sicura su true.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (utilizza l'attributo media per trovare il foglio di stile associato a un documento.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (utilizza esplicitamente s2s=SAX o d2d=DOM per eseguire la trasformazione.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (visualizza i millisecondi totali richiesti per la trasformazione.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (richiede la creazione incrementale di DTM impostando http://xml.apache.org/xalan/features/incremental su true.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (richiede che non venga elaborata l'ottimizzazione dei fogli di stile impostando http://xml.apache.org/xalan/features/optimize su false.)]"}, + {"optionRL", " [-RL recursionlimit (stabilisce un limite numerico sulla profondit\u00E0 ricorsiva dei fogli di stile.)]"}, + {"optionXO", " [-XO [transletName] (assegna un nome al translet creato)]"}, + {"optionXD", " [-XD destinationDirectory (specifica una directory di destinazione per il translet)]"}, + {"optionXJ", " [-XJ jarfile (crea un package di classi di translet in un file jar denominato )]"}, + {"optionXP", " [-XP package (specifica un prefisso nome package per tutte le classi di translet generate)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (abilita l'inserimento in linea dei modelli)]"}, + {"optionXX", " [-XX (attiva l'output di altri messaggi di debug)]"}, + {"optionXT", " [-XT (utilizza il translet per eseguire la trasformazione, se possibile.)]"}, + {"diagTiming", " --------- La trasformazione di {0} mediante {1} ha richiesto {2} ms"}, + {"recursionTooDeep", "Nidificazione dei modelli troppo profonda. Nidificazione = {0}, modello {1} {2}."}, + {"nameIs", "il nome \u00E8"}, + {"matchPatternIs", "il pattern di corrispondenza \u00E8"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java new file mode 100644 index 0000000..adcd1b2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_ja extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "\u30A8\u30E9\u30FC: \u5F0F\u5185\u306B'{'\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0}\u306B\u4E0D\u6B63\u306A\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode\u306Fxsl:apply-imports\u5185\u3067null\u3067\u3059\u3002"}, + + {ER_CANNOT_ADD, + "{0}\u3092{1}\u306B\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode\u306FhandleApplyTemplatesInstruction\u5185\u3067null\u3067\u3059\u3002"}, + + {ER_NO_NAME_ATTRIB, + "{0}\u306B\u306Fname\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u540D\u524D{0}\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "xsl:call-template\u306E\u540D\u524DAVT\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0}\u306F\u5C5E\u6027{1}\u304C\u5FC5\u8981\u3067\u3059"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0}\u306F''test''\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level\u5C5E\u6027\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction\u540D\u306F'xml'\u306B\u3067\u304D\u307E\u305B\u3093"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction\u540D\u306F\u6709\u52B9\u306ANCName\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "\u30E2\u30FC\u30C9\u304C\u3042\u308B\u5834\u5408\u3001{0}\u306B\u306Fmatch\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\u306B\u306Fname\u307E\u305F\u306Fmatch\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_NO_OWNERDOC, + "\u5B50\u30CE\u30FC\u30C9\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement\u30A8\u30E9\u30FC: {0}"}, + + {ER_NULL_CHILD, + "null\u306E\u5B50\u3092\u8FFD\u52A0\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F\u3002"}, + + {ER_NEED_SELECT_ATTRIB, + "{0}\u306B\u306Fselect\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when\u306B\u306F'test'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param\u306B\u306F'name'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_NO_CONTEXT_OWNERDOC, + "\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML TransformerFactory Liaison\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u30D7\u30ED\u30BB\u30B9\u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_NOT_SUCCESSFUL, + "Xalan: \u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_ENCODING_NOT_SUPPORTED, + "\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key\u306B\u306F'name'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key\u306B\u306F'match'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key\u306B\u306F'use'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\u306B\u306F''elements''\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0}\u5C5E\u6027''prefix''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_BAD_STYLESHEET_URL, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8URL\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_FILE_NOT_FOUND, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_IOEXCEPTION, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u306B\u5165\u51FA\u529B\u4F8B\u5916\u304C\u3042\u308A\u307E\u3059: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) {0}\u306Ehref\u5C5E\u6027\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u7684\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u542B\u3093\u3067\u3044\u307E\u3059\u3002"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude\u30A8\u30E9\u30FC\u3001{0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0}\u5C5E\u6027''lang''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}\u8981\u7D20\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002\u30B3\u30F3\u30C6\u30CA\u8981\u7D20''component''\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Element\u3001DocumentFragment\u3001Document\u307E\u305F\u306FPrintWriter\u306B\u306E\u307F\u51FA\u529B\u3067\u304D\u307E\u3059\u3002"}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process\u30A8\u30E9\u30FC"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode\u30A8\u30E9\u30FC: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "\u30A8\u30E9\u30FC\u3002xpath\u9078\u629E\u5F0F(-select)\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor\u3092\u30B7\u30EA\u30A2\u30E9\u30A4\u30BA\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_NO_INPUT_STYLESHEET, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u5165\u529B\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}, + + {ER_COULDNT_PARSE_DOC, + "{0}\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u89E3\u6790\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_COULDNT_FIND_FRAGMENT, + "\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u8B58\u5225\u5B50\u306B\u3088\u3063\u3066\u6307\u793A\u3055\u308C\u305F\u30CE\u30FC\u30C9\u306F\u8981\u7D20\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each\u306Fmatch\u307E\u305F\u306Fname\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306Fmatch\u307E\u305F\u306Fname\u5C5E\u6027\u3092\u6301\u3064\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306E\u30AF\u30ED\u30FC\u30F3\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_CANT_CREATE_ITEM, + "\u7D50\u679C\u30C4\u30EA\u30FC\u306B\u9805\u76EE\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "\u30BD\u30FC\u30B9XML\u306Exml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "{0}\u306Exsl:key\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_CANT_CREATE_URL, + "\u30A8\u30E9\u30FC\u3002{0}\u306EURL\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory\u30A8\u30E9\u30FC"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0}\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:output\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:strip-space\u307E\u305F\u306Fxsl:preserve-space\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306Bxsl:output\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\u306B\u306F\u4E0D\u6B63\u306A\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "\u4E0D\u660E\u306AXSL\u8981\u7D20: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort\u306F\u3001xsl:apply-templates\u307E\u305F\u306Fxsl:for-each\u3068\u3068\u3082\u306B\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when\u306E\u89AA\u304Cxsl:choose\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise\u306E\u914D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise\u306E\u89AA\u304Cxsl:choose\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0}\u306F\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) \u4E0D\u660E\u306A{0}\u62E1\u5F35\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E{1}\u3067\u3059"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u30A4\u30F3\u30DD\u30FC\u30C8\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u6700\u521D\u306E\u8981\u7D20\u3068\u3057\u3066\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u3059\u3002"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet\u306F\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}, + + {ER_SAX_EXCEPTION, + "SAX\u4F8B\u5916"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "\u95A2\u6570\u304C\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + {ER_XSLT_ERROR, + "XSLT\u30A8\u30E9\u30FC"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "\u901A\u8CA8\u8A18\u53F7\u306F\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u30FB\u30D1\u30BF\u30FC\u30F3\u6587\u5B57\u5217\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u95A2\u6570\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8DOM\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u975E\u63A5\u982D\u8F9E\u30EA\u30BE\u30EB\u30D0\u306E\u63A5\u982D\u8F9E\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u62E1\u5F35: \u30D5\u30A1\u30A4\u30EB\u540D\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F - file\u307E\u305F\u306Fselect\u5C5E\u6027\u304C\u6709\u52B9\u306A\u6587\u5B57\u5217\u3092\u8FD4\u3059\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u62E1\u5F35\u3067FormatterListener\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes\u306E\u63A5\u982D\u8F9E\u304C\u7121\u52B9\u3067\u3059: {0}"}, + + {ER_MISSING_NS_URI, + "\u6307\u5B9A\u3057\u305F\u63A5\u982D\u8F9E\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_MISSING_ARG_FOR_OPTION, + "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306E\u5F15\u6570\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_INVALID_OPTION, + "\u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "\u4E0D\u6B63\u306A\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u306E\u6587\u5B57\u5217\u3067\u3059: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet\u306F'version'\u5C5E\u6027\u304C\u5FC5\u8981\u3067\u3059\u3002"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C5E\u6027{0}\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose\u306Fxsl:when\u304C\u5FC5\u8981\u3067\u3059"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports\u306Fxsl:for-each\u5185\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "\u51FA\u529BDOM\u30CE\u30FC\u30C9\u306BDTMLiaison\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093...\u304B\u308F\u308A\u306Bcom.sun.org.apache.xpath.internal.DOM2Helper\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "\u5165\u529BDOM\u30CE\u30FC\u30C9\u306BDTMLiaison\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093...\u304B\u308F\u308A\u306Bcom.sun.org.apache.xpath.internal.DOM2Helper\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + + {ER_CALL_TO_EXT_FAILED, + "\u62E1\u5F35\u8981\u7D20\u306E\u547C\u51FA\u3057\u304C\u5931\u6557\u3057\u307E\u3057\u305F: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "\u63A5\u982D\u8F9E\u306F\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306B\u89E3\u6C7A\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "\u7121\u52B9\u306AUTF-16\u30B5\u30ED\u30B2\u30FC\u30C8\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: {0}\u3002"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0}\u304C\u305D\u308C\u81EA\u4F53\u3092\u4F7F\u7528\u3057\u3001\u7121\u9650\u30EB\u30FC\u30D7\u304C\u767A\u751F\u3057\u307E\u3059\u3002"}, + + {ER_CANNOT_MIX_XERCESDOM, + "\u975EXerces-DOM\u5165\u529B\u3068Xerces-DOM\u51FA\u529B\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "ElemTemplateElement.readObject\u5185: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "\u540D\u524D{0}\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u8907\u6570\u898B\u3064\u304B\u308A\u307E\u3057\u305F"}, + + {ER_INVALID_KEY_CALL, + "\u7121\u52B9\u306A\u95A2\u6570\u547C\u51FA\u3057: \u518D\u5E30\u7684\u306Akey()\u306E\u547C\u51FA\u3057\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + {ER_REFERENCING_ITSELF, + "\u5909\u6570{0}\u306F\u305D\u308C\u81EA\u4F53\u3092\u76F4\u63A5\u307E\u305F\u306F\u9593\u63A5\u7684\u306B\u53C2\u7167\u3057\u3066\u3044\u307E\u3059\u3002"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates\u306EDOMSource\u306B\u3064\u3044\u3066\u5165\u529B\u30CE\u30FC\u30C9\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306B\u3064\u3044\u3066\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "\u5FC5\u9808\u8981\u7D20\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + {ER_URI_CANNOT_BE_NULL, + "URI\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + {ER_FILE_CANNOT_BE_NULL, + "\u30D5\u30A1\u30A4\u30EB\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"}, + + {ER_CANNOT_INIT_BSFMGR, + "BSF\u30DE\u30CD\u30FC\u30B8\u30E3\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_CANNOT_CMPL_EXTENSN, + "\u62E1\u5F35\u3092\u30B3\u30F3\u30D1\u30A4\u30EB\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_CANNOT_CREATE_EXTENSN, + "{1}\u304C\u539F\u56E0\u3067\u62E1\u5F35{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u30E1\u30BD\u30C3\u30C9{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u3057\u3067\u306F\u3001\u6700\u521D\u306E\u5F15\u6570\u3068\u3057\u3066\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u30FB\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5FC5\u8981\u3067\u3059"}, + + {ER_INVALID_ELEMENT_NAME, + "\u7121\u52B9\u306A\u8981\u7D20\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F{0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "\u8981\u7D20\u540D\u30E1\u30BD\u30C3\u30C9\u306Fstatic {0}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "\u62E1\u5F35\u95A2\u6570{0} : {1}\u304C\u4E0D\u660E\u3067\u3059"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "{0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + {ER_MORE_MATCH_METHOD, + "\u30E1\u30BD\u30C3\u30C9{0}\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + {ER_MORE_MATCH_ELEMENT, + "\u8981\u7D20\u30E1\u30BD\u30C3\u30C9{0}\u306B\u8907\u6570\u306E\u6700\u9069\u4E00\u81F4\u304C\u3042\u308A\u307E\u3059"}, + + {ER_INVALID_CONTEXT_PASSED, + "{0}\u3092\u8A55\u4FA1\u3059\u308B\u305F\u3081\u306B\u7121\u52B9\u306A\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304C\u6E21\u3055\u308C\u307E\u3057\u305F"}, + + {ER_POOL_EXISTS, + "\u30D7\u30FC\u30EB\u306F\u3059\u3067\u306B\u5B58\u5728\u3057\u307E\u3059"}, + + {ER_NO_DRIVER_NAME, + "\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_NO_URL, + "URL\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "\u30D7\u30FC\u30EB\u30FB\u30B5\u30A4\u30BA\u304C1\u3088\u308A\u5C0F\u3055\u3044\u3067\u3059\u3002"}, + + {ER_INVALID_DRIVER, + "\u7121\u52B9\u306A\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F\u3002"}, + + {ER_NO_STYLESHEETROOT, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30EB\u30FC\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode\u304C\u5931\u6557\u3057\u307E\u3057\u305F"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "\u30EA\u30BD\u30FC\u30B9[ {0} ]\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u30D0\u30C3\u30D5\u30A1\u30FB\u30B5\u30A4\u30BA<=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u62E1\u5F35\u3092\u547C\u3073\u51FA\u3059\u3068\u304D\u306B\u4E0D\u660E\u306A\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"}, + + {ER_NO_NAMESPACE_DECL, + "\u63A5\u982D\u8F9E{0}\u306B\u306F\u3001\u5BFE\u5FDC\u3059\u308B\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "\u8981\u7D20\u306E\u5185\u5BB9\u306Flang=javaclass {0}\u306B\u3064\u3044\u3066\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306B\u3088\u308A\u7D42\u4E86\u304C\u6307\u793A\u3055\u308C\u307E\u3057\u305F"}, + + {ER_ONE_OR_TWO, + "1\u307E\u305F\u306F2"}, + + {ER_TWO_OR_THREE, + "2\u307E\u305F\u306F3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "{0}\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F(CLASSPATH\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044)\u3002\u73FE\u5728\u306F\u5358\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093"}, + + {ER_RESULT_NULL, + "\u7D50\u679C\u306Fnull\u306B\u3067\u304D\u307E\u305B\u3093"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "\u7D50\u679C\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_NO_OUTPUT_SPECIFIED, + "\u51FA\u529B\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u30BF\u30A4\u30D7{0}\u306E\u7D50\u679C\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u30BF\u30A4\u30D7{0}\u306E\u30BD\u30FC\u30B9\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093"}, + + {ER_NULL_CONTENT_HANDLER, + "Null\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u30FB\u30CF\u30F3\u30C9\u30E9"}, + + {ER_NULL_ERROR_HANDLER, + "Null\u306E\u30A8\u30E9\u30FC\u30FB\u30CF\u30F3\u30C9\u30E9"}, + + {ER_CANNOT_CALL_PARSE, + "ContentHandler\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u3001\u89E3\u6790\u3092\u547C\u3073\u51FA\u3059\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093"}, + + {ER_NO_PARENT_FOR_FILTER, + "\u30D5\u30A3\u30EB\u30BF\u306E\u89AA\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u304C{0}\u306B\u3042\u308A\u307E\u305B\u3093\u3002\u30E1\u30C7\u30A3\u30A2= {1}"}, + + {ER_NO_STYLESHEET_PI, + "xml-stylesheet PI\u304C{0}\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + {ER_NOT_SUPPORTED, + "\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "\u30D7\u30ED\u30D1\u30C6\u30A3{0}\u306E\u5024\u306FBoolean\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "{0}\u306E\u5916\u90E8\u30B9\u30AF\u30EA\u30D7\u30C8\u306B\u5230\u9054\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "\u30EA\u30BD\u30FC\u30B9[ {0} ]\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u51FA\u529B\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u8A8D\u8B58\u3055\u308C\u307E\u305B\u3093: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "{0}\u306E\u5024\u306B\u306F\u89E3\u6790\u53EF\u80FD\u306A\u6570\u5024\u304C\u542B\u307E\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_VALUE_SHOULD_EQUAL, + "{0}\u306E\u5024\u306Fyes\u307E\u305F\u306Fno\u306B\u7B49\u3057\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_FAILED_CALLING_METHOD, + "{0}\u30E1\u30BD\u30C3\u30C9\u306E\u547C\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F"}, + + {ER_CHARS_NOT_ALLOWED, + "\u6587\u5B57\u306F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u3053\u306E\u30DD\u30A4\u30F3\u30C8\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"}, + + {ER_ATTR_NOT_ALLOWED, + "\"{0}\"\u5C5E\u6027\u306F{1}\u8981\u7D20\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + {ER_BAD_VALUE, + "{0}\u306E\u4E0D\u6B63\u306A\u5024{1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "{0}\u5C5E\u6027\u5024\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0}\u5C5E\u6027\u5024\u304C\u8A8D\u8B58\u3055\u308C\u307E\u305B\u3093 "}, + + {ER_NULL_URI_NAMESPACE, + "null\u306EURI\u3092\u6301\u3064\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u63A5\u982D\u8F9E\u3092\u751F\u6210\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F"}, + + {ER_NUMBER_TOO_BIG, + "\u6700\u5927\u306ELong\u6574\u6570\u3088\u308A\u3082\u5927\u304D\u3044\u6570\u5024\u3092\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u304C\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u304C\u30ED\u30FC\u30C9\u3055\u308C\u307E\u3057\u305F\u304C\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1\u30C9\u30E9\u30A4\u30D0\u30FB\u30AF\u30E9\u30B9{0}\u306Forg.xml.sax.Parser\u3092\u5B9F\u88C5\u3067\u304D\u307E\u305B\u3093"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u30B7\u30B9\u30C6\u30E0\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3org.xml.sax.parser\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "\u30D1\u30FC\u30B5\u30FC\u5F15\u6570\u306Fnull\u3067\u306A\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_FEATURE, + "\u6A5F\u80FD: {0}"}, + + {ER_PROPERTY, + "\u30D7\u30ED\u30D1\u30C6\u30A3: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Null\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u30FB\u30EA\u30BE\u30EB\u30D0"}, + + {ER_NULL_DTD_HANDLER, + "Null DTD\u30CF\u30F3\u30C9\u30E9"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + {ER_NO_URL_SPECIFIED, + "URL\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "\u30D7\u30FC\u30EB\u30FB\u30B5\u30A4\u30BA\u304C1\u3088\u308A\u5C0F\u3055\u3044\u3067\u3059\u3002"}, + + {ER_INVALID_DRIVER_NAME, + "\u7121\u52B9\u306A\u30C9\u30E9\u30A4\u30D0\u540D\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F\u3002"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "\u30D7\u30ED\u30B0\u30E9\u30DE\u306E\u30A8\u30E9\u30FC\u3002\u5F0F\u306BElemTemplateElement\u306E\u89AA\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator\u3067\u306E\u30D7\u30ED\u30B0\u30E9\u30DE\u306E\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0}\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u3053\u306E\u4F4D\u7F6E\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u7A7A\u767D\u4EE5\u5916\u306E\u30C6\u30AD\u30B9\u30C8\u306F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u3053\u306E\u4F4D\u7F6E\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CCHAR\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\u3002CHAR\u578B\u306E\u5C5E\u6027\u306F1\u6587\u5B57\u306E\u307F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CQNAME\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CENUM\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\u3002\u6709\u52B9\u306A\u5024\u306F{2}\u3067\u3059\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CNMTOKEN\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "\u4E0D\u6B63\u306A\u5024: {1}\u304CNCNAME\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "\u4E0D\u6B63\u306A\u5024: {1}\u304Cboolean\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "\u4E0D\u6B63\u306A\u5024: {1}\u304C\u6570\u5024\u5C5E\u6027{0}\u306B\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "\u4E00\u81F4\u30D1\u30BF\u30FC\u30F3\u306B\u304A\u3051\u308B{0}\u306E\u5F15\u6570\u306F\u30EA\u30C6\u30E9\u30EB\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "\u30B0\u30ED\u30FC\u30D0\u30EB\u5909\u6570\u5BA3\u8A00\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "\u5909\u6570\u5BA3\u8A00\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template\u306B\u306Fname\u5C5E\u6027\u307E\u305F\u306Fmatch\u5C5E\u6027(\u3042\u308B\u3044\u306F\u4E21\u65B9)\u304C\u5FC5\u8981\u3067\u3059"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "exclude-result-prefixes\u306E\u63A5\u982D\u8F9E\u304C\u7121\u52B9\u3067\u3059: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "{0}\u3068\u3044\u3046\u540D\u524D\u306Eattribute-set\u306F\u5B58\u5728\u3057\u307E\u305B\u3093"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "{0}\u3068\u3044\u3046\u540D\u524D\u306E\u6A5F\u80FD\u306F\u5B58\u5728\u3057\u307E\u305B\u3093"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}\u8981\u7D20\u306B\u306F\u30B3\u30F3\u30C6\u30F3\u30C4\u3068select\u5C5E\u6027\u306E\u4E21\u65B9\u3092\u542B\u3081\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u306F\u6709\u52B9\u306AJava\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias\u8981\u7D20\u306Eresult-prefix\u5C5E\u6027\u306B\u5024'#default'\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u8981\u7D20\u306E\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306E\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias\u8981\u7D20\u306Eresult-prefix\u5C5E\u6027\u306B\u5024''{0}''\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u8981\u7D20\u306E\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u63A5\u982D\u8F9E''{0}''\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}, + + {ER_SET_FEATURE_NULL_NAME, + "\u6A5F\u80FD\u540D\u306FTransformerFactory.setFeature(String name, boolean value)\u5185\u3067null\u306B\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_GET_FEATURE_NULL_NAME, + "\u6A5F\u80FD\u540D\u306FTransformerFactory.getFeature(String name)\u5185\u3067null\u306B\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_UNSUPPORTED_FEATURE, + "\u6A5F\u80FD''{0}''\u3092\u3053\u306ETransformerFactory\u306B\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u304Ctrue\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u8981\u7D20''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "null\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u306B\u3064\u3044\u3066\u63A5\u982D\u8F9E\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "null\u306E\u63A5\u982D\u8F9E\u306B\u3064\u3044\u3066\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "\u6A5F\u80FD\u540D\u3092null\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "arity\u3092\u8CA0\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "'}'\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u304C\u5C5E\u6027\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u958B\u3044\u3066\u3044\u307E\u305B\u3093\u3002"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: count\u5C5E\u6027\u304Cxsl:number\u5185\u306E\u7956\u5148\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u30BF\u30FC\u30B2\u30C3\u30C8= {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u53E4\u3044\u69CB\u6587: 'expr'\u5C5E\u6027\u306E\u540D\u524D\u304C'select'\u306B\u5909\u66F4\u3055\u308C\u307E\u3057\u305F\u3002"}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan\u306Fformat-number\u95A2\u6570\u5185\u306E\u30ED\u30B1\u30FC\u30EB\u540D\u3092\u307E\u3060\u51E6\u7406\u3067\u304D\u307E\u305B\u3093\u3002"}, + + {WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: xml:lang={0}\u306E\u30ED\u30B1\u30FC\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F"}, + + {WG_CANNOT_MAKE_URL_FROM, + "{0}\u304B\u3089URL\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "\u30EA\u30AF\u30A8\u30B9\u30C8\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8{0}\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093"}, + + {WG_CANNOT_FIND_COLLATOR, + ">>>>>> Xalan\u30D0\u30FC\u30B8\u30E7\u30F3 "}, + {"version2", "<<<<<<<"}, + {"yes", "yes"}, + {"line", "\u884C\u756A\u53F7"}, + {"column", "\u5217\u756A\u53F7"}, + {"xsldone", "XSLProcessor: \u5B8C\u4E86\u3057\u307E\u3057\u305F"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J\u30B3\u30DE\u30F3\u30C9\u884C\u30D7\u30ED\u30BB\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u30AA\u30D7\u30B7\u30E7\u30F3:"}, + {"xslProc_option", "Xalan-J\u30B3\u30DE\u30F3\u30C9\u884C\u30D7\u30ED\u30BB\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u30AA\u30D7\u30B7\u30E7\u30F3:"}, + {"xslProc_invalid_xsltc_option", "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306FXSLTC\u30E2\u30FC\u30C9\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, + {"xslProc_invalid_xalan_option", "\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306F-XSLTC\u3068\u3068\u3082\u306B\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"}, + {"xslProc_no_input", "\u30A8\u30E9\u30FC: \u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u307E\u305F\u306F\u5165\u529Bxml\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u4F7F\u7528\u65B9\u6CD5\u306E\u6307\u793A\u306B\u3064\u3044\u3066\u306F\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4ED8\u3051\u305A\u306B\u3053\u306E\u30B3\u30DE\u30F3\u30C9\u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + {"xslProc_common_options", "-\u5171\u901A\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + {"xslProc_xalan_options", "-Xalan\u7528\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + {"xslProc_xsltc_options", "-XSLTC\u7528\u30AA\u30D7\u30B7\u30E7\u30F3-"}, + {"xslProc_return_to_continue", "(\u7D9A\u884C\u3059\u308B\u306B\u306F\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (\u5909\u63DB\u306BXSLTC\u3092\u4F7F\u7528)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER \u30D1\u30FC\u30B5\u30FC\u30FB\u30EA\u30A8\u30BE\u30F3\u306E\u5B8C\u5168\u4FEE\u98FE\u30AF\u30E9\u30B9\u540D]"}, + {"optionE", " [-E (\u5B9F\u4F53\u53C2\u7167\u3092\u62E1\u5F35\u3057\u306A\u3044)]"}, + {"optionV", " [-E (\u5B9F\u4F53\u53C2\u7167\u3092\u62E1\u5F35\u3057\u306A\u3044)]"}, + {"optionQC", " [-QC (\u6291\u5236\u30D1\u30BF\u30FC\u30F3\u7AF6\u5408\u306E\u8B66\u544A)]"}, + {"optionQ", " [-Q (\u6291\u5236\u30E2\u30FC\u30C9)]"}, + {"optionLF", " [-LF (\u51FA\u529B\u3067\u306E\u307F\u6539\u884C\u3092\u4F7F\u7528{\u30C7\u30D5\u30A9\u30EB\u30C8\u306FCR/LF})]"}, + {"optionCR", " [-CR (\u51FA\u529B\u3067\u306E\u307F\u6539\u884C\u3092\u4F7F\u7528{\u30C7\u30D5\u30A9\u30EB\u30C8\u306FCR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (\u30A8\u30B9\u30B1\u30FC\u30D7\u3059\u308B\u6587\u5B57{\u30C7\u30D5\u30A9\u30EB\u30C8\u306F<>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (\u30A4\u30F3\u30C7\u30F3\u30C8\u3059\u308B\u7A7A\u767D\u6587\u5B57\u6570\u3092\u5236\u5FA1{\u30C7\u30D5\u30A9\u30EB\u30C8\u306F0})]"}, + {"optionTT", " [-TT (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u547C\u3073\u51FA\u3055\u308C\u305F\u3068\u304D\u306B\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + {"optionTG", " [-TG (\u5404\u751F\u6210\u30A4\u30D9\u30F3\u30C8\u3092\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + {"optionTS", " [-TS (\u5404\u9078\u629E\u30A4\u30D9\u30F3\u30C8\u3092\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + {"optionTTC", " [-TTC (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u5B50\u304C\u51E6\u7406\u3055\u308C\u308B\u3068\u304D\u306B\u30C8\u30EC\u30FC\u30B9\u3059\u308B\u3002)]"}, + {"optionTCLASS", " [-TCLASS (\u30C8\u30EC\u30FC\u30B9\u62E1\u5F35\u7528\u306ETraceListener\u30AF\u30E9\u30B9\u3002)]"}, + {"optionVALIDATE", " [-VALIDATE (\u691C\u8A3C\u3092\u5B9F\u884C\u3059\u308B\u304B\u3069\u3046\u304B\u3092\u8A2D\u5B9A\u3059\u308B\u3002\u691C\u8A3C\u306F\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u30AA\u30D5\u3002)]"}, + {"optionEDUMP", " [-EDUMP {optional filename} (\u30A8\u30E9\u30FC\u6642\u306Bstackdump\u3092\u5B9F\u884C\u3059\u308B\u3002)]"}, + {"optionXML", " [-XML (XML\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3057\u3066XML\u30D8\u30C3\u30C0\u30FC\u3092\u8FFD\u52A0\u3059\u308B\u3002)]"}, + {"optionTEXT", " [-TEXT (\u30B7\u30F3\u30D7\u30EB\u30FB\u30C6\u30AD\u30B9\u30C8\u30FB\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + {"optionHTML", " [-HTML (HTML\u30D5\u30A9\u30FC\u30DE\u30C3\u30BF\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + {"optionPARAM", " [-PARAM name expression (\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u8A2D\u5B9A\u3059\u308B)]"}, + {"noParsermsg1", "XSL\u30D7\u30ED\u30BB\u30B9\u306F\u6210\u529F\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"}, + {"noParsermsg2", "** \u30D1\u30FC\u30B5\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F **"}, + {"noParsermsg3", "\u30AF\u30E9\u30B9\u30D1\u30B9\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, + {"noParsermsg4", "IBM\u306EJava\u7528XML\u30D1\u30FC\u30B5\u30FC\u304C\u306A\u3044\u5834\u5408\u3001\u6B21\u306E\u30B5\u30A4\u30C8\u304B\u3089\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3067\u304D\u307E\u3059"}, + {"noParsermsg5", "IBM\u306EAlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER full class name (URI\u306E\u89E3\u6C7A\u306B\u4F7F\u7528\u3055\u308C\u308BURIResolver)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER full class name (\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u306E\u89E3\u6C7A\u306B\u4F7F\u7528\u3055\u308C\u308BEntityResolver)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER full class name (\u51FA\u529B\u306E\u30B7\u30EA\u30A2\u30E9\u30A4\u30BA\u306B\u4F7F\u7528\u3055\u308C\u308BContentHandler)]"}, + {"optionLINENUMBERS", " [-L \u30BD\u30FC\u30B9\u30FB\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u884C\u756A\u53F7\u3092\u4F7F\u7528]"}, + {"optionSECUREPROCESSING", " [-SECURE (\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u3092true\u306B\u8A2D\u5B9A\u3059\u308B\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u95A2\u9023\u4ED8\u3051\u3089\u308C\u305F\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u3092\u898B\u3064\u3051\u308B\u305F\u3081\u306B\u30E1\u30C7\u30A3\u30A2\u5C5E\u6027\u3092\u4F7F\u7528\u3059\u308B\u3002)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (\u5909\u63DB\u3092\u884C\u3046\u305F\u3081\u306Bs2s=SAX\u307E\u305F\u306Fd2d=DOM\u3092\u660E\u793A\u7684\u306B\u4F7F\u7528\u3059\u308B\u3002)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (\u5909\u63DB\u306B\u304B\u304B\u3063\u305F\u5408\u8A08\u30DF\u30EA\u79D2\u6570\u3092\u51FA\u529B\u3059\u308B\u3002)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (http://xml.apache.org/xalan/features/incremental\u3092true\u306B\u8A2D\u5B9A\u3059\u308B\u3053\u3068\u306B\u3088\u3063\u3066\u5897\u5206DTM\u69CB\u7BC9\u3092\u30EA\u30AF\u30A8\u30B9\u30C8\u3059\u308B\u3002)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (http://xml.apache.org/xalan/features/optimize\u3092false\u306B\u8A2D\u5B9A\u3059\u308B\u3053\u3068\u306B\u3088\u3063\u3066\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u6700\u9069\u5316\u51E6\u7406\u3092\u30EA\u30AF\u30A8\u30B9\u30C8\u3057\u306A\u3044\u3002)]"}, + {"optionRL", " [-RL recursionlimit (\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u306E\u518D\u5E30\u306E\u6DF1\u3055\u306B\u3064\u3044\u3066\u6570\u5024\u4E0A\u306E\u5236\u9650\u3092\u30A2\u30B5\u30FC\u30C8\u3059\u308B\u3002)]"}, + {"optionXO", " [-XO [transletName] (\u751F\u6210\u6E08translet\u306B\u540D\u524D\u3092\u5272\u308A\u5F53\u3066\u308B)]"}, + {"optionXD", " [-XD destinationDirectory (translet\u306E\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u6307\u5B9A\u3059\u308B)]"}, + {"optionXJ", " [-XJ jarfile (translet\u30AF\u30E9\u30B9\u3092\u540D\u524D\u306Ejar\u30D5\u30A1\u30A4\u30EB\u306B\u30D1\u30C3\u30B1\u30FC\u30B8\u3059\u308B)]"}, + {"optionXP", " [-XP package (\u3059\u3079\u3066\u306E\u751F\u6210\u6E08translet\u30AF\u30E9\u30B9\u7528\u306B\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u63A5\u982D\u8F9E\u3092\u6307\u5B9A\u3059\u308B)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u30A4\u30F3\u30E9\u30A4\u30F3\u5316\u3092\u6709\u52B9\u306B\u3059\u308B)]"}, + {"optionXX", " [-XX (\u8FFD\u52A0\u306E\u30C7\u30D0\u30C3\u30B0\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u51FA\u529B\u3092\u30AA\u30F3\u306B\u3059\u308B)]"}, + {"optionXT", " [-XT (\u53EF\u80FD\u306A\u5834\u5408\u306F\u5909\u63DB\u306E\u305F\u3081\u306Btranslet\u3092\u4F7F\u7528\u3059\u308B)]"}, + {"diagTiming", " --------- {1}\u306B\u3088\u308B{0}\u306E\u5909\u63DB\u306B{2}\u30DF\u30EA\u79D2\u304B\u304B\u308A\u307E\u3057\u305F"}, + {"recursionTooDeep", "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u30CD\u30B9\u30C8\u304C\u6DF1\u3059\u304E\u307E\u3059\u3002\u30CD\u30B9\u30C8= {0}\u3001\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8{1} {2}"}, + {"nameIs", "\u540D\u524D:"}, + {"matchPatternIs", "\u4E00\u81F4\u30D1\u30BF\u30FC\u30F3:"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java new file mode 100644 index 0000000..4305b18 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_ko extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "\uC624\uB958: \uD45C\uD604\uC2DD\uC5D0\uB294 '{'\uAC00 \uD3EC\uD568\uB420 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0}\uC5D0 \uC798\uBABB\uB41C \uC18D\uC131\uC774 \uC788\uC74C: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "xsl:apply-imports\uC758 sourceNode\uAC00 \uB110\uC785\uB2C8\uB2E4!"}, + + {ER_CANNOT_ADD, + "{1}\uC5D0 {0}\uC744(\uB97C) \uCD94\uAC00\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "handleApplyTemplatesInstruction\uC758 sourceNode\uAC00 \uB110\uC785\uB2C8\uB2E4!"}, + + {ER_NO_NAME_ATTRIB, + "{0}\uC5D0\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_TEMPLATE_NOT_FOUND, + "\uBA85\uBA85\uB41C \uD15C\uD50C\uB9AC\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "xsl:call-template\uC5D0\uC11C \uC774\uB984 AVT\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_REQUIRES_ATTRIB, + "{0}\uC5D0 \uC18D\uC131\uC774 \uD544\uC694\uD568: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0}\uC5D0\uB294 ''test'' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level \uC18D\uC131\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \uC774\uB984\uC740 'xml'\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \uC774\uB984\uC740 \uC801\uD569\uD55C NCName\uC774\uC5B4\uC57C \uD568: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0}\uC5D0 \uBAA8\uB4DC\uAC00 \uC788\uC744 \uACBD\uC6B0 match \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\uC5D0\uB294 name \uB610\uB294 match \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + {ER_NO_OWNERDOC, + "\uD558\uC704 \uB178\uB4DC\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \uC624\uB958: {0}"}, + + {ER_NULL_CHILD, + "\uB110 \uD558\uC704\uB97C \uCD94\uAC00\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911\uC785\uB2C8\uB2E4!"}, + + {ER_NEED_SELECT_ATTRIB, + "{0}\uC5D0\uB294 select \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when\uC5D0\uB294 'test' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param\uC5D0\uB294 'name' \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_NO_CONTEXT_OWNERDOC, + "\uCEE8\uD14D\uC2A4\uD2B8\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "XML TransformerFactory \uC5F0\uACB0\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \uD504\uB85C\uC138\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_ENCODING_NOT_SUPPORTED, + "\uC778\uCF54\uB529\uC774 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "TraceListener\uB97C \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key\uC5D0\uB294 'name' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key\uC5D0\uB294 'match' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key\uC5D0\uB294 'use' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\uC5D0\uB294 ''elements'' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) {0} \uC18D\uC131 ''prefix''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_BAD_STYLESHEET_URL, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 URL\uC774 \uC798\uBABB\uB428: {0}"}, + + {ER_FILE_NOT_FOUND, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_IOEXCEPTION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uD30C\uC77C\uC5D0 IO \uC608\uC678\uC0AC\uD56D \uBC1C\uC0DD: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) {0}\uC5D0 \uB300\uD55C href \uC18D\uC131\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\uC5D0 \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC774 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4!"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \uC624\uB958, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) {0} \uC18D\uC131 ''lang''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0} \uC694\uC18C\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB41C \uAC83 \uAC19\uC2B5\uB2C8\uB2E4. \uCEE8\uD14C\uC774\uB108 \uC694\uC18C ''component''\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Element, DocumentFragment, Document \uB610\uB294 PrintWriter\uC5D0\uB9CC \uCD9C\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process \uC624\uB958"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode \uC624\uB958: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "\uC624\uB958: xpath select \uD45C\uD604\uC2DD(-select)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "XSLProcessor\uB97C \uC9C1\uB82C\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_NO_INPUT_STYLESHEET, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC785\uB825\uAC12\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCC98\uB9AC\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4!"}, + + {ER_COULDNT_PARSE_DOC, + "{0} \uBB38\uC11C\uC758 \uAD6C\uBB38\uC744 \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_COULDNT_FIND_FRAGMENT, + "\uBD80\uBD84\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "\uBD80\uBD84 \uC2DD\uBCC4\uC790\uAC00 \uAC00\uB9AC\uD0A8 \uB178\uB4DC\uB294 \uC694\uC18C\uAC00 \uC544\uB2D8: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each\uC5D0\uB294 match \uB610\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates\uC5D0\uB294 match \uB610\uB294 name \uC18D\uC131\uC774 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\uBB38\uC11C \uBD80\uBD84\uC758 \uBCF5\uC81C\uBCF8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_CANT_CREATE_ITEM, + "\uACB0\uACFC \uD2B8\uB9AC\uC5D0 \uD56D\uBAA9\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "\uC18C\uC2A4 XML\uC758 xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "{0}\uC5D0 \uB300\uD55C xsl:key \uC120\uC5B8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_CANT_CREATE_URL, + "\uC624\uB958: {0}\uC5D0 \uB300\uD55C URL\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions\uB294 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \uC624\uB958"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC5D0\uC11C\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:output\uC744 \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:strip-space \uB610\uB294 xsl:preserve-space\uB97C \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result\uB294 \uB354 \uC774\uC0C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC2E0 xsl:output\uC744 \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\uC5D0 \uC798\uBABB\uB41C \uC18D\uC131\uC774 \uC788\uC74C: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "\uC54C \uC218 \uC5C6\uB294 XSL \uC694\uC18C: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort\uB294 xsl:apply-templates \uB610\uB294 xsl:for-each\uC640 \uD568\uAED8\uB9CC \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when\uC774 xsl:choose\uC5D0 \uC758\uD574 \uC0C1\uC704\uB85C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise\uC758 \uC704\uCE58\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise\uAC00 xsl:choose\uC5D0 \uC758\uD574 \uC0C1\uC704\uB85C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4!"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \uD15C\uD50C\uB9AC\uD2B8\uC5D0\uC11C\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0} \uD655\uC7A5 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4 {1}\uC744(\uB97C) \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uCCAB\uBC88\uC9F8 \uC694\uC18C\uB85C\uB9CC \uC784\uD3EC\uD2B8\uB97C \uC218\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4!"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\uC774(\uAC00) \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC744 \uC784\uD3EC\uD2B8\uD558\uACE0 \uC788\uC2B5\uB2C8\uB2E4!"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4!"}, + + {ER_SAX_EXCEPTION, + "SAX \uC608\uC678\uC0AC\uD56D"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "\uD568\uC218\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_XSLT_ERROR, + "XSLT \uC624\uB958"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "\uD615\uC2DD \uD328\uD134 \uBB38\uC790\uC5F4\uC5D0\uC11C\uB294 \uD1B5\uD654 \uAE30\uD638\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Document \uD568\uC218\uB294 \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 DOM\uC5D0\uC11C \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\uBE44\uC811\uB450\uC5B4 \uBD84\uC11D\uAE30\uC758 \uC811\uB450\uC5B4\uB97C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "\uC7AC\uC9C0\uC815 \uD655\uC7A5: \uD30C\uC77C \uC774\uB984\uC744 \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. file \uB610\uB294 select \uC18D\uC131\uC740 \uC801\uD569\uD55C \uBB38\uC790\uC5F4\uC744 \uBC18\uD658\uD574\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\uC7AC\uC9C0\uC815 \uD655\uC7A5\uC5D0 FormatterListener\uB97C \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes\uC758 \uC811\uB450\uC5B4\uAC00 \uBD80\uC801\uD569\uD568: {0}"}, + + {ER_MISSING_NS_URI, + "\uC9C0\uC815\uB41C \uC811\uB450\uC5B4\uC5D0 \uB300\uD55C \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uAC00 \uB204\uB77D\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_MISSING_ARG_FOR_OPTION, + "\uC635\uC158\uC5D0 \uB300\uD55C \uC778\uC218\uAC00 \uB204\uB77D\uB428: {0}"}, + + {ER_INVALID_OPTION, + "\uBD80\uC801\uD569\uD55C \uC635\uC158: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "\uC798\uBABB\uB41C \uD615\uC2DD \uBB38\uC790\uC5F4: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet\uC5D0\uB294 'version' \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4!"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "{0} \uC18D\uC131\uC5D0 \uC798\uBABB\uB41C \uAC12\uC774 \uC788\uC74C: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose\uC5D0\uB294 xsl:when\uC774 \uD544\uC694\uD569\uB2C8\uB2E4."}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each\uC5D0\uC11C\uB294 xsl:apply-imports\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "\uCD9C\uB825 DOM \uB178\uB4DC\uC5D0 DTMLiaison\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB300\uC2E0 com.sun.org.apache.xpath.internal.DOM2Helper\uB97C \uC804\uB2EC\uD558\uC2ED\uC2DC\uC624!"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "\uC785\uB825 DOM \uB178\uB4DC\uC5D0 DTMLiaison\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB300\uC2E0 com.sun.org.apache.xpath.internal.DOM2Helper\uB97C \uC804\uB2EC\uD558\uC2ED\uC2DC\uC624!"}, + + {ER_CALL_TO_EXT_FAILED, + "\uD655\uC7A5 \uC694\uC18C\uC5D0 \uB300\uD55C \uD638\uCD9C \uC2E4\uD328: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "\uC811\uB450\uC5B4\uB294 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uB85C \uBD84\uC11D\uB418\uC5B4\uC57C \uD568: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "\uBD80\uC801\uD569\uD55C UTF-16 \uB300\uB9AC \uC694\uC18C\uAC00 \uAC10\uC9C0\uB428: {0}"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0}\uC774(\uAC00) \uC790\uC2E0\uC744 \uC0AC\uC6A9\uD588\uC2B5\uB2C8\uB2E4. \uC774 \uACBD\uC6B0 \uBB34\uD55C \uB8E8\uD504\uAC00 \uBC1C\uC0DD\uD569\uB2C8\uB2E4."}, + + {ER_CANNOT_MIX_XERCESDOM, + "\uBE44Xerces-DOM \uC785\uB825\uACFC Xerces-DOM \uCD9C\uB825\uC744 \uD568\uAED8 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "ElemTemplateElement.readObject\uC5D0 \uC624\uB958 \uBC1C\uC0DD: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "\uBA85\uBA85\uB41C \uD15C\uD50C\uB9AC\uD2B8\uB97C \uB450 \uAC1C \uC774\uC0C1 \uCC3E\uC74C: {0}"}, + + {ER_INVALID_KEY_CALL, + "\uBD80\uC801\uD569\uD55C \uD568\uC218 \uD638\uCD9C: recursive key() \uD638\uCD9C\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_REFERENCING_ITSELF, + "{0} \uBCC0\uC218\uAC00 \uC9C1\uC811 \uB610\uB294 \uAC04\uC811\uC801\uC73C\uB85C \uC790\uC2E0\uC744 \uCC38\uC870\uD558\uACE0 \uC788\uC2B5\uB2C8\uB2E4!"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates\uC758 DOMSource\uC5D0 \uB300\uD55C \uC785\uB825 \uB178\uB4DC\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "{0} \uC635\uC158\uC5D0 \uB300\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "\uD544\uC218 \uC694\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_URI_CANNOT_BE_NULL, + "URI\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_FILE_CANNOT_BE_NULL, + "\uD30C\uC77C\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource\uB294 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_INIT_BSFMGR, + "BSF \uAD00\uB9AC\uC790\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_CMPL_EXTENSN, + "\uD655\uC7A5\uC744 \uCEF4\uD30C\uC77C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_CREATE_EXTENSN, + "{0} \uD655\uC7A5\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uB294 \uC6D0\uC778: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "{0} \uBA54\uC18C\uB4DC\uC5D0 \uB300\uD55C \uC778\uC2A4\uD134\uC2A4 \uBA54\uC18C\uB4DC\uC5D0\uB294 \uAC1D\uCCB4 \uC778\uC2A4\uD134\uC2A4\uAC00 \uCCAB\uBC88\uC9F8 \uC778\uC218\uB85C \uD544\uC694\uD569\uB2C8\uB2E4."}, + + {ER_INVALID_ELEMENT_NAME, + "\uBD80\uC801\uD569\uD55C \uC694\uC18C \uC774\uB984\uC774 \uC9C0\uC815\uB428: {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "\uC694\uC18C \uC774\uB984 \uBA54\uC18C\uB4DC\uB294 \uC815\uC801 {0}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "\uD655\uC7A5 \uD568\uC218 {0}: {1}\uC744(\uB97C) \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "{0}\uC5D0 \uB300\uD55C \uC0DD\uC131\uC790\uC640 \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + {ER_MORE_MATCH_METHOD, + "{0} \uBA54\uC18C\uB4DC\uC640 \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + {ER_MORE_MATCH_ELEMENT, + "\uC694\uC18C \uBA54\uC18C\uB4DC {0}\uACFC(\uC640) \uAC00\uC7A5 \uC798 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uB450 \uAC1C \uC774\uC0C1 \uC788\uC2B5\uB2C8\uB2E4."}, + + {ER_INVALID_CONTEXT_PASSED, + "{0} \uD3C9\uAC00\uB97C \uC704\uD574 \uBD80\uC801\uD569\uD55C \uCEE8\uD14D\uC2A4\uD2B8\uAC00 \uC804\uB2EC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_POOL_EXISTS, + "\uD480\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4."}, + + {ER_NO_DRIVER_NAME, + "\uC9C0\uC815\uB41C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NO_URL, + "\uC9C0\uC815\uB41C URL\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "\uD480 \uD06C\uAE30\uAC00 1\uBCF4\uB2E4 \uC791\uC2B5\uB2C8\uB2E4!"}, + + {ER_INVALID_DRIVER, + "\uBD80\uC801\uD569\uD55C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + {ER_NO_STYLESHEETROOT, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB8E8\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space\uC5D0 \uB300\uD55C \uAC12\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "[{0}] \uB9AC\uC18C\uC2A4\uAC00 \uB2E4\uC74C\uC744 \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC74C: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\uBC84\uD37C \uD06C\uAE30 <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\uD655\uC7A5\uC744 \uD638\uCD9C\uD558\uB294 \uC911 \uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_NO_NAMESPACE_DECL, + "{0} \uC811\uB450\uC5B4\uC5D0 \uD574\uB2F9\uD558\uB294 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC120\uC5B8\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "lang=javaclass {0}\uC5D0 \uB300\uD574\uC11C\uB294 \uC694\uC18C \uCF58\uD150\uCE20\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uAC00 \uC885\uB8CC\uB97C \uC9C0\uC815\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_ONE_OR_TWO, + "1 \uB610\uB294 2"}, + + {ER_TWO_OR_THREE, + "2 \uB610\uB294 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "{0}\uC744(\uB97C) \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. CLASSPATH\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624. \uD604\uC7AC \uAE30\uBCF8\uAC12\uB9CC \uC0AC\uC6A9\uD558\uB294 \uC911\uC785\uB2C8\uB2E4."}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\uAE30\uBCF8 \uD15C\uD50C\uB9AC\uD2B8\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_RESULT_NULL, + "\uACB0\uACFC\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_RESULT_COULD_NOT_BE_SET, + "\uACB0\uACFC\uB97C \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NO_OUTPUT_SPECIFIED, + "\uC9C0\uC815\uB41C \uCD9C\uB825\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "{0} \uC720\uD615\uC758 \uACB0\uACFC\uB85C \uBCC0\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "{0} \uC720\uD615\uC758 \uC18C\uC2A4\uB97C \uBCC0\uD658\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NULL_CONTENT_HANDLER, + "\uB110 \uCF58\uD150\uCE20 \uCC98\uB9AC\uAE30"}, + + {ER_NULL_ERROR_HANDLER, + "\uB110 \uC624\uB958 \uCC98\uB9AC\uAE30"}, + + {ER_CANNOT_CALL_PARSE, + "ContentHandler\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC740 \uACBD\uC6B0 parse\uB97C \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NO_PARENT_FOR_FILTER, + "\uD544\uD130\uC5D0 \uB300\uD55C \uC0C1\uC704\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "{0}\uC5D0\uC11C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uB9E4\uCCB4 = {1}"}, + + {ER_NO_STYLESHEET_PI, + "{0}\uC5D0\uC11C xml-stylesheet PI\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NOT_SUPPORTED, + "\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "{0} \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 \uBD80\uC6B8 \uC778\uC2A4\uD134\uC2A4\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "{0}\uC5D0 \uC788\uB294 \uC678\uBD80 \uC2A4\uD06C\uB9BD\uD2B8\uB85C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_RESOURCE_COULD_NOT_FIND, + "[{0}] \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\uCD9C\uB825 \uC18D\uC131\uC744 \uC778\uC2DD\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "ElemLiteralResult \uC778\uC2A4\uD134\uC2A4 \uC0DD\uC131\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "{0}\uC5D0 \uB300\uD55C \uAC12\uC5D0\uB294 \uAD6C\uBB38\uC744 \uBD84\uC11D\uD560 \uC218 \uC788\uB294 \uC22B\uC790\uAC00 \uD3EC\uD568\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_VALUE_SHOULD_EQUAL, + "{0}\uC5D0 \uB300\uD55C \uAC12\uC740 yes \uB610\uB294 no\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_FAILED_CALLING_METHOD, + "{0} \uBA54\uC18C\uB4DC \uD638\uCD9C\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_FAILED_CREATING_ELEMTMPL, + "ElemTemplateElement \uC778\uC2A4\uD134\uC2A4 \uC0DD\uC131\uC744 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + + {ER_CHARS_NOT_ALLOWED, + "\uBB38\uC11C\uC758 \uC774 \uC9C0\uC810\uC5D0\uC11C\uB294 \uBB38\uC790\uAC00 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + {ER_ATTR_NOT_ALLOWED, + "{1} \uC694\uC18C\uC5D0\uC11C\uB294 \"{0}\" \uC18D\uC131\uC774 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_BAD_VALUE, + "{0}: \uC798\uBABB\uB41C \uAC12 {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "{0} \uC18D\uC131\uAC12\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} \uC18D\uC131\uAC12\uC744 \uC778\uC2DD\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. "}, + + {ER_NULL_URI_NAMESPACE, + "\uB110 URI\uB97C \uC0AC\uC6A9\uD558\uC5EC \uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC811\uB450\uC5B4\uB97C \uC0DD\uC131\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911"}, + + {ER_NUMBER_TOO_BIG, + "\uAC00\uC7A5 \uD070 Long \uC815\uC218\uBCF4\uB2E4 \uD070 \uC22B\uC790\uC758 \uD615\uC2DD\uC744 \uC9C0\uC815\uD558\uB824\uACE0 \uC2DC\uB3C4\uD558\uB294 \uC911"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC744(\uB97C) \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) \uBC1C\uACAC\uB418\uC5C8\uC9C0\uB9CC \uD574\uB2F9 \uD074\uB798\uC2A4\uB97C \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) \uB85C\uB4DC\uB418\uC5C8\uC9C0\uB9CC \uD574\uB2F9 \uD074\uB798\uC2A4\uB97C \uC778\uC2A4\uD134\uC2A4\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \uB4DC\uB77C\uC774\uBC84 \uD074\uB798\uC2A4 {0}\uC774(\uAC00) org.xml.sax.Parser\uB97C \uAD6C\uD604\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\uC2DC\uC2A4\uD15C \uC18D\uC131 org.xml.sax.parser\uAC00 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "\uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC778\uC218\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_FEATURE, + "\uAE30\uB2A5: {0}"}, + + {ER_PROPERTY, + "\uC18D\uC131: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "\uB110 \uC5D4\uD2F0\uD2F0 \uBD84\uC11D\uAE30"}, + + {ER_NULL_DTD_HANDLER, + "\uB110 DTD \uCC98\uB9AC\uAE30"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "\uC9C0\uC815\uB41C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_NO_URL_SPECIFIED, + "\uC9C0\uC815\uB41C URL\uC774 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "\uD480 \uD06C\uAE30\uAC00 1 \uBBF8\uB9CC\uC785\uB2C8\uB2E4!"}, + + {ER_INVALID_DRIVER_NAME, + "\uBD80\uC801\uD569\uD55C \uB4DC\uB77C\uC774\uBC84 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "\uD504\uB85C\uADF8\uB798\uBA38 \uC624\uB958\uC785\uB2C8\uB2E4! \uD45C\uD604\uC2DD\uC5D0 ElemTemplateElement \uC0C1\uC704\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator\uC5D0 \uD504\uB85C\uADF8\uB798\uBA38 \uAC80\uC99D\uC774 \uC788\uC74C: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uC774 \uC704\uCE58\uC5D0\uB294 {0}\uC774(\uAC00) \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC758 \uC774 \uC704\uCE58\uC5D0\uB294 \uACF5\uBC31\uC774 \uC544\uB2CC \uD14D\uC2A4\uD2B8\uB294 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) CHAR \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}. CHAR \uC720\uD615\uC758 \uC18D\uC131\uC740 1\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) QNAME \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) ENUM \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0}. \uC801\uD569\uD55C \uAC12: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) NMTOKEN \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) NCNAME \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) boolean \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "\uC798\uBABB\uB41C \uAC12: {1}\uC774(\uAC00) number \uC18D\uC131\uC5D0 \uC0AC\uC6A9\uB428: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "\uC77C\uCE58 \uD328\uD134\uC758 {0}\uC5D0 \uB300\uD55C \uC778\uC218\uB294 \uB9AC\uD130\uB7F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "\uC804\uC5ED \uBCC0\uC218 \uC120\uC5B8\uC774 \uC911\uBCF5\uB429\uB2C8\uB2E4."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "\uBCC0\uC218 \uC120\uC5B8\uC774 \uC911\uBCF5\uB429\uB2C8\uB2E4."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template\uC5D0\uB294 name \uB610\uB294 match \uC18D\uC131 \uC911 \uD558\uB098\uAC00 \uC788\uAC70\uB098 \uBAA8\uB450 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "exclude-result-prefixes\uC758 \uC811\uB450\uC5B4\uAC00 \uBD80\uC801\uD569\uD568: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "\uC774\uB984\uC774 {0}\uC778 attribute-set\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "\uC774\uB984\uC774 {0}\uC778 \uD568\uC218\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0} \uC694\uC18C\uC5D0\uB294 content \uC18D\uC131\uACFC select \uC18D\uC131\uC774 \uD568\uAED8 \uD3EC\uD568\uB418\uC9C0 \uC54A\uC544\uC57C \uD569\uB2C8\uB2E4."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "{0} \uB9E4\uAC1C\uBCC0\uC218\uC758 \uAC12\uC740 \uC801\uD569\uD55C Java \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4."}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \uC694\uC18C\uC758 result-prefix \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 '#default'\uC774\uC9C0\uB9CC \uC694\uC18C\uC5D0 \uB300\uD55C \uBC94\uC704\uC5D0\uC11C \uAE30\uBCF8 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uAC00 \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \uC694\uC18C\uC758 result-prefix \uC18D\uC131\uC5D0 \uB300\uD55C \uAC12\uC740 ''{0}''\uC774\uC9C0\uB9CC \uC694\uC18C\uC5D0 \uB300\uD55C \uBC94\uC704\uC5D0\uC11C ''{0}'' \uC811\uB450\uC5B4\uC758 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uAC00 \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + {ER_SET_FEATURE_NULL_NAME, + "\uAE30\uB2A5 \uC774\uB984\uC740 TransformerFactory.setFeature(\uBB38\uC790\uC5F4 \uC774\uB984, \uBD80\uC6B8 \uAC12)\uC5D0\uC11C \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_GET_FEATURE_NULL_NAME, + "\uAE30\uB2A5 \uC774\uB984\uC740 TransformerFactory.getFeature(\uBB38\uC790\uC5F4 \uC774\uB984)\uC5D0\uC11C \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_UNSUPPORTED_FEATURE, + "\uC774 TransformerFactory\uC5D0\uC11C ''{0}'' \uAE30\uB2A5\uC744 \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\uBCF4\uC548 \uCC98\uB9AC \uAE30\uB2A5\uC774 true\uB85C \uC124\uC815\uB41C \uACBD\uC6B0 \uD655\uC7A5 \uC694\uC18C ''{0}''\uC744(\uB97C) \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\uB110 \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uC5D0 \uB300\uD55C \uC811\uB450\uC5B4\uB97C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\uB110 \uC811\uB450\uC5B4\uC5D0 \uB300\uD55C \uB124\uC784\uC2A4\uD398\uC774\uC2A4 URI\uB97C \uAC00\uC838\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "\uD568\uC218 \uC774\uB984\uC740 \uB110\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "\uC778\uC790 \uC218\uB294 \uC74C\uC218\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "'}'\uB97C \uCC3E\uC558\uC9C0\uB9CC \uC5F4\uB824 \uC788\uB294 \uC18D\uC131 \uD15C\uD50C\uB9AC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\uACBD\uACE0: count \uC18D\uC131\uC774 xsl:number\uC758 \uC870\uC0C1\uACFC \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4! \uB300\uC0C1 = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\uC774\uC804 \uAD6C\uBB38: 'expr' \uC18D\uC131\uC758 \uC774\uB984\uC774 'select'\uB85C \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan\uC774 format-number \uD568\uC218\uC5D0\uC11C \uB85C\uCF00\uC77C \uC774\uB984\uC744 \uC544\uC9C1 \uCC98\uB9AC\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, + + {WG_LOCALE_NOT_FOUND, + "\uACBD\uACE0: xml:lang={0}\uC5D0 \uB300\uD55C \uB85C\uCF00\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {WG_CANNOT_MAKE_URL_FROM, + "{0}\uC5D0\uC11C URL\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "\uC694\uCCAD\uB41C \uBB38\uC11C\uB97C \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC74C: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + ">>>>>> Xalan \uBC84\uC804 "}, + {"version2", "<<<<<<<"}, + {"yes", "\uC608"}, + {"line", "\uD589 \uBC88\uD638"}, + {"column", "\uC5F4 \uBC88\uD638"}, + {"xsldone", "XSLProcessor: \uC644\uB8CC"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J \uBA85\uB839\uD589 Process \uD074\uB798\uC2A4 \uC635\uC158:"}, + {"xslProc_option", "Xalan-J \uBA85\uB839\uD589 Process \uD074\uB798\uC2A4 \uC635\uC158:"}, + {"xslProc_invalid_xsltc_option", "XSLTC \uBAA8\uB4DC\uC5D0\uC11C\uB294 {0} \uC635\uC158\uC774 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."}, + {"xslProc_invalid_xalan_option", "{0} \uC635\uC158\uC740 -XSLTC\uC5D0\uB9CC \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + {"xslProc_no_input", "\uC624\uB958: \uC9C0\uC815\uB41C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB610\uB294 \uC785\uB825 xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \uC0AC\uC6A9\uBC95 \uC9C0\uCE68\uC5D0 \uB300\uD55C \uC635\uC158 \uC5C6\uC774 \uC774 \uBA85\uB839\uC744 \uC2E4\uD589\uD558\uC2ED\uC2DC\uC624."}, + {"xslProc_common_options", "-\uC77C\uBC18 \uC635\uC158-"}, + {"xslProc_xalan_options", "-Xalan \uC635\uC158-"}, + {"xslProc_xsltc_options", "-XSLTC \uC635\uC158-"}, + {"xslProc_return_to_continue", "(\uACC4\uC18D\uD558\uB824\uBA74 \uD0A4\uB97C \uB204\uB974\uC2ED\uC2DC\uC624.)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC(\uBCC0\uD658\uC5D0 XSLTC \uC0AC\uC6A9)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER \uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC5F0\uACB0\uC758 \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984]"}, + {"optionE", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, + {"optionV", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, + {"optionQC", " [-QC(\uC790\uB3D9 \uD328\uD134 \uCDA9\uB3CC \uACBD\uACE0)]"}, + {"optionQ", " [-Q(\uC790\uB3D9 \uBAA8\uB4DC)]"}, + {"optionLF", " [-LF(\uCD9C\uB825\uC5D0\uB9CC \uC904 \uBC14\uAFC8 \uC0AC\uC6A9 {\uAE30\uBCF8\uAC12: CR/LF})]"}, + {"optionCR", " [-CR(\uCD9C\uB825\uC5D0\uB9CC \uCE90\uB9AC\uC9C0 \uB9AC\uD134 \uC0AC\uC6A9 {\uAE30\uBCF8\uAC12: CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE(\uC774\uC2A4\uCF00\uC774\uD504 \uBB38\uC790 {\uAE30\uBCF8\uAC12: <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT(\uB4E4\uC5EC \uC4F8 \uACF5\uBC31 \uC218 \uC81C\uC5B4 {\uAE30\uBCF8\uAC12: 0})]"}, + {"optionTT", " [-TT(\uD15C\uD50C\uB9AC\uD2B8 \uD638\uCD9C \uC2DC \uCD94\uC801)]"}, + {"optionTG", " [-TG(\uAC01 \uC0DD\uC131 \uC774\uBCA4\uD2B8 \uCD94\uC801)]"}, + {"optionTS", " [-TS(\uAC01 \uC120\uD0DD \uC774\uBCA4\uD2B8 \uCD94\uC801)]"}, + {"optionTTC", " [-TTC(\uD15C\uD50C\uB9AC\uD2B8 \uD558\uC704 \uD56D\uBAA9 \uCC98\uB9AC \uC2DC \uCD94\uC801)]"}, + {"optionTCLASS", " [-TCLASS(\uCD94\uC801 \uD655\uC7A5\uC5D0 \uB300\uD55C TraceListener \uD074\uB798\uC2A4)]"}, + {"optionVALIDATE", " [-VALIDATE(\uAC80\uC99D \uC5EC\uBD80 \uC124\uC815. \uAE30\uBCF8\uC801\uC73C\uB85C \uAC80\uC99D\uC740 \uD574\uC81C\uB418\uC5B4 \uC788\uC74C)]"}, + {"optionEDUMP", " [-EDUMP {\uC120\uD0DD\uC801 \uD30C\uC77C \uC774\uB984}(\uC624\uB958 \uBC1C\uC0DD \uC2DC \uC2A4\uD0DD \uB364\uD504)]"}, + {"optionXML", " [-XML(XML \uD3EC\uB9F7\uD130 \uC0AC\uC6A9 \uBC0F XML \uD5E4\uB354 \uCD94\uAC00)]"}, + {"optionTEXT", " [-TEXT(\uAC04\uB2E8\uD55C \uD14D\uC2A4\uD2B8 \uD3EC\uB9F7\uD130 \uC0AC\uC6A9)]"}, + {"optionHTML", " [-HTML(HTML \uD3EC\uB9F7\uD130 \uC0AC\uC6A9)]"}, + {"optionPARAM", " [-PARAM \uC774\uB984 \uD45C\uD604\uC2DD(\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB9E4\uAC1C\uBCC0\uC218 \uC124\uC815)]"}, + {"noParsermsg1", "XSL \uD504\uB85C\uC138\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, + {"noParsermsg2", "** \uAD6C\uBB38 \uBD84\uC11D\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C **"}, + {"noParsermsg3", "\uD074\uB798\uC2A4 \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624."}, + {"noParsermsg4", "IBM\uC758 Java\uC6A9 XML \uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC5C6\uC744 \uACBD\uC6B0 \uB2E4\uC74C \uC704\uCE58\uC5D0\uC11C \uB2E4\uC6B4\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + {"noParsermsg5", "IBM AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(URI \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 URIResolver)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(\uC5D4\uD2F0\uD2F0 \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 EntityResolver)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(\uCD9C\uB825 \uC9C1\uB82C\uD654\uC5D0 \uC0AC\uC6A9\uD560 ContentHandler)]"}, + {"optionLINENUMBERS", " [-L(\uC18C\uC2A4 \uBB38\uC11C\uC5D0 \uD589 \uBC88\uD638 \uC0AC\uC6A9)]"}, + {"optionSECUREPROCESSING", " [-SECURE(\uBCF4\uC548 \uCC98\uB9AC \uAE30\uB2A5\uC744 true\uB85C \uC124\uC815)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType(media \uC18D\uC131\uC744 \uC0AC\uC6A9\uD558\uC5EC \uBB38\uC11C\uC640 \uC5F0\uAD00\uB41C \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCC3E\uAE30)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName(\uBCC0\uD658\uC5D0 \uBA85\uC2DC\uC801\uC73C\uB85C s2s=SAX \uB610\uB294 d2d=DOM \uC0AC\uC6A9)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG(\uBCC0\uD658\uC5D0 \uAC78\uB9B0 \uCD1D \uC2DC\uAC04(\uBC00\uB9AC\uCD08) \uC778\uC1C4)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL(http://xml.apache.org/xalan/features/incremental\uC744 true\uB85C \uC124\uC815\uD558\uC5EC \uC99D\uBD84\uC801 DTM \uC0DD\uC131 \uC694\uCCAD)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE(http://xml.apache.org/xalan/features/optimize\uB97C false\uB85C \uC124\uC815\uD558\uC5EC \uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uCD5C\uC801\uD654 \uCC98\uB9AC \uC548\uD568 \uC694\uCCAD)]"}, + {"optionRL", " [-RL recursionlimit(\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC21C\uD658 \uAE4A\uC774\uC5D0 \uB300\uD55C \uC22B\uC790 \uC81C\uD55C \uAC80\uC99D)]"}, + {"optionXO", " [-XO [transletName](\uC0DD\uC131\uB41C translet\uC5D0 \uC774\uB984 \uC9C0\uC815)]"}, + {"optionXD", " [-XD destinationDirectory(translet\uC5D0 \uB300\uD55C \uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC \uC9C0\uC815)]"}, + {"optionXJ", " [-XJ jarfile(translet \uD074\uB798\uC2A4\uB97C \uC774\uB984\uC758 jar \uD30C\uC77C\uB85C \uD328\uD0A4\uC9C0\uD654)]"}, + {"optionXP", " [-XP package(\uC0DD\uC131\uB41C \uBAA8\uB4E0 translet \uD074\uB798\uC2A4\uC5D0 \uB300\uD55C \uD328\uD0A4\uC9C0 \uC774\uB984 \uC811\uB450\uC5B4 \uC9C0\uC815)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN(\uD15C\uD50C\uB9AC\uD2B8 \uC778\uB77C\uC778\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815)]"}, + {"optionXX", " [-XX(\uCD94\uAC00 \uB514\uBC84\uAE45 \uBA54\uC2DC\uC9C0 \uCD9C\uB825 \uC124\uC815)]"}, + {"optionXT", " [-XT(\uAC00\uB2A5\uD55C \uACBD\uC6B0 \uBCC0\uD658\uC5D0 translet \uC0AC\uC6A9)]"}, + {"diagTiming", " --------- {1}\uC744(\uB97C) \uD1B5\uD55C {0} \uBCC0\uD658\uC5D0 {2}\uBC00\uB9AC\uCD08\uAC00 \uAC78\uB838\uC2B5\uB2C8\uB2E4."}, + {"recursionTooDeep", "\uD15C\uD50C\uB9AC\uD2B8\uAC00 \uB108\uBB34 \uAE4A\uAC8C \uC911\uCCA9\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC911\uCCA9 = {0}, \uD15C\uD50C\uB9AC\uD2B8: {1} {2}"}, + {"nameIs", "\uC774\uB984:"}, + {"matchPatternIs", "\uC77C\uCE58 \uD328\uD134:"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java new file mode 100644 index 0000000..2ef9aa4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_pt_BR extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Erro: N\u00E3o \u00E9 poss\u00EDvel utilizar ''{'' na express\u00E3o"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} tem um atributo inv\u00E1lido: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode \u00E9 nulo em xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "N\u00E3o \u00E9 poss\u00EDvel adicionar {0} a {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u00E9 nulo em handleApplyTemplatesInstruction!"}, + + {ER_NO_NAME_ATTRIB, + "{0} deve ter um atributo de nome."}, + + {ER_TEMPLATE_NOT_FOUND, + "N\u00E3o foi poss\u00EDvel localizar o modelo com o nome: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "N\u00E3o foi poss\u00EDvel resolver o nome AVT em xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} requer o atributo: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} deve ter um atributo ''test''."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Valor inv\u00E1lido no atributo de n\u00EDvel: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "o nome da instru\u00E7\u00E3o de processamento n\u00E3o pode ser 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "o nome da instru\u00E7\u00E3o de processamento deve ser um NCName v\u00E1lido: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} deve ter um atributo de correspond\u00EAncia se tiver um modo."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} requer um atributo de nome ou de correspond\u00EAncia."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "N\u00E3o \u00E9 poss\u00EDvel resolver o prefixo do namespace: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space tem um valor inv\u00E1lido: {0}"}, + + {ER_NO_OWNERDOC, + "O n\u00F3 filho n\u00E3o tem um documento de propriet\u00E1rio!"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "Erro de ElemTemplateElement: {0}"}, + + {ER_NULL_CHILD, + "Tentativa de adicionar um filho nulo!"}, + + {ER_NEED_SELECT_ATTRIB, + "{0} requer um atributo de sele\u00E7\u00E3o."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when deve ter um atributo 'test'."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param deve ter um atributo 'name'."}, + + {ER_NO_CONTEXT_OWNERDOC, + "o contexto n\u00E3o tem um documento de propriet\u00E1rio!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "N\u00E3o foi poss\u00EDvel criar a Liga\u00E7\u00E3o TransformerFactory XML: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: O processo n\u00E3o foi bem-sucedido."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: N\u00E3o foi bem-sucedido."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Codifica\u00E7\u00E3o n\u00E3o suportada: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "N\u00E3o foi poss\u00EDvel criar TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key requer um atributo 'name'!"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key requer um atributo 'match'!"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key requer um atributo 'use'!"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} requer um atributo ''elements''!"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) o atributo ''prefix'' de {0} n\u00E3o foi encontrado"}, + + {ER_BAD_STYLESHEET_URL, + "O URL da Folha de Estilos est\u00E1 incorreto: {0}"}, + + {ER_FILE_NOT_FOUND, + "O arquivo da folha de estilos n\u00E3o foi encontrado: {0}"}, + + {ER_IOEXCEPTION, + "Exce\u00E7\u00E3o de E/S com o arquivo de folha de estilos: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) N\u00E3o foi poss\u00EDvel encontrar o atributo href para {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) A folha de estilos {0} est\u00E1 incluindo a si mesma direta ou indiretamente!"}, + + {ER_PROCESSINCLUDE_ERROR, + "Erro de StylesheetHandler.processInclude: {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) O atributo ''lang'' de {0} n\u00E3o foi encontrado"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) elemento {0} incorretamente posicionado?? Elemento ''component'' do container n\u00E3o encontrado"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Sa\u00EDda permitida somente para Element, DocumentFragment, Document ou PrintWriter."}, + + {ER_PROCESS_ERROR, + "Erro de StylesheetRoot.process"}, + + {ER_UNIMPLNODE_ERROR, + "Erro de UnImplNode: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Erro! N\u00E3o foi poss\u00EDvel localizar a express\u00E3o de sele\u00E7\u00E3o xpath (-select)."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "N\u00E3o \u00E9 poss\u00EDvel serializar um XSLProcessor!"}, + + {ER_NO_INPUT_STYLESHEET, + "A entrada da folha de estilos n\u00E3o foi especificada!"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Falha ao processar a folha de estilos!"}, + + {ER_COULDNT_PARSE_DOC, + "N\u00E3o foi poss\u00EDvel fazer parsing do documento {0}!"}, + + {ER_COULDNT_FIND_FRAGMENT, + "N\u00E3o foi poss\u00EDvel localizar o fragmento: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "O n\u00F3 indicado pelo identificador de fragmento n\u00E3o era um elemento: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each deve ter um atributo de correspond\u00EAncia ou de nome"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "os modelos devem ter um atributo de correspond\u00EAncia ou de nome"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "N\u00E3o h\u00E1 clone de um fragmento de documento!"}, + + {ER_CANT_CREATE_ITEM, + "N\u00E3o \u00E9 poss\u00EDvel criar um item em uma \u00E1rvore de resultados: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space no XML de origem tem um valor inv\u00E1lido: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "N\u00E3o h\u00E1 uma declara\u00E7\u00E3o de xsl:key para {0}!"}, + + {ER_CANT_CREATE_URL, + "Erro! N\u00E3o \u00E9 poss\u00EDvel criar o url para: {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions n\u00E3o \u00E9 suportado"}, + + {ER_PROCESSOR_ERROR, + "Erro de TransformerFactory XSLT"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} n\u00E3o \u00E9 permitido em uma folha de estilos!"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:output."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "padr\u00E3o-space n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:strip-space ou xsl:preserve-space."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result n\u00E3o \u00E9 mais suportado! Em vez disso, use xsl:output."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} tem um atributo inv\u00E1lido: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Elemento XSL desconhecido: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort s\u00F3 pode ser usado com xsl:apply-templates ou xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when posicionado incorretamente!"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when n\u00E3o relacionado a xsl:choose!"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise posicionado incorretamente!"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise n\u00E3o relacionado a xsl:choose!"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} n\u00E3o \u00E9 permitido em um modelo!"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) prefixo {1} de namespace da extens\u00E3o de {0} desconhecido"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) As importa\u00E7\u00F5es s\u00F3 podem ocorrer como os primeiros elementos na folha de estilos!"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) A folha de estilos {0} est\u00E1 importando a si mesmo(a) direta ou indiretamente!"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space tem um valor inv\u00E1lido: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet malsucedido!"}, + + {ER_SAX_EXCEPTION, + "Exce\u00E7\u00E3o de SAX"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Fun\u00E7\u00E3o n\u00E3o suportada!"}, + + {ER_XSLT_ERROR, + "Erro de XSLT"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "sinal de moeda n\u00E3o permitido na string de padr\u00E3o de formato"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Fun\u00E7\u00E3o do documento n\u00E3o suportada no DOM da Folha de estilos!"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "N\u00E3o \u00E9 poss\u00EDvel resolver o prefixo de um resolvedor sem Prefixo!"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirecionar extens\u00E3o: N\u00E3o foi poss\u00EDvel obter o nome do arquivo - o arquivo ou o atributo de sele\u00E7\u00E3o deve retornar uma string v\u00E1lida."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "N\u00E3o \u00E9 poss\u00EDvel criar FormatterListener na extens\u00E3o de Redirecionamento!"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "O prefixo em exclude-result-prefixes n\u00E3o \u00E9 v\u00E1lido: {0}"}, + + {ER_MISSING_NS_URI, + "URI do namespace n\u00E3o encontrado para o prefixo especificado"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Argumento n\u00E3o encontrado para a op\u00E7\u00E3o: {0}"}, + + {ER_INVALID_OPTION, + "Op\u00E7\u00E3o inv\u00E1lida: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "String de formato incorreta: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet requer um atributo 'version'!"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "Atributo: {0} tem um valor inv\u00E1lido: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose requer um xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports n\u00E3o permitido em um xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "N\u00E3o \u00E9 poss\u00EDvel usar um DTMLiaison para um n\u00F3 DOM de sa\u00EDda... em vez disso, especifique um com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "N\u00E3o \u00E9 poss\u00EDvel usar um DTMLiaison para um n\u00F3 DOM de entrada... em vez disso, especifique um com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + {ER_CALL_TO_EXT_FAILED, + "Falha ao chamar o elemento da extens\u00E3o: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "O prefixo deve ser resolvido para um namespace: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Foi detectado um substituto de UTF-16 inv\u00E1lido: {0} ?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} usou ele mesmo, o que causar\u00E1 um loop infinito."}, + + {ER_CANNOT_MIX_XERCESDOM, + "N\u00E3o \u00E9 poss\u00EDvel misturar entrada n\u00E3o Xerces-DOM com sa\u00EDda Xerces-DOM!"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "No ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Foi encontrado mais de um modelo com o nome: {0}"}, + + {ER_INVALID_KEY_CALL, + "Chamada de fun\u00E7\u00E3o inv\u00E1lida: chamadas recursivas de key() n\u00E3o s\u00E3o permitidas"}, + + {ER_REFERENCING_ITSELF, + "A vari\u00E1vel {0} est\u00E1 importando ela mesma de forma direta ou indireta!"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "O n\u00F3 de entrada n\u00E3o pode ser nulo para um DOMSource para newTemplates!"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "O arquivo de classe n\u00E3o foi encontrado para a op\u00E7\u00E3o {0}"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "Elemento Obrigat\u00F3rio n\u00E3o encontrado: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream n\u00E3o pode ser nulo"}, + + {ER_URI_CANNOT_BE_NULL, + "O URI n\u00E3o pode ser nulo"}, + + {ER_FILE_CANNOT_BE_NULL, + "O arquivo n\u00E3o pode ser nulo"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource n\u00E3o pode ser nulo"}, + + {ER_CANNOT_INIT_BSFMGR, + "N\u00E3o foi poss\u00EDvel inicializar o Gerenciador de BSF"}, + + {ER_CANNOT_CMPL_EXTENSN, + "N\u00E3o foi poss\u00EDvel compilar a extens\u00E3o"}, + + {ER_CANNOT_CREATE_EXTENSN, + "N\u00E3o foi poss\u00EDvel criar a extens\u00E3o: {0} em decorr\u00EAncia de: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "A chamada do m\u00E9todo da inst\u00E2ncia para o m\u00E9todo {0} exige uma inst\u00E2ncia do Objeto como primeiro argumento"}, + + {ER_INVALID_ELEMENT_NAME, + "Nome de elemento inv\u00E1lido especificado {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "O m\u00E9todo do nome do elemento deve ser est\u00E1tico {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "Fun\u00E7\u00E3o da extens\u00E3o {0} : {1} desconhecido"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o construtor em rela\u00E7\u00E3o a {0}"}, + + {ER_MORE_MATCH_METHOD, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o m\u00E9todo {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "H\u00E1 mais de uma melhor correspond\u00EAncia para o m\u00E9todo do elemento {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Contexto inv\u00E1lido especificado para avaliar {0}"}, + + {ER_POOL_EXISTS, + "O pool j\u00E1 existe"}, + + {ER_NO_DRIVER_NAME, + "Nenhum Nome do driver especificado"}, + + {ER_NO_URL, + "Nenhum URL especificado"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "O tamanho do pool \u00E9 menor que um!"}, + + {ER_INVALID_DRIVER, + "Nome do driver inv\u00E1lido especificado!"}, + + {ER_NO_STYLESHEETROOT, + "A raiz da folha de estilos n\u00E3o foi encontrada!"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Valor inv\u00E1lido para xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "Falha em processFromNode"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "O recurso [ {0} ] n\u00E3o foi carregado: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Tamanho do buffer <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Erro desconhecido ao chamar a extens\u00E3o"}, + + {ER_NO_NAMESPACE_DECL, + "O prefixo {0} n\u00E3o tem uma declara\u00E7\u00E3o de namespace correspondente"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Conte\u00FAdo do elemento n\u00E3o permitido para lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "T\u00E9rmino direcionado da folha de estilos"}, + + {ER_ONE_OR_TWO, + "1 ou 2"}, + + {ER_TWO_OR_THREE, + "2 ou 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "N\u00E3o foi poss\u00EDvel carregar {0} (verificar CLASSPATH); usando agora apenas os padr\u00F5es"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "N\u00E3o \u00E9 poss\u00EDvel inicializar os modelos padr\u00E3o"}, + + {ER_RESULT_NULL, + "O resultado n\u00E3o deve ser nulo"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "N\u00E3o foi poss\u00EDvel definir o resultado"}, + + {ER_NO_OUTPUT_SPECIFIED, + "Nenhuma sa\u00EDda especificada"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "N\u00E3o \u00E9 poss\u00EDvel transformar um Resultado do tipo {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "N\u00E3o \u00E9 poss\u00EDvel transformar uma Origem do tipo {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Handler de conte\u00FAdo nulo"}, + + {ER_NULL_ERROR_HANDLER, + "Handler de erro nulo"}, + + {ER_CANNOT_CALL_PARSE, + "o parsing n\u00E3o poder\u00E1 ser chamado se o ContentHandler n\u00E3o tiver sido definido"}, + + {ER_NO_PARENT_FOR_FILTER, + "Nenhum pai para o filtro"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "Nenhuma folha de estilos encontrada em: {0}, m\u00EDdia= {1}"}, + + {ER_NO_STYLESHEET_PI, + "Nenhum PI de xml-stylesheet encontrado em: {0}"}, + + {ER_NOT_SUPPORTED, + "N\u00E3o suportado: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "O valor da propriedade {0} deve ser uma inst\u00E2ncia Booliana"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "N\u00E3o foi poss\u00EDvel obter um script externo em {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "N\u00E3o foi poss\u00EDvel encontrar o recurso [ {0} ].\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Propriedade de sa\u00EDda n\u00E3o reconhecida: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Falha ao criar a inst\u00E2ncia ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "O valor para {0} deve conter um n\u00FAmero pass\u00EDvel de parsing"}, + + {ER_VALUE_SHOULD_EQUAL, + "O valor para {0} deve ser igual a sim ou n\u00E3o"}, + + {ER_FAILED_CALLING_METHOD, + "Falha ao chamar o m\u00E9todo {0}"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Falha ao criar a inst\u00E2ncia ElemTemplateElement"}, + + {ER_CHARS_NOT_ALLOWED, + "Os caracteres n\u00E3o s\u00E3o permitidos neste ponto do documento"}, + + {ER_ATTR_NOT_ALLOWED, + "O atributo \"{0}\" n\u00E3o \u00E9 permitido no elemento {1}!"}, + + {ER_BAD_VALUE, + "{0} valor incorreto {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "valor do atributo {0} n\u00E3o encontrado "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Valor do atributo {0} n\u00E3o reconhecido "}, + + {ER_NULL_URI_NAMESPACE, + "Tentativa de gerar um prefixo do namespace com um URI nulo"}, + + {ER_NUMBER_TOO_BIG, + "Tentativa de formatar um n\u00FAmero maior que o n\u00FAmero inteiro Longo maior"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "N\u00E3o \u00E9 poss\u00EDvel localizar a classe do driver SAX1 {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "A classe do driver SAX1 {0} foi encontrada, mas n\u00E3o pode ser carregada"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "A classe do driver SAX1 {0} foi carregada, mas n\u00E3o pode ser instanciada"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "A classe do driver SAX1 {0} n\u00E3o implementa org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "A propriedade do sistema org.xml.sax.parser n\u00E3o foi especificada"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "O argumento de parser n\u00E3o pode ser nulo"}, + + {ER_FEATURE, + "Recurso: {0}"}, + + {ER_PROPERTY, + "Propriedade: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Resolvedor da entidade nulo"}, + + {ER_NULL_DTD_HANDLER, + "Handler de DTD nulo"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "Nenhum Nome do Driver Especificado!"}, + + {ER_NO_URL_SPECIFIED, + "Nenhum URL Especificado!"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "O tamanho do pool \u00E9 menor que 1!"}, + + {ER_INVALID_DRIVER_NAME, + "Nome do Driver Especificado Inv\u00E1lido!"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Erro do programador! A express\u00E3o n\u00E3o tem ElemTemplateElement pai!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Asser\u00E7\u00E3o do Programador no RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} n\u00E3o \u00E9 permitido(a) nesta posi\u00E7\u00E3o na folha de estilos!"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Texto sem espa\u00E7o em branco n\u00E3o permitido nesta posi\u00E7\u00E3o na folha de estilos!"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Valor inv\u00E1lido: {1} usado para o atributo CHAR: {0}. Um atributo do tipo CHAR deve ter somente 1 caractere!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Valor inv\u00E1lido: {1} usado para o atributo QNAME: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Valor inv\u00E1lido: {1} usado para o atributo ENUM: {0}. Os valores v\u00E1lidos s\u00E3o: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Valor inv\u00E1lido: {1} usado para o atributo NMTOKEN: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Valor inv\u00E1lido: {1} usado para o atributo NCNAME: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Valor inv\u00E1lido: {1} usado para o atributo boolean: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Valor inv\u00E1lido: {1} usado para o atributo do n\u00FAmero: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "O argumento para {0} no padr\u00E3o de correspond\u00EAncia deve ser um literal."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Declara\u00E7\u00E3o de vari\u00E1vel global duplicada."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Declara\u00E7\u00E3o de vari\u00E1vel duplicada."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template deve ter um atributo name ou match (ou ambos)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "O prefixo em exclude-result-prefixes n\u00E3o \u00E9 v\u00E1lido: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "o conjunto de atributos com o nome {0} n\u00E3o existe"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "A fun\u00E7\u00E3o com o nome {0} n\u00E3o existe"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "O elemento {0} n\u00E3o deve ter um conte\u00FAdo e um atributo select."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "O valor do par\u00E2metro {0} deve ser um Objeto Java v\u00E1lido"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "O atributo result-prefix de um elemento xsl:namespace-alias tem o valor '#padr\u00E3o', mas n\u00E3o h\u00E1 declara\u00E7\u00E3o do namespace padr\u00E3o no escopo do elemento"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "O atributo result-prefix de um elemento xsl:namespace-alias tem o valor ''{0}'', mas n\u00E3o h\u00E1 declara\u00E7\u00E3o de namespace para o prefixo ''{0}'' no escopo do elemento."}, + + {ER_SET_FEATURE_NULL_NAME, + "O nome do recurso n\u00E3o pode ser nulo em TransformerFactory.setFeature(Nome da string, valor booliano)."}, + + {ER_GET_FEATURE_NULL_NAME, + "O nome do recurso n\u00E3o pode ser nulo em TransformerFactory.getFeature(Nome da string)."}, + + {ER_UNSUPPORTED_FEATURE, + "N\u00E3o \u00E9 poss\u00EDvel definir o recurso ''{0}'' nesta TransformerFactory."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "O uso do elemento da extens\u00E3o ''{0}'' n\u00E3o ser\u00E1 permitido quando o recurso de processamento seguro for definido como verdadeiro."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "N\u00E3o \u00E9 poss\u00EDvel obter o prefixo de um uri de namespace nulo."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "N\u00E3o \u00E9 poss\u00EDvel obter o uri do namespace do prefixo nulo."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "O nome da fun\u00E7\u00E3o n\u00E3o pode ser nulo."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "A aridade n\u00E3o pode ser negativa."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "Encontrou '}', mas nenhum modelo do atributo estava aberto!"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Advert\u00EAncia: o atributo de contagem n\u00E3o corresponde a um ancestral no xsl:number! Alvo = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Sintaxe antiga: O nome do atributo 'expr' foi alterado para 'select'."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "O Xalan ainda n\u00E3o trata o nome das configura\u00E7\u00F5es regionais na fun\u00E7\u00E3o format-number."}, + + {WG_LOCALE_NOT_FOUND, + "Advert\u00EAncia: N\u00E3o foi poss\u00EDvel encontrar o nome das configura\u00E7\u00F5es regionais de xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "N\u00E3o \u00E9 poss\u00EDvel criar o URL de: {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "N\u00E3o \u00E9 poss\u00EDvel carregar o doc solicitado: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "N\u00E3o foi poss\u00EDvel localizar o Agrupador para >>>>>> Vers\u00E3o do Xalan "}, + {"version2", "<<<<<<<"}, + {"yes", "sim"}, + {"line", "N\u00B0 da Linha"}, + {"column", "N\u00B0 da Coluna"}, + {"xsldone", "XSLProcessor: conclu\u00EDdo"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Op\u00E7\u00F5es da classe Process da linha de comandos do Xalan-J:"}, + {"xslProc_option", "Op\u00E7\u00F5es da classe Process da linha de comandos do Xalan-J:"}, + {"xslProc_invalid_xsltc_option", "A op\u00E7\u00E3o {0} n\u00E3o \u00E9 suportada no modo XSLTC."}, + {"xslProc_invalid_xalan_option", "A op\u00E7\u00E3o {0} s\u00F3 pode ser usada com -XSLTC."}, + {"xslProc_no_input", "Erro: N\u00E3o foi especificada uma folha de estilos ou um xml de entrada . Execute este comando sem nenhuma op\u00E7\u00E3o para instru\u00E7\u00F5es de uso."}, + {"xslProc_common_options", "-Op\u00E7\u00F5es Comuns-"}, + {"xslProc_xalan_options", "-Op\u00E7\u00F5es para Xalan-"}, + {"xslProc_xsltc_options", "-Op\u00E7\u00F5es para XSLTC-"}, + {"xslProc_return_to_continue", "(pressione para continuar)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (use XSLTC para transforma\u00E7\u00E3o)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER nome da classe totalmente qualificado de liaison de parser]"}, + {"optionE", " [-E (N\u00E3o expandir refer\u00EAncias da entidade)]"}, + {"optionV", " [-E (N\u00E3o expandir refer\u00EAncias da entidade)]"}, + {"optionQC", " [-QC (Advert\u00EAncias de Conflitos do Padr\u00E3o Silencioso)]"}, + {"optionQ", " [-Q (Modo Silencioso)]"}, + {"optionLF", " [-LF (Usar alimenta\u00E7\u00F5es de linha somente na sa\u00EDda {o padr\u00E3o \u00E9 CR/LF})]"}, + {"optionCR", " [-CR (Use retornos de carro somente na sa\u00EDda {o padr\u00E3o \u00E9 CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Quais caracteres devem ser identificados como escape {o padr\u00E3o \u00E9 <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (Controla quantos espa\u00E7os devem ser recuados {o padr\u00E3o \u00E9 0})]"}, + {"optionTT", " [-TT (Rastreia os modelos \u00E0 medida que s\u00E3o chamados.)]"}, + {"optionTG", " [-TG (Rastreia cada evento de gera\u00E7\u00E3o.)]"}, + {"optionTS", " [-TS (Rastreia cada evento de sele\u00E7\u00E3o.)]"}, + {"optionTTC", " [-TTC (Rastreia os filhos do modelo \u00E0 medida que s\u00E3o processados.)]"}, + {"optionTCLASS", " [-TCLASS (Classe TraceListener para extens\u00F5es de rastreamento.)]"}, + {"optionVALIDATE", " [-VALIDATE (Define se ocorre valida\u00E7\u00E3o. Por padr\u00E3o, a valida\u00E7\u00E3o fica desativada.)]"}, + {"optionEDUMP", " [-EDUMP {nome do arquivo opcional} (Execute um dump de pilha em caso de erro.)]"}, + {"optionXML", " [-XML (Use o formatador XML e adicione o cabe\u00E7alho XML.)]"}, + {"optionTEXT", " [-TEXT (Use o formatador de Texto simples.)]"}, + {"optionHTML", " [-HTML (Use o formatador HTML.)]"}, + {"optionPARAM", " [-PARAM express\u00E3o do nome (Defina um par\u00E2metro da folha de estilos)]"}, + {"noParsermsg1", "Processo XSL malsucedido."}, + {"noParsermsg2", "** N\u00E3o foi poss\u00EDvel localizar o parser **"}, + {"noParsermsg3", "Verifique seu classpath."}, + {"noParsermsg4", "Se voc\u00EA n\u00E3o tiver um Parser XML da IBM para Java, poder\u00E1 fazer download dele em"}, + {"noParsermsg5", "AlphaWorks da IBM: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER nome completo da classe (URIResolver a ser usado para resolver URIs)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER nome completo da classe (EntityResolver a ser usado para resolver entidades)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER nome completo da classe (ContentHandler a ser usado para serializar a sa\u00EDda)]"}, + {"optionLINENUMBERS", " [-L usa os n\u00FAmeros de linha dos documentos de origem]"}, + {"optionSECUREPROCESSING", " [-SECURE (define o recurso de processamento seguro como verdadeiro.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (use o atributo de m\u00EDdia para localizar a folha de estilos associada a um documento.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (Use explicitamente s2s=SAX ou d2d=DOM para fazer a transforma\u00E7\u00E3o.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Imprimir transforma\u00E7\u00E3o geral de milissegundos detectada.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (solicitar a constru\u00E7\u00E3o de DTM incremental, definindo http://xml.apache.org/xalan/features/incremental como verdadeiro.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (solicite o n\u00E3o processamento de otimiza\u00E7\u00E3o da folha de estilos definindo http://xml.apache.org/xalan/features/optimize como falso.)]"}, + {"optionRL", " [-RL recursionlimit (limite num\u00E9rico de asser\u00E7\u00E3o na profundidade de recurs\u00E3o da folha de estilos.)]"}, + {"optionXO", " [-XO [transletName] (atribui o nome ao translet gerado)]"}, + {"optionXD", " [-XD destinationDirectory (especificar um diret\u00F3rio de destino para translet)]"}, + {"optionXJ", " [-XJ jarfile (empacotar classes do translet em um arquivo jar com o nome )]"}, + {"optionXP", " [-XP pacote (especifica um prefixo de nome do pacote para todas as classes translet geradas)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (ativa a inser\u00E7\u00E3o do modelo)]"}, + {"optionXX", " [-XX (ativa a sa\u00EDda da mensagem de depura\u00E7\u00E3o adicional)]"}, + {"optionXT", " [-XT (usar o translet para transformar, se poss\u00EDvel)]"}, + {"diagTiming", " --------- A transforma\u00E7\u00E3o de {0} por meio de {1} levou {2} ms"}, + {"recursionTooDeep", "Aninhamento do modelo muito profundo. aninhamento = {0}, modelo {1} {2}"}, + {"nameIs", "o nome \u00E9"}, + {"matchPatternIs", "o padr\u00E3o de correspond\u00EAncia \u00E9"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java new file mode 100644 index 0000000..7cd04fd --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_sv extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "Fel: Uttryck f\u00E5r inte inneh\u00E5lla '{'"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} har ett otill\u00E5tet attribut: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode \u00E4r null i xsl:apply-imports!"}, + + {ER_CANNOT_ADD, + "Kan inte addera {0} till {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u00E4r null i handleApplyTemplatesInstruction!"}, + + {ER_NO_NAME_ATTRIB, + "{0} m\u00E5ste ha ett namnattribut."}, + + {ER_TEMPLATE_NOT_FOUND, + "Hittade inte mallen med namnet: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "Kunde inte matcha namn-AVT i xsl:call-template."}, + + {ER_REQUIRES_ATTRIB, + "{0} kr\u00E4ver attribut: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} m\u00E5ste ha ett ''test''-attribut."}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "Felaktigt v\u00E4rde i niv\u00E5attribut: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "Namn p\u00E5 bearbetningsinstruktion kan inte vara 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "Namn p\u00E5 bearbetningsinstruktion m\u00E5ste vara ett giltigt NCName: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} m\u00E5ste ha ett matchningsattribut n\u00E4r det anger ett l\u00E4ge."}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} kr\u00E4ver antingen ett namn eller ett matchningsattribut."}, + + {ER_CANT_RESOLVE_NSPREFIX, + "Kan inte matcha prefix f\u00F6r namnrymd: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space har ett otill\u00E5tet v\u00E4rde: {0}"}, + + {ER_NO_OWNERDOC, + "Underordnad nod har inget \u00E4gardokument!"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement-fel: {0}"}, + + {ER_NULL_CHILD, + "F\u00F6rs\u00F6ker l\u00E4gga till en null-underordnad!"}, + + {ER_NEED_SELECT_ATTRIB, + "{0} kr\u00E4ver ett select-attribut."}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when m\u00E5ste ha ett 'test'-attribut."}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-parametern m\u00E5ste ha ett 'namn'-attribut."}, + + {ER_NO_CONTEXT_OWNERDOC, + "context har inget \u00E4gardokument!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "Kunde inte skapa XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: Processen utf\u00F6rdes inte."}, + + {ER_NOT_SUCCESSFUL, + "Xalan: utf\u00F6rdes inte."}, + + {ER_ENCODING_NOT_SUPPORTED, + "Kodningen st\u00F6ds inte: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "Kunde inte TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key kr\u00E4ver ett 'namn'-attribut!"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key kr\u00E4ver ett 'matchning'-attribut!"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key kr\u00E4ver ett 'anv\u00E4nd'-attribut!"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} kr\u00E4ver ett ''element''-attribut!"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) ''prefix'' f\u00F6r {0}-attribut saknas"}, + + {ER_BAD_STYLESHEET_URL, + "Formatmall-URL \u00E4r felaktig: {0}"}, + + {ER_FILE_NOT_FOUND, + "Formatmallfil kunde inte hittas: {0}"}, + + {ER_IOEXCEPTION, + "Fick IO-undantag med formatmallfil: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) Hittade inte href-attribut f\u00F6r {0}"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} inkluderar, direkt eller indirekt, sig sj\u00E4lv!"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude-fel, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) ''lang'' f\u00F6r {0}-attribut saknas"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}-element?? \u00E4r felplacerat Container-elementet ''component'' saknas"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "Kan endast skicka utdata till ett Element, ett DocumentFragment, ett Document eller en PrintWriter."}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process-fel"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode-fel: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "Fel! Hittade inte xpath select-uttryck (-select)."}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "Kan inte serialisera en XSLProcessor!"}, + + {ER_NO_INPUT_STYLESHEET, + "Formatmallindata ej angiven!"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "Kunde inte behandla formatmall!"}, + + {ER_COULDNT_PARSE_DOC, + "Kunde inte tolka dokumentet {0}!"}, + + {ER_COULDNT_FIND_FRAGMENT, + "Hittade inte fragment: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "Nod som pekades p\u00E5 av fragment-identifierare var inte ett element: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each kr\u00E4ver antingen en matchning eller ett namnattribut"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates kr\u00E4ver antingen en matchning eller ett namnattribut"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "Ingen klon av ett dokumentfragment!"}, + + {ER_CANT_CREATE_ITEM, + "Kan inte skapa element i resultattr\u00E4d: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "xml:space i k\u00E4ll-XML har ett otill\u00E5tet v\u00E4rde: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "Det finns ingen xsl:key-deklaration f\u00F6r {0}!"}, + + {ER_CANT_CREATE_URL, + "Fel! Kan inte skapa URL f\u00F6r: {0}"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "xsl:functions st\u00F6ds inte"}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory-fel"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) {0} \u00E4r inte till\u00E5ten inne i en formatmall!"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "result-ns st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:output ist\u00E4llet."}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "default-space st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:strip-space eller xsl:preserve-space ist\u00E4llet."}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "indent-result st\u00F6ds inte l\u00E4ngre! Anv\u00E4nd xsl:output ist\u00E4llet."}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} har ett otill\u00E5tet attribut: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "Ok\u00E4nt XSL-element: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort kan endast anv\u00E4ndas med xsl:apply-templates eller xsl:for-each."}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) felplacerade xsl:when!"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when h\u00E4rstammar inte fr\u00E5n xsl:choose!"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) felplacerade xsl:otherwise!"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise h\u00E4rstammar inte fr\u00E5n xsl:choose!"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) {0} \u00E4r inte till\u00E5ten inne i en mall!"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) ok\u00E4nt namnrymdsprefix {1} f\u00F6r till\u00E4gg {0}"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) Imports kan endast f\u00F6rekomma som de f\u00F6rsta elementen i formatmallen!"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} importerar, direkt eller indirekt, sig sj\u00E4lv!"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space har ett otill\u00E5tet v\u00E4rde: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet utf\u00F6rdes inte!"}, + + {ER_SAX_EXCEPTION, + "SAX-undantag"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "Funktionen st\u00F6ds inte!"}, + + {ER_XSLT_ERROR, + "XSLT-fel"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "valutatecken \u00E4r inte till\u00E5tet i formatm\u00F6nsterstr\u00E4ng"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Dokumentfunktion st\u00F6ds inte i Stylesheet DOM!"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "Kan inte matcha prefix med matchning som saknar prefix!"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "Redirect-till\u00E4gg: Hittade inte filnamn - fil eller valattribut m\u00E5ste returnera giltig str\u00E4ng."}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "Kan inte bygga FormatterListener i Redirect-till\u00E4gg!"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "Prefix i exclude-result-prefixes \u00E4r inte giltigt: {0}"}, + + {ER_MISSING_NS_URI, + "Namnrymds-URI saknas f\u00F6r angivna prefix"}, + + {ER_MISSING_ARG_FOR_OPTION, + "Argument saknas f\u00F6r alternativet: {0}"}, + + {ER_INVALID_OPTION, + "Ogiltigt alternativ: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "Felaktigt utformad formatstr\u00E4ng: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet kr\u00E4ver ett 'version'-attribut!"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "Attribut: {0} har ett otill\u00E5tet v\u00E4rde: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose kr\u00E4ver xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:apply-imports inte till\u00E5tet i xsl:for-each"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "Kan inte anv\u00E4nda DTMLiaison till en DOM utdatanod... skicka en com.sun.org.apache.xpath.internal.DOM2Helper ist\u00E4llet!"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "Kan inte anv\u00E4nda DTMLiaison till en DOM indatanod... skicka en com.sun.org.apache.xpath.internal.DOM2Helper ist\u00E4llet!"}, + + {ER_CALL_TO_EXT_FAILED, + "Anrop till till\u00E4ggselement utf\u00F6rdes inte: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "Prefix m\u00E5ste matchas till en namnrymd: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "Ogiltigt UTF-16-surrogat uppt\u00E4ckt: {0} ?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} anv\u00E4nde sig sj\u00E4lvt, vilket kommer att orsaka en o\u00E4ndlig slinga."}, + + {ER_CANNOT_MIX_XERCESDOM, + "Kan inte blanda icke-Xerces-DOM-indata med Xerces-DOM-utdata!"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "I ElemTemplateElement.readObject: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "Hittade fler \u00E4n en mall med namnet: {0}"}, + + {ER_INVALID_KEY_CALL, + "Ogiltigt funktionsanrop: rekursiva key()-anrop \u00E4r inte till\u00E5tna"}, + + {ER_REFERENCING_ITSELF, + "Variabeln {0} refererar, direkt eller indirekt, till sig sj\u00E4lv!"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "Indatanoden till en DOMSource f\u00F6r newTemplates f\u00E5r inte vara null!"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "Klassfil f\u00F6r alternativ {0} saknas"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "Obligatoriska element hittades inte: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream kan inte vara null"}, + + {ER_URI_CANNOT_BE_NULL, + "URI kan inte vara null"}, + + {ER_FILE_CANNOT_BE_NULL, + "Fil kan inte vara null"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource kan inte vara null"}, + + {ER_CANNOT_INIT_BSFMGR, + "Kunde inte initiera BSF Manager"}, + + {ER_CANNOT_CMPL_EXTENSN, + "Kunde inte kompilera till\u00E4gg"}, + + {ER_CANNOT_CREATE_EXTENSN, + "Kunde inte skapa till\u00E4gg: {0} p\u00E5 grund av: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "Instansmetodanrop till metod {0} kr\u00E4ver en objektinstans som f\u00F6rsta argument"}, + + {ER_INVALID_ELEMENT_NAME, + "Ogiltigt elementnamn angivet {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "Elementnamnmetod m\u00E5ste vara statisk {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "Till\u00E4ggsfunktion {0} : {1} \u00E4r ok\u00E4nd"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r konstruktor f\u00F6r {0}"}, + + {ER_MORE_MATCH_METHOD, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r metod {0}"}, + + {ER_MORE_MATCH_ELEMENT, + "Fler \u00E4n en b\u00E4sta matchning f\u00F6r elementmetod {0}"}, + + {ER_INVALID_CONTEXT_PASSED, + "Ogiltig kontext skickad f\u00F6r att utv\u00E4rdera {0}"}, + + {ER_POOL_EXISTS, + "Pool finns redan"}, + + {ER_NO_DRIVER_NAME, + "Inget drivrutinsnamn angivet"}, + + {ER_NO_URL, + "Ingen URL angiven"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "Poolstorlek \u00E4r mindre \u00E4n ett!"}, + + {ER_INVALID_DRIVER, + "Ogiltigt drivrutinsnamn angivet!"}, + + {ER_NO_STYLESHEETROOT, + "Hittade inte formatmallen roten!"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "Otill\u00E5tet v\u00E4rde f\u00F6r xml:space"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode utf\u00F6rdes inte"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "Resursen [ {0} ] kunde inte laddas: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "Buffertstorlek <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "Ok\u00E4nt fel vid anrop av till\u00E4gg"}, + + {ER_NO_NAMESPACE_DECL, + "Prefix {0} har ingen motsvarande namnrymdsdeklaration"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "Elementinneh\u00E5ll inte till\u00E5tet f\u00F6r lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "Avslutning via formatmall"}, + + {ER_ONE_OR_TWO, + "1 eller 2"}, + + {ER_TWO_OR_THREE, + "2 eller 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "Kunde inte ladda {0} (kontrollera CLASSPATH), anv\u00E4nder nu enbart standardv\u00E4rden"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "Kan inte initiera standardmallar"}, + + {ER_RESULT_NULL, + "Result borde inte vara null"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "Result kunde inte st\u00E4llas in"}, + + {ER_NO_OUTPUT_SPECIFIED, + "Ingen utdata angiven"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "Kan inte omvandla till Result av typ {0}"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "Kan inte omvandla Source av typ {0}"}, + + {ER_NULL_CONTENT_HANDLER, + "Inneh\u00E5llshanterare med v\u00E4rde null"}, + + {ER_NULL_ERROR_HANDLER, + "Felhanterare med v\u00E4rde null"}, + + {ER_CANNOT_CALL_PARSE, + "parse kan inte anropas om ContentHandler inte har satts"}, + + {ER_NO_PARENT_FOR_FILTER, + "Ingen \u00F6verordnad f\u00F6r filter"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "Formatmall saknas i: {0}, media= {1}"}, + + {ER_NO_STYLESHEET_PI, + "PI f\u00F6r xml-formatmall saknas i: {0}"}, + + {ER_NOT_SUPPORTED, + "Underst\u00F6ds inte: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "V\u00E4rde f\u00F6r egenskap {0} b\u00F6r vara en boolesk instans"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "Kunde inte h\u00E4mta externt skript fr\u00E5n {0}"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "Resursen [ {0} ] kunde inte h\u00E4mtas.\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "Utdataegenskap kan inte identifieras: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "Kunde inte skapa instans av ElemLiteralResult"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "V\u00E4rdet f\u00F6r {0} b\u00F6r inneh\u00E5lla ett tal som kan tolkas"}, + + {ER_VALUE_SHOULD_EQUAL, + "V\u00E4rdet f\u00F6r {0} b\u00F6r vara ja eller nej"}, + + {ER_FAILED_CALLING_METHOD, + "Kunde inte anropa metoden {0}"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "Kunde inte skapa instans av ElemTemplateElement"}, + + {ER_CHARS_NOT_ALLOWED, + "Tecken \u00E4r inte till\u00E5tna i dokumentet i det h\u00E4r skedet"}, + + {ER_ATTR_NOT_ALLOWED, + "Attributet \"{0}\" \u00E4r inte till\u00E5tet i elementet {1}!"}, + + {ER_BAD_VALUE, + "{0} felaktigt v\u00E4rde {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "Attributet {0} saknas "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "Attributv\u00E4rdet {0} kan inte identifieras "}, + + {ER_NULL_URI_NAMESPACE, + "F\u00F6rs\u00F6ker generera ett namnrymdsprefix med en null-URI"}, + + {ER_NUMBER_TOO_BIG, + "F\u00F6rs\u00F6ker formatera ett tal som \u00E4r st\u00F6rre \u00E4n det st\u00F6rsta l\u00E5nga heltalet"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "Hittar inte SAX1-drivrutinen klass {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "SAX1-drivrutinen klass {0} hittades, men kan inte laddas"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "SAX1-drivrutinen klass {0} laddades, men kan inte instansieras"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1-drivrutinen klass {0} implementerar inte org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "Systemegenskapen org.xml.sax.parser \u00E4r inte angiven"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "Parserargument m\u00E5ste vara null"}, + + {ER_FEATURE, + "Funktion: {0}"}, + + {ER_PROPERTY, + "Egenskap: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "Enhetsmatchning med v\u00E4rde null"}, + + {ER_NULL_DTD_HANDLER, + "DTD-hanterare med v\u00E4rde null"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "Inget angivet drivrutinsnamn!"}, + + {ER_NO_URL_SPECIFIED, + "Ingen URL angiven!"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "Poolstorlek \u00E4r mindre \u00E4n ett!"}, + + {ER_INVALID_DRIVER_NAME, + "Ogiltigt drivrutinsnamn angivet!"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "Programmerarfel! Uttrycket har ingen \u00F6verordnad ElemTemplateElement!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "Programmerarens utsaga i RedundentExprEliminator: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "{0} \u00E4r inte till\u00E5ten i denna position i formatmallen!"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "Text utan blanktecken \u00E4r inte till\u00E5ten i denna position i formatmallen!"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r CHAR-attributet: {0}. Ett attribut av CHAR-typ f\u00E5r bara ha 1 tecken!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r QNAME-attributet: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r ENUM-attributet: {0}. Giltiga v\u00E4rden \u00E4r: {2}."}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r NMTOKEN-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r NCNAME-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r boolean-attributet: {0} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Otill\u00E5tet v\u00E4rde: {1} anv\u00E4nds f\u00F6r number-attributet: {0} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "Argument f\u00F6r {0} i matchningsm\u00F6nstret m\u00E5ste vara litteral."}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "Dubbel deklaration av global variabel."}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "Dubbel deklaration av variabel."}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template m\u00E5ste ha name- och/eller match-attribut"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "Prefix i exclude-result-prefixes \u00E4r inte giltigt: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "attributserien {0} finns inte"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "Det finns ingen funktion med namnet {0}"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "Elementet {0} kan inte ha b\u00E5de inneh\u00E5ll och select-attribut."}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "Parameterv\u00E4rdet f\u00F6r {0} m\u00E5ste vara giltigt Java-objekt"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "result-prefix-attributet i xsl:namespace-alias-element har v\u00E4rdet '#default', men det finns ingen deklaration av standardnamnrymd inom omfattningen av elementet"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "result-prefix-attributet i xsl:namespace-alias-element har v\u00E4rdet ''{0}'', men det finns ingen deklaration av namnrymd f\u00F6r prefixet ''{0}'' inom omfattningen av elementet."}, + + {ER_SET_FEATURE_NULL_NAME, + "Funktionsnamnet kan inte vara null i TransformerFactory.setFeature(namn p\u00E5 str\u00E4ng, booleskt v\u00E4rde)."}, + + {ER_GET_FEATURE_NULL_NAME, + "Funktionsnamnet kan inte vara null i TransformerFactory.getFeature(namn p\u00E5 str\u00E4ng)."}, + + {ER_UNSUPPORTED_FEATURE, + "Kan inte st\u00E4lla in funktionen ''{0}'' i denna TransformerFactory."}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "Anv\u00E4ndning av till\u00E4ggselementet ''{0}'' \u00E4r inte till\u00E5tet n\u00E4r s\u00E4ker bearbetning till\u00E4mpas."}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "Kan inte h\u00E4mta prefix f\u00F6r namnrymds-uri som \u00E4r null."}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "Kan inte h\u00E4mta namnrymds-uri f\u00F6r prefix som \u00E4r null."}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "Funktionsnamn f\u00E5r inte vara null."}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Ariteten kan inte vara negativ."}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "Hittade '}' men det finns ingen \u00F6ppen attributmall!"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "Varning: r\u00E4knarattribut matchar inte \u00F6verordnad i xsl:number! Target = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "Gammal syntax: Namnet p\u00E5 'expr'-attributet har \u00E4ndrats till 'select'."}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan hanterar \u00E4nnu inte spr\u00E5kkonventionen i funktionen format-number."}, + + {WG_LOCALE_NOT_FOUND, + "Varning: Hittade inte spr\u00E5kkonvention f\u00F6r xml:lang={0}"}, + + {WG_CANNOT_MAKE_URL_FROM, + "Kan inte skapa URL fr\u00E5n: {0}"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "Kan inte ladda beg\u00E4rt dokument: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "Hittade inte kollationering f\u00F6r >>>>>> Xalan version "}, + {"version2", "<<<<<<<"}, + {"yes", "ja"}, + {"line", "Rad nr"}, + {"column", "Kolumn nr"}, + {"xsldone", "XSLProcessor: utf\u00F6rd"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Process-klassalternativ f\u00F6r Xalan-J-kommandorad:"}, + {"xslProc_option", "Process-klassalternativ f\u00F6r Xalan-J-kommandorad:"}, + {"xslProc_invalid_xsltc_option", "Alternativet {0} underst\u00F6ds inte i XSLTC-l\u00E4ge."}, + {"xslProc_invalid_xalan_option", "Alternativet {0} kan anv\u00E4ndas endast med -XSLTC."}, + {"xslProc_no_input", "Fel: Ingen formatmall eller indata-xml har angetts. K\u00F6r kommandot utan n\u00E5got alternativ f\u00F6r att visa syntax."}, + {"xslProc_common_options", "-Allm\u00E4nna alternativ-"}, + {"xslProc_xalan_options", "-Alternativ f\u00F6r Xalan-"}, + {"xslProc_xsltc_options", "-Alternativ f\u00F6r XSLTC-"}, + {"xslProc_return_to_continue", "(tryck p\u00E5 Enter f\u00F6r att forts\u00E4tta)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (anv\u00E4nd XSLTC f\u00F6r transformering)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER fullt kvalificerat klassnamn p\u00E5 parserf\u00F6rbindelse]"}, + {"optionE", " [-E (Ut\u00F6ka inte enhetsreferenser)]"}, + {"optionV", " [-E (Ut\u00F6ka inte enhetsreferenser)]"}, + {"optionQC", " [-QC (Tysta m\u00F6nsterkonfliktvarningar)]"}, + {"optionQ", " [-Q (Tyst l\u00E4ge)]"}, + {"optionLF", " [-LF (Anv\u00E4nd radmatningar endast f\u00F6r utdata {standard \u00E4r CR/LF})]"}, + {"optionCR", " [-CR (Anv\u00E4nd radmatningar endast f\u00F6r utdata {standard \u00E4r CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (Vilka tecken \u00E4r skiftningstecken {standard \u00E4r <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (Best\u00E4m antal blanksteg f\u00F6r indrag {standard \u00E4r 0})]"}, + {"optionTT", " [-TT (Sp\u00E5ra mallar vid anrop.)]"}, + {"optionTG", " [-TG (Sp\u00E5ra varje generationsh\u00E4ndelse.)]"}, + {"optionTS", " [-TS (Sp\u00E5ra varje urvalsh\u00E4ndelse.)]"}, + {"optionTTC", " [-TTC (Sp\u00E5ra mallunderordnade n\u00E4r de bearbetas.)]"}, + {"optionTCLASS", " [-TCLASS (TraceListener-klass f\u00F6r sp\u00E5rningstill\u00E4gg.)]"}, + {"optionVALIDATE", " [-VALIDATE (St\u00E4ll in om validering utf\u00F6rs. Standard \u00E4r att validering \u00E4r avst\u00E4ngd.)]"}, + {"optionEDUMP", " [-EDUMP {valfritt filnamn} (G\u00F6r stackdump vid fel.)]"}, + {"optionXML", " [-XML (Anv\u00E4nd XML-formaterare och l\u00E4gg till XML-huvud.)]"}, + {"optionTEXT", " [-TEXT (Anv\u00E4nd enkel textformaterare.)]"}, + {"optionHTML", " [-HTML (Anv\u00E4nd HTML-formaterare.)]"}, + {"optionPARAM", " [-PARAM-namnuttryck (St\u00E4ll in parameter f\u00F6r formatmall)]"}, + {"noParsermsg1", "XSL-processen utf\u00F6rdes inte."}, + {"noParsermsg2", "** Hittade inte parser **"}, + {"noParsermsg3", "Kontrollera klass\u00F6kv\u00E4gen."}, + {"noParsermsg4", "Om du inte har IBMs XML Parser f\u00F6r Java kan du ladda ned den fr\u00E5n"}, + {"noParsermsg5", "IBMs AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER fullst\u00E4ndigt klassnamn (URIResolver som anv\u00E4nds vid matchning av URI-er)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER fullst\u00E4ndigt klassnamn (EntityResolver som anv\u00E4nds vid matchning av enheter)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER fullst\u00E4ndigt klassnamn (ContentHandler som anv\u00E4nds vid serialisering av utdata)]"}, + {"optionLINENUMBERS", " [-L anv\u00E4nd radnummer i k\u00E4lldokument]"}, + {"optionSECUREPROCESSING", " [-SECURE (ange att s\u00E4ker bearbetning ska till\u00E4mpas.)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (anv\u00E4nd medieattribut f\u00F6r att hitta formatmall som h\u00F6r ihop med dokument.)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (Anv\u00E4nd s2s=SAX eller d2d=DOM vid transformering.)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (Skriv ut tid f\u00F6r transformering i millisekunder.)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (beg\u00E4r inkrementell DTM-konstruktion genom att ange http://xml.apache.org/xalan/features/incremental true.)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (beg\u00E4r att ingen formatmallsoptimering utf\u00F6rs genom att ange http://xml.apache.org/xalan/features/optimize false.)]"}, + {"optionRL", " [-RL rekursionsgr\u00E4ns (verifiera numeriskt gr\u00E4nsv\u00E4rde f\u00F6r formatmallens rekursionsdjup.)]"}, + {"optionXO", " [-XO [transletName] (tilldela namnet till genererad translet)]"}, + {"optionXD", " [-XD destinationDirectory (ange destinationskatalog f\u00F6r translet)]"}, + {"optionXJ", " [-XJ jarfile (paketerar transletklasserna i en jar-fil med namnet )]"}, + {"optionXP", " [-XP package (anger paketnamnsprefix f\u00F6r alla genererade transletklasser)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (aktiverar mallinfogning)]"}, + {"optionXX", " [-XX (aktiverar ytterligare fels\u00F6kningsmeddelanden)]"}, + {"optionXT", " [-XT (anv\u00E4nder translet vid transformering om m\u00F6jligt)]"}, + {"diagTiming", " --------- Transformering av {0} via {1} tog {2} ms"}, + {"recursionTooDeep", "Mallkapslingen \u00E4r f\u00F6r djup. kapsling = {0}, mall {1} {2}"}, + {"nameIs", "namnet \u00E4r"}, + {"matchPatternIs", "matchningsm\u00F6nstret \u00E4r"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java new file mode 100644 index 0000000..63de93d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_zh_CN extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "\u9519\u8BEF: \u8868\u8FBE\u5F0F\u4E2D\u4E0D\u80FD\u5305\u542B '{'"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0}\u5177\u6709\u975E\u6CD5\u5C5E\u6027: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode \u5728 xsl:apply-imports \u4E2D\u4E3A\u7A7A\u503C!"}, + + {ER_CANNOT_ADD, + "\u65E0\u6CD5\u5411{1}\u6DFB\u52A0{0}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u5728 handleApplyTemplatesInstruction \u4E2D\u4E3A\u7A7A\u503C!"}, + + {ER_NO_NAME_ATTRIB, + "{0}\u5FC5\u987B\u5177\u6709 name \u5C5E\u6027\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u627E\u4E0D\u5230\u540D\u4E3A{0}\u7684\u6A21\u677F"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "\u65E0\u6CD5\u89E3\u6790 xsl:call-template \u4E2D\u7684\u540D\u79F0 AVT\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0}\u9700\u8981\u5C5E\u6027: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0}\u5FC5\u987B\u5177\u6709 ''test'' \u5C5E\u6027\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "level \u5C5E\u6027\u7684\u503C\u9519\u8BEF: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \u540D\u79F0\u4E0D\u80FD\u4E3A 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \u540D\u79F0\u5FC5\u987B\u662F\u6709\u6548\u7684 NCName: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "\u5982\u679C{0}\u5177\u6709\u67D0\u79CD\u6A21\u5F0F, \u5219\u5FC5\u987B\u5177\u6709 match \u5C5E\u6027\u3002"}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0}\u9700\u8981 name \u6216 match \u5C5E\u6027\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u65E0\u6CD5\u89E3\u6790\u540D\u79F0\u7A7A\u95F4\u524D\u7F00: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + {ER_NO_OWNERDOC, + "\u5B50\u8282\u70B9\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863!"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \u9519\u8BEF: {0}"}, + + {ER_NULL_CHILD, + "\u6B63\u5728\u5C1D\u8BD5\u6DFB\u52A0\u7A7A\u5B50\u7EA7!"}, + + {ER_NEED_SELECT_ATTRIB, + "{0}\u9700\u8981 select \u5C5E\u6027\u3002"}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when \u5FC5\u987B\u5177\u6709 'test' \u5C5E\u6027\u3002"}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param \u5FC5\u987B\u5177\u6709 'name' \u5C5E\u6027\u3002"}, + + {ER_NO_CONTEXT_OWNERDOC, + "\u4E0A\u4E0B\u6587\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863!"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "\u65E0\u6CD5\u521B\u5EFA XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u8FDB\u7A0B\u672A\u6210\u529F\u3002"}, + + {ER_NOT_SUCCESSFUL, + "Xalan: \u672A\u6210\u529F\u3002"}, + + {ER_ENCODING_NOT_SUPPORTED, + "\u4E0D\u652F\u6301\u7F16\u7801: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "\u65E0\u6CD5\u521B\u5EFA TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key \u9700\u8981 'name' \u5C5E\u6027!"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key \u9700\u8981 'match' \u5C5E\u6027!"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key \u9700\u8981 'use' \u5C5E\u6027!"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0}\u9700\u8981 ''elements'' \u5C5E\u6027!"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) \u7F3A\u5C11{0}\u5C5E\u6027 ''prefix''"}, + + {ER_BAD_STYLESHEET_URL, + "\u6837\u5F0F\u8868 URL \u9519\u8BEF: {0}"}, + + {ER_FILE_NOT_FOUND, + "\u627E\u4E0D\u5230\u6837\u5F0F\u8868\u6587\u4EF6: {0}"}, + + {ER_IOEXCEPTION, + "\u6837\u5F0F\u8868\u6587\u4EF6\u51FA\u73B0 IO \u5F02\u5E38\u9519\u8BEF: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \u627E\u4E0D\u5230{0}\u7684 href \u5C5E\u6027"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0}\u76F4\u63A5\u6216\u95F4\u63A5\u5305\u542B\u5176\u81EA\u8EAB!"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \u9519\u8BEF, {0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) \u7F3A\u5C11{0}\u5C5E\u6027 ''lang''"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0}\u5143\u7D20\u7684\u653E\u7F6E\u4F4D\u7F6E\u662F\u5426\u9519\u8BEF?? \u7F3A\u5C11\u5BB9\u5668\u5143\u7D20 ''component''"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "\u53EA\u80FD\u8F93\u51FA\u5230 Element, DocumentFragment, Document \u6216 PrintWriter\u3002"}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process \u9519\u8BEF"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode \u9519\u8BEF: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "\u9519\u8BEF! \u627E\u4E0D\u5230 xpath \u9009\u62E9\u8868\u8FBE\u5F0F (-select)\u3002"}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "\u65E0\u6CD5\u5E8F\u5217\u5316 XSLProcessor!"}, + + {ER_NO_INPUT_STYLESHEET, + "\u672A\u6307\u5B9A\u6837\u5F0F\u8868\u8F93\u5165!"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "\u65E0\u6CD5\u5904\u7406\u6837\u5F0F\u8868!"}, + + {ER_COULDNT_PARSE_DOC, + "\u65E0\u6CD5\u89E3\u6790{0}\u6587\u6863!"}, + + {ER_COULDNT_FIND_FRAGMENT, + "\u627E\u4E0D\u5230\u7247\u6BB5: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "\u7247\u6BB5\u6807\u8BC6\u7B26\u6307\u5411\u7684\u8282\u70B9\u4E0D\u662F\u5143\u7D20: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each \u5FC5\u987B\u5177\u6709 match \u6216 name \u5C5E\u6027"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "templates \u5FC5\u987B\u5177\u6709 match \u6216 name \u5C5E\u6027"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u4E0D\u80FD\u514B\u9686\u6587\u6863\u7247\u6BB5!"}, + + {ER_CANT_CREATE_ITEM, + "\u65E0\u6CD5\u5728\u7ED3\u679C\u6811\u4E2D\u521B\u5EFA\u9879: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "\u6E90 XML \u4E2D\u7684 xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "{0}\u6CA1\u6709 xsl:key \u58F0\u660E!"}, + + {ER_CANT_CREATE_URL, + "\u9519\u8BEF! \u65E0\u6CD5\u4E3A{0}\u521B\u5EFA url"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "\u4E0D\u652F\u6301 xsl:functions"}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \u9519\u8BEF"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \u6837\u5F0F\u8868\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528{0}!"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 result-ns! \u8BF7\u6539\u7528 xsl:output\u3002"}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 default-space! \u8BF7\u6539\u7528 xsl:strip-space \u6216 xsl:preserve-space\u3002"}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u6301 indent-result! \u8BF7\u6539\u7528 xsl:output\u3002"}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0}\u5177\u6709\u975E\u6CD5\u5C5E\u6027: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "\u672A\u77E5 XSL \u5143\u7D20: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort \u53EA\u80FD\u4E0E xsl:apply-templates \u6216 xsl:for-each \u4E00\u8D77\u4F7F\u7528\u3002"}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when \u7684\u653E\u7F6E\u4F4D\u7F6E\u9519\u8BEF!"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when \u7684\u7236\u7EA7\u4E0D\u662F xsl:choose!"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise \u7684\u653E\u7F6E\u4F4D\u7F6E\u9519\u8BEF!"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise \u7684\u7236\u7EA7\u4E0D\u662F xsl:choose!"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \u6A21\u677F\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528{0}!"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) {0}\u6269\u5C55\u540D\u79F0\u7A7A\u95F4\u524D\u7F00 {1} \u672A\u77E5"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u53EA\u80FD\u4F5C\u4E3A\u6837\u5F0F\u8868\u4E2D\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20\u5BFC\u5165!"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0}\u76F4\u63A5\u6216\u95F4\u63A5\u5BFC\u5165\u5176\u81EA\u8EAB!"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space \u5177\u6709\u975E\u6CD5\u503C: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet \u5931\u8D25!"}, + + {ER_SAX_EXCEPTION, + "SAX \u5F02\u5E38\u9519\u8BEF"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "\u4E0D\u652F\u6301\u8BE5\u51FD\u6570!"}, + + {ER_XSLT_ERROR, + "XSLT \u9519\u8BEF"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "\u683C\u5F0F\u6A21\u5F0F\u5B57\u7B26\u4E32\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u8D27\u5E01\u7B26\u53F7"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "\u6837\u5F0F\u8868 DOM \u4E2D\u4E0D\u652F\u6301 Document \u51FD\u6570!"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u65E0\u6CD5\u89E3\u6790\u975E\u524D\u7F00\u89E3\u6790\u5668\u7684\u524D\u7F00!"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "\u91CD\u5B9A\u5411\u6269\u5C55: \u65E0\u6CD5\u83B7\u53D6\u6587\u4EF6\u540D - file \u6216 select \u5C5E\u6027\u5FC5\u987B\u8FD4\u56DE\u6709\u6548\u5B57\u7B26\u4E32\u3002"}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u65E0\u6CD5\u5728\u91CD\u5B9A\u5411\u6269\u5C55\u4E2D\u6784\u5EFA FormatterListener!"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F00\u65E0\u6548: {0}"}, + + {ER_MISSING_NS_URI, + "\u6307\u5B9A\u524D\u7F00\u7F3A\u5C11\u540D\u79F0\u7A7A\u95F4 URI"}, + + {ER_MISSING_ARG_FOR_OPTION, + "\u9009\u9879\u7F3A\u5C11\u53C2\u6570: {0}"}, + + {ER_INVALID_OPTION, + "\u9009\u9879\u65E0\u6548: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "\u683C\u5F0F\u5B57\u7B26\u4E32\u7684\u683C\u5F0F\u9519\u8BEF: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet \u9700\u8981 'version' \u5C5E\u6027!"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C5E\u6027{0}\u5177\u6709\u975E\u6CD5\u503C: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose \u9700\u8981 xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 xsl:apply-imports"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "\u65E0\u6CD5\u5C06 DTMLiaison \u7528\u4E8E\u8F93\u51FA DOM \u8282\u70B9... \u8BF7\u6539\u4E3A\u4F20\u9012 com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "\u65E0\u6CD5\u5C06 DTMLiaison \u7528\u4E8E\u8F93\u5165 DOM \u8282\u70B9... \u8BF7\u6539\u4E3A\u4F20\u9012 com.sun.org.apache.xpath.internal.DOM2Helper!"}, + + {ER_CALL_TO_EXT_FAILED, + "\u672A\u80FD\u8C03\u7528\u6269\u5C55\u5143\u7D20: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "\u524D\u7F00\u5FC5\u987B\u89E3\u6790\u4E3A\u540D\u79F0\u7A7A\u95F4: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "\u68C0\u6D4B\u5230\u65E0\u6548\u7684 UTF-16 \u4EE3\u7406: {0}?"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} \u4F7F\u7528\u5176\u81EA\u8EAB, \u8FD9\u5C06\u5BFC\u81F4\u65E0\u9650\u5FAA\u73AF\u3002"}, + + {ER_CANNOT_MIX_XERCESDOM, + "\u65E0\u6CD5\u6DF7\u5408\u975E Xerces-DOM \u8F93\u5165\u548C Xerces-DOM \u8F93\u51FA!"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "\u5728 ElemTemplateElement.readObject \u4E2D: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "\u627E\u5230\u591A\u4E2A\u540D\u4E3A{0}\u7684\u6A21\u677F"}, + + {ER_INVALID_KEY_CALL, + "\u51FD\u6570\u8C03\u7528\u65E0\u6548: \u4E0D\u5141\u8BB8\u9012\u5F52 key() \u8C03\u7528"}, + + {ER_REFERENCING_ITSELF, + "\u53D8\u91CF {0} \u76F4\u63A5\u6216\u95F4\u63A5\u5F15\u7528\u5176\u81EA\u8EAB!"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "\u5BF9\u4E8E newTemplates \u7684 DOMSource, \u8F93\u5165\u8282\u70B9\u4E0D\u80FD\u4E3A\u7A7A\u503C!"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u627E\u4E0D\u5230\u9009\u9879{0}\u7684\u7C7B\u6587\u4EF6"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "\u627E\u4E0D\u5230\u6240\u9700\u5143\u7D20: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_URI_CANNOT_BE_NULL, + "URI \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_FILE_CANNOT_BE_NULL, + "File \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_CANNOT_INIT_BSFMGR, + "\u65E0\u6CD5\u521D\u59CB\u5316 BSF \u7BA1\u7406\u5668"}, + + {ER_CANNOT_CMPL_EXTENSN, + "\u65E0\u6CD5\u7F16\u8BD1\u6269\u5C55"}, + + {ER_CANNOT_CREATE_EXTENSN, + "\u65E0\u6CD5\u521B\u5EFA\u6269\u5C55: {0}, \u539F\u56E0: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u5BF9\u65B9\u6CD5{0}\u7684\u5B9E\u4F8B\u65B9\u6CD5\u8C03\u7528\u9700\u8981\u5C06 Object \u5B9E\u4F8B\u4F5C\u4E3A\u7B2C\u4E00\u4E2A\u53C2\u6570"}, + + {ER_INVALID_ELEMENT_NAME, + "\u6307\u5B9A\u7684\u5143\u7D20\u540D\u79F0{0}\u65E0\u6548"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "\u5143\u7D20\u540D\u79F0\u65B9\u6CD5\u5FC5\u987B\u662F static {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "\u6269\u5C55\u51FD\u6570 {0}: {1} \u672A\u77E5"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "{0}\u7684\u6784\u9020\u5668\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + {ER_MORE_MATCH_METHOD, + "\u65B9\u6CD5{0}\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + {ER_MORE_MATCH_ELEMENT, + "\u5143\u7D20\u65B9\u6CD5{0}\u5177\u6709\u591A\u4E2A\u6700\u4F73\u5339\u914D"}, + + {ER_INVALID_CONTEXT_PASSED, + "\u4F20\u9012\u7684\u7528\u4E8E\u5BF9{0}\u6C42\u503C\u7684\u4E0A\u4E0B\u6587\u65E0\u6548"}, + + {ER_POOL_EXISTS, + "\u6C60\u5DF2\u5B58\u5728"}, + + {ER_NO_DRIVER_NAME, + "\u672A\u6307\u5B9A\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0"}, + + {ER_NO_URL, + "\u672A\u6307\u5B9A URL"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "\u6C60\u5927\u5C0F\u5C0F\u4E8E 1!"}, + + {ER_INVALID_DRIVER, + "\u6307\u5B9A\u7684\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0\u65E0\u6548!"}, + + {ER_NO_STYLESHEETROOT, + "\u627E\u4E0D\u5230\u6837\u5F0F\u8868\u6839!"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space \u7684\u503C\u975E\u6CD5"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode \u5931\u8D25"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "\u8D44\u6E90 [ {0} ] \u65E0\u6CD5\u52A0\u8F7D: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u7F13\u51B2\u533A\u5927\u5C0F <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u8C03\u7528\u6269\u5C55\u65F6\u51FA\u73B0\u672A\u77E5\u9519\u8BEF"}, + + {ER_NO_NAMESPACE_DECL, + "\u524D\u7F00 {0} \u6CA1\u6709\u5BF9\u5E94\u7684\u540D\u79F0\u7A7A\u95F4\u58F0\u660E"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "lang=javaclass {0}\u4E0D\u5141\u8BB8\u4F7F\u7528\u5143\u7D20\u5185\u5BB9"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "\u6837\u5F0F\u8868\u6307\u5411\u7EC8\u6B62"}, + + {ER_ONE_OR_TWO, + "1 \u6216 2"}, + + {ER_TWO_OR_THREE, + "2 \u6216 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "\u65E0\u6CD5\u52A0\u8F7D{0} (\u68C0\u67E5 CLASSPATH), \u73B0\u5728\u53EA\u4F7F\u7528\u9ED8\u8BA4\u503C"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u65E0\u6CD5\u521D\u59CB\u5316\u9ED8\u8BA4\u6A21\u677F"}, + + {ER_RESULT_NULL, + "Result \u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "\u65E0\u6CD5\u8BBE\u7F6E Result"}, + + {ER_NO_OUTPUT_SPECIFIED, + "\u672A\u6307\u5B9A\u8F93\u51FA"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u65E0\u6CD5\u8F6C\u6362\u4E3A\u7C7B\u578B\u4E3A{0}\u7684 Result"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u65E0\u6CD5\u8F6C\u6362\u7C7B\u578B\u4E3A{0}\u7684\u6E90"}, + + {ER_NULL_CONTENT_HANDLER, + "\u7A7A\u5185\u5BB9\u5904\u7406\u7A0B\u5E8F"}, + + {ER_NULL_ERROR_HANDLER, + "\u7A7A\u9519\u8BEF\u5904\u7406\u7A0B\u5E8F"}, + + {ER_CANNOT_CALL_PARSE, + "\u5982\u679C\u5C1A\u672A\u8BBE\u7F6E ContentHandler, \u5219\u65E0\u6CD5\u8C03\u7528 parse"}, + + {ER_NO_PARENT_FOR_FILTER, + "\u7B5B\u9009\u5668\u6CA1\u6709\u7236\u7EA7"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "\u5728{0}\u4E2D\u627E\u4E0D\u5230\u6837\u5F0F\u8868, \u4ECB\u8D28= {1}"}, + + {ER_NO_STYLESHEET_PI, + "\u5728{0}\u4E2D\u627E\u4E0D\u5230 xml-stylesheet PI"}, + + {ER_NOT_SUPPORTED, + "\u4E0D\u652F\u6301: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "\u5C5E\u6027{0}\u7684\u503C\u5E94\u4E3A Boolean \u5B9E\u4F8B"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "\u65E0\u6CD5\u5728{0}\u4E2D\u83B7\u53D6\u5916\u90E8\u811A\u672C"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "\u627E\u4E0D\u5230\u8D44\u6E90 [ {0} ]\u3002\n {1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u65E0\u6CD5\u8BC6\u522B\u8F93\u51FA\u5C5E\u6027: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "\u672A\u80FD\u521B\u5EFA ElemLiteralResult \u5B9E\u4F8B"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "{0}\u7684\u503C\u5E94\u5305\u542B\u53EF\u89E3\u6790\u7684\u6570\u5B57"}, + + {ER_VALUE_SHOULD_EQUAL, + "{0}\u7684\u503C\u5E94\u7B49\u4E8E\u201C\u662F\u201D\u6216\u201C\u5426\u201D"}, + + {ER_FAILED_CALLING_METHOD, + "\u672A\u80FD\u8C03\u7528{0}\u65B9\u6CD5"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "\u672A\u80FD\u521B\u5EFA ElemTemplateElement \u5B9E\u4F8B"}, + + {ER_CHARS_NOT_ALLOWED, + "\u4E0D\u5141\u8BB8\u5728\u6587\u6863\u4E2D\u7684\u6B64\u4F4D\u7F6E\u5904\u4F7F\u7528\u5B57\u7B26"}, + + {ER_ATTR_NOT_ALLOWED, + "{1}\u5143\u7D20\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 \"{0}\" \u5C5E\u6027!"}, + + {ER_BAD_VALUE, + "{0}\u9519\u8BEF\u503C{1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "\u627E\u4E0D\u5230{0}\u5C5E\u6027\u503C "}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "\u65E0\u6CD5\u8BC6\u522B{0}\u5C5E\u6027\u503C "}, + + {ER_NULL_URI_NAMESPACE, + "\u5C1D\u8BD5\u4F7F\u7528\u7A7A URI \u751F\u6210\u540D\u79F0\u7A7A\u95F4\u524D\u7F00"}, + + {ER_NUMBER_TOO_BIG, + "\u5C1D\u8BD5\u8BBE\u7F6E\u8D85\u8FC7\u6700\u5927\u957F\u6574\u578B\u7684\u6570\u5B57\u7684\u683C\u5F0F"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "\u627E\u4E0D\u5230 SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "\u5DF2\u627E\u5230 SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}, \u4F46\u65E0\u6CD5\u8FDB\u884C\u52A0\u8F7D"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "\u5DF2\u52A0\u8F7D SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B{0}, \u4F46\u65E0\u6CD5\u8FDB\u884C\u5B9E\u4F8B\u5316"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \u9A71\u52A8\u7A0B\u5E8F\u7C7B {0} \u672A\u5B9E\u73B0 org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u672A\u6307\u5B9A\u7CFB\u7EDF\u5C5E\u6027 org.xml.sax.parser"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "\u89E3\u6790\u5668\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A\u503C"}, + + {ER_FEATURE, + "\u529F\u80FD: {0}"}, + + {ER_PROPERTY, + "\u5C5E\u6027: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "\u7A7A\u5B9E\u4F53\u89E3\u6790\u5668"}, + + {ER_NULL_DTD_HANDLER, + "\u7A7A DTD \u5904\u7406\u7A0B\u5E8F"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "\u672A\u6307\u5B9A\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0!"}, + + {ER_NO_URL_SPECIFIED, + "\u672A\u6307\u5B9A URL!"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "\u6C60\u5927\u5C0F\u5C0F\u4E8E 1!"}, + + {ER_INVALID_DRIVER_NAME, + "\u6307\u5B9A\u7684\u9A71\u52A8\u7A0B\u5E8F\u540D\u79F0\u65E0\u6548!"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "\u7A0B\u5E8F\u5458\u9519\u8BEF! \u8868\u8FBE\u5F0F\u6CA1\u6709 ElemTemplateElement \u7236\u7EA7!"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "RedundentExprEliminator \u4E2D\u7684\u7A0B\u5E8F\u5458\u65AD\u8A00: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "\u4E0D\u5141\u8BB8\u5728\u6837\u5F0F\u8868\u4E2D\u7684\u6B64\u4F4D\u7F6E\u4F7F\u7528{0}!"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u4E0D\u5141\u8BB8\u5728\u6837\u5F0F\u8868\u4E2D\u7684\u6B64\u4F4D\u7F6E\u4F7F\u7528\u975E\u7A7A\u767D\u6587\u672C!"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "CHAR \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}\u3002CHAR \u7C7B\u578B\u7684\u5C5E\u6027\u53EA\u80FD\u4E3A 1 \u4E2A\u5B57\u7B26!"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "QNAME \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "ENUM \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1}\u3002\u6709\u6548\u503C\u4E3A: {2}\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "NMTOKEN \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "NCNAME \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "Boolean \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "Number \u5C5E\u6027{0}\u4F7F\u7528\u4E86\u975E\u6CD5\u503C{1} "}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "\u5339\u914D\u6A21\u5F0F\u4E2D\u7684{0}\u7684\u53C2\u6570\u5FC5\u987B\u4E3A\u6587\u5B57\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "\u5168\u5C40\u53D8\u91CF\u58F0\u660E\u91CD\u590D\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "\u53D8\u91CF\u58F0\u660E\u91CD\u590D\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template \u5FC5\u987B\u5177\u6709 name \u548C/\u6216 match \u5C5E\u6027"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F00\u65E0\u6548: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "\u540D\u4E3A{0}\u7684\u5C5E\u6027\u96C6\u4E0D\u5B58\u5728"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "\u540D\u4E3A{0}\u7684\u51FD\u6570\u4E0D\u5B58\u5728"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0}\u5143\u7D20\u4E0D\u80FD\u540C\u65F6\u5177\u6709\u5185\u5BB9\u548C select \u5C5E\u6027\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "\u53C2\u6570 {0} \u7684\u503C\u5FC5\u987B\u662F\u6709\u6548 Java \u5BF9\u8C61"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C5E\u6027\u5177\u6709\u503C '#default', \u4F46\u8BE5\u5143\u7D20\u7684\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u9ED8\u8BA4\u540D\u79F0\u7A7A\u95F4\u7684\u58F0\u660E"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C5E\u6027\u5177\u6709\u503C ''{0}'', \u4F46\u8BE5\u5143\u7D20\u7684\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u524D\u7F00 ''{0}'' \u7684\u540D\u79F0\u7A7A\u95F4\u58F0\u660E\u3002"}, + + {ER_SET_FEATURE_NULL_NAME, + "TransformerFactory.setFeature(String name, boolean value) \u4E2D\u7684\u529F\u80FD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + {ER_GET_FEATURE_NULL_NAME, + "TransformerFactory.getFeature(String name) \u4E2D\u7684\u529F\u80FD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + {ER_UNSUPPORTED_FEATURE, + "\u65E0\u6CD5\u5BF9\u6B64 TransformerFactory \u8BBE\u7F6E\u529F\u80FD ''{0}''\u3002"}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u5F53\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u65F6, \u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u5143\u7D20 ''{0}''\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\u65E0\u6CD5\u83B7\u53D6\u7A7A\u540D\u79F0\u7A7A\u95F4 uri \u7684\u524D\u7F00\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\u65E0\u6CD5\u83B7\u53D6\u7A7A\u524D\u7F00\u7684\u540D\u79F0\u7A7A\u95F4 uri\u3002"}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "\u51FD\u6570\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u503C\u3002"}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "\u5143\u6570\u4E0D\u80FD\u4E3A\u8D1F\u6570\u3002"}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "\u5DF2\u627E\u5230 '}', \u4F46\u672A\u6253\u5F00\u5C5E\u6027\u6A21\u677F!"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: count \u5C5E\u6027\u4E0E xsl:number \u4E2D\u7684 ancestor \u4E0D\u5339\u914D! \u76EE\u6807 = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u65E7\u8BED\u6CD5: 'expr' \u5C5E\u6027\u7684\u540D\u79F0\u5DF2\u66F4\u6539\u4E3A 'select'\u3002"}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan \u5C1A\u672A\u5904\u7406 format-number \u51FD\u6570\u4E2D\u7684\u533A\u57DF\u8BBE\u7F6E\u540D\u79F0\u3002"}, + + {WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: \u627E\u4E0D\u5230 xml:lang={0} \u7684\u533A\u57DF\u8BBE\u7F6E"}, + + {WG_CANNOT_MAKE_URL_FROM, + "\u65E0\u6CD5\u6839\u636E{0}\u751F\u6210 URL"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "\u65E0\u6CD5\u52A0\u8F7D\u8BF7\u6C42\u7684\u6587\u6863: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "\u627E\u4E0D\u5230 >>>>>> Xalan \u7248\u672C "}, + {"version2", "<<<<<<<"}, + {"yes", "\u662F"}, + {"line", "\u884C\u53F7"}, + {"column", "\u5217\u53F7"}, + {"xsldone", "XSLProcessor: \u5B8C\u6210"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J \u547D\u4EE4\u884C Process \u7C7B\u9009\u9879:"}, + {"xslProc_option", "Xalan-J \u547D\u4EE4\u884C Process \u7C7B\u9009\u9879:"}, + {"xslProc_invalid_xsltc_option", "XSLTC \u6A21\u5F0F\u4E0B\u4E0D\u652F\u6301\u9009\u9879{0}\u3002"}, + {"xslProc_invalid_xalan_option", "\u9009\u9879{0}\u53EA\u80FD\u4E0E -XSLTC \u4E00\u8D77\u4F7F\u7528\u3002"}, + {"xslProc_no_input", "\u9519\u8BEF: \u672A\u6307\u5B9A\u6837\u5F0F\u8868\u6216\u8F93\u5165 xml\u3002\u8FD0\u884C\u6B64\u547D\u4EE4\u65F6, \u7528\u6CD5\u6307\u4EE4\u4E0D\u5E26\u4EFB\u4F55\u9009\u9879\u3002"}, + {"xslProc_common_options", "-\u516C\u7528\u9009\u9879-"}, + {"xslProc_xalan_options", "-Xalan \u7684\u9009\u9879-"}, + {"xslProc_xsltc_options", "-XSLTC \u7684\u9009\u9879-"}, + {"xslProc_return_to_continue", "(\u6309 \u4EE5\u7EE7\u7EED)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (\u4F7F\u7528 XSLTC \u8FDB\u884C\u8F6C\u6362)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER fully qualified class name of parser liaison]"}, + {"optionE", " [-E (\u4E0D\u5C55\u5F00\u5B9E\u4F53\u5F15\u7528)]"}, + {"optionV", " [-E (\u4E0D\u5C55\u5F00\u5B9E\u4F53\u5F15\u7528)]"}, + {"optionQC", " [-QC (\u65E0\u63D0\u793A\u6A21\u5F0F\u51B2\u7A81\u8B66\u544A)]"}, + {"optionQ", " [-Q (\u65E0\u63D0\u793A\u6A21\u5F0F)]"}, + {"optionLF", " [-LF (\u4EC5\u5728\u8F93\u51FA\u65F6\u4F7F\u7528\u6362\u884C\u7B26 {\u9ED8\u8BA4\u503C\u4E3A CR/LF})]"}, + {"optionCR", " [-CR (\u4EC5\u5728\u8F93\u51FA\u65F6\u4F7F\u7528\u56DE\u8F66 {\u9ED8\u8BA4\u503C\u4E3A CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (\u8981\u8F6C\u79FB\u7684\u5B57\u7B26 {\u9ED8\u8BA4\u503C\u4E3A <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (\u63A7\u5236\u8981\u7F29\u8FDB\u7684\u7A7A\u683C\u6570 {\u9ED8\u8BA4\u503C\u4E3A 0})]"}, + {"optionTT", " [-TT (\u5728\u8C03\u7528\u6A21\u677F\u65F6\u8DDF\u8E2A\u6A21\u677F\u3002)]"}, + {"optionTG", " [-TG (\u8DDF\u8E2A\u6BCF\u4E2A\u751F\u6210\u4E8B\u4EF6\u3002)]"}, + {"optionTS", " [-TS (\u8DDF\u8E2A\u6BCF\u4E2A\u9009\u62E9\u4E8B\u4EF6\u3002)]"}, + {"optionTTC", " [-TTC (\u5728\u5904\u7406\u6A21\u677F\u5B50\u7EA7\u65F6\u8DDF\u8E2A\u6A21\u677F\u5B50\u7EA7\u3002)]"}, + {"optionTCLASS", " [-TCLASS (\u7528\u4E8E\u8DDF\u8E2A\u6269\u5C55\u7684 TraceListener \u7C7B\u3002)]"}, + {"optionVALIDATE", " [-VALIDATE (\u8BBE\u7F6E\u662F\u5426\u8FDB\u884C\u9A8C\u8BC1\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u7981\u6B62\u9A8C\u8BC1\u3002)]"}, + {"optionEDUMP", " [-EDUMP {optional filename} (\u5728\u51FA\u9519\u65F6\u6267\u884C\u5806\u6808\u8F6C\u50A8\u3002)]"}, + {"optionXML", " [-XML (\u4F7F\u7528 XML \u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u5E76\u6DFB\u52A0 XML \u6807\u5934\u3002)]"}, + {"optionTEXT", " [-TEXT (\u4F7F\u7528\u7B80\u5355\u6587\u672C\u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u3002)]"}, + {"optionHTML", " [-HTML (\u4F7F\u7528 HTML \u683C\u5F0F\u8BBE\u7F6E\u5DE5\u5177\u3002)]"}, + {"optionPARAM", " [-PARAM \u540D\u79F0\u8868\u8FBE\u5F0F (\u8BBE\u7F6E\u6837\u5F0F\u8868\u53C2\u6570)]"}, + {"noParsermsg1", "XSL \u8FDB\u7A0B\u672A\u6210\u529F\u3002"}, + {"noParsermsg2", "** \u627E\u4E0D\u5230\u89E3\u6790\u5668 **"}, + {"noParsermsg3", "\u8BF7\u68C0\u67E5\u60A8\u7684\u7C7B\u8DEF\u5F84\u3002"}, + {"noParsermsg4", "\u5982\u679C\u6CA1\u6709 IBM \u63D0\u4F9B\u7684 XML Parser for Java, \u5219\u53EF\u4EE5\u4ECE"}, + {"noParsermsg5", "IBM AlphaWorks \u8FDB\u884C\u4E0B\u8F7D, \u7F51\u5740\u4E3A: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 URIResolver \u89E3\u6790 URI)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 EntityResolver \u89E3\u6790\u5B9E\u4F53)]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER \u5B8C\u6574\u7C7B\u540D (\u4F7F\u7528 ContentHandler \u5E8F\u5217\u5316\u8F93\u51FA)]"}, + {"optionLINENUMBERS", " [-L \u4F7F\u7528\u6E90\u6587\u6863\u7684\u884C\u53F7]"}, + {"optionSECUREPROCESSING", " [-SECURE (\u5C06\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (\u4F7F\u7528 media \u5C5E\u6027\u67E5\u627E\u4E0E\u6587\u6863\u5173\u8054\u7684\u6837\u5F0F\u8868\u3002)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (\u660E\u786E\u4F7F\u7528 s2s=SAX \u6216 d2d=DOM \u6267\u884C\u8F6C\u6362\u3002)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (\u8F93\u51FA\u5168\u90E8\u8F6C\u6362\u65F6\u95F4 (\u6BEB\u79D2)\u3002)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (\u901A\u8FC7\u5C06 http://xml.apache.org/xalan/features/incremental \u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u6765\u8BF7\u6C42\u589E\u91CF DTM \u6784\u5EFA\u3002)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (\u901A\u8FC7\u5C06 http://xml.apache.org/xalan/features/optimize \u8BBE\u7F6E\u4E3A\u201C\u5047\u201D\u6765\u8BF7\u6C42\u4E0D\u6267\u884C\u6837\u5F0F\u8868\u4F18\u5316\u5904\u7406\u3002)]"}, + {"optionRL", " [-RL recursionlimit (\u58F0\u660E\u6837\u5F0F\u8868\u9012\u5F52\u6DF1\u5EA6\u7684\u6570\u5B57\u9650\u5236\u3002)]"}, + {"optionXO", " [-XO [transletName] (\u4E3A\u751F\u6210\u7684 translet \u5206\u914D\u540D\u79F0)]"}, + {"optionXD", " [-XD destinationDirectory (\u6307\u5B9A translet \u7684\u76EE\u6807\u76EE\u5F55)]"}, + {"optionXJ", " [-XJ jarfile (\u5C06 translet \u7C7B\u6253\u5305\u5230\u540D\u4E3A \u7684 jar \u6587\u4EF6\u4E2D)]"}, + {"optionXP", " [-XP package (\u4E3A\u751F\u6210\u7684\u6240\u6709 translet \u7C7B\u6307\u5B9A\u7A0B\u5E8F\u5305\u540D\u79F0\u524D\u7F00)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (\u542F\u7528\u6A21\u677F\u5185\u5D4C)]"}, + {"optionXX", " [-XX (\u542F\u7528\u9644\u52A0\u8C03\u8BD5\u6D88\u606F\u8F93\u51FA)]"}, + {"optionXT", " [-XT (\u5982\u679C\u53EF\u80FD, \u4F7F\u7528 translet \u8FDB\u884C\u8F6C\u6362)]"}, + {"diagTiming", " --------- \u901A\u8FC7{1}\u8F6C\u6362{0}\u82B1\u8D39\u4E86 {2} \u6BEB\u79D2\u7684\u65F6\u95F4"}, + {"recursionTooDeep", "\u6A21\u677F\u5D4C\u5957\u592A\u6DF1\u3002\u5D4C\u5957 = {0}, \u6A21\u677F{1} {2}"}, + {"nameIs", "\u540D\u79F0\u4E3A"}, + {"matchPatternIs", "\u5339\u914D\u6A21\u5F0F\u4E3A"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java new file mode 100644 index 0000000..ed96b71 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java @@ -0,0 +1,1428 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.res; + +import java.util.ListResourceBundle; + +/** + * Set up error messages. + * We build a two dimensional array of message keys and + * message strings. In order to add a new message here, + * you need to first add a String constant. And + * you need to enter key , value pair as part of contents + * Array. You also need to update MAX_CODE for error strings + * and MAX_WARNING for warnings ( Needed for only information + * purpose ) + */ +public class XSLTErrorResources_zh_TW extends ListResourceBundle { + + /* + * This file contains error and warning messages related to Xalan Error + * Handling. + * + * General notes to translators: + * + * 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of + * components. + * XSLT is an acronym for "XML Stylesheet Language: Transformations". + * XSLTC is an acronym for XSLT Compiler. + * + * 2) A stylesheet is a description of how to transform an input XML document + * into a resultant XML document (or HTML document or text). The + * stylesheet itself is described in the form of an XML document. + * + * 3) A template is a component of a stylesheet that is used to match a + * particular portion of an input document and specifies the form of the + * corresponding portion of the output document. + * + * 4) An element is a mark-up tag in an XML document; an attribute is a + * modifier on the tag. For example, in + * "elem" is an element name, "attr" and "attr2" are attribute names with + * the values "val" and "val2", respectively. + * + * 5) A namespace declaration is a special attribute that is used to associate + * a prefix with a URI (the namespace). The meanings of element names and + * attribute names that use that prefix are defined with respect to that + * namespace. + * + * 6) "Translet" is an invented term that describes the class file that + * results from compiling an XML stylesheet into a Java class. + * + * 7) XPath is a specification that describes a notation for identifying + * nodes in a tree-structured representation of an XML document. An + * instance of that notation is referred to as an XPath expression. + * + */ + + /* + * Static variables + */ + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX = + "ER_INVALID_SET_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX"; + + public static final String ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT = + "ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT"; + + public static final String ER_NO_CURLYBRACE = "ER_NO_CURLYBRACE"; + public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIBUTE = "ER_ILLEGAL_ATTRIBUTE"; + public static final String ER_NULL_SOURCENODE_APPLYIMPORTS = "ER_NULL_SOURCENODE_APPLYIMPORTS"; + public static final String ER_CANNOT_ADD = "ER_CANNOT_ADD"; + public static final String ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES = "ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES"; + public static final String ER_NO_NAME_ATTRIB = "ER_NO_NAME_ATTRIB"; + public static final String ER_TEMPLATE_NOT_FOUND = "ER_TEMPLATE_NOT_FOUND"; + public static final String ER_CANT_RESOLVE_NAME_AVT = "ER_CANT_RESOLVE_NAME_AVT"; + public static final String ER_REQUIRES_ATTRIB = "ER_REQUIRES_ATTRIB"; + public static final String ER_MUST_HAVE_TEST_ATTRIB = "ER_MUST_HAVE_TEST_ATTRIB"; + public static final String ER_BAD_VAL_ON_LEVEL_ATTRIB = + "ER_BAD_VAL_ON_LEVEL_ATTRIB"; + public static final String ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB"; + public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = + "ER_NEED_NAME_OR_MATCH_ATTRIB"; + public static final String ER_CANT_RESOLVE_NSPREFIX = + "ER_CANT_RESOLVE_NSPREFIX"; + public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE"; + public static final String ER_NO_OWNERDOC = "ER_NO_OWNERDOC"; + public static final String ER_ELEMTEMPLATEELEM_ERR = "ER_ELEMTEMPLATEELEM_ERR"; + public static final String ER_NULL_CHILD = "ER_NULL_CHILD"; + public static final String ER_NEED_SELECT_ATTRIB = "ER_NEED_SELECT_ATTRIB"; + public static final String ER_NEED_TEST_ATTRIB = "ER_NEED_TEST_ATTRIB"; + public static final String ER_NEED_NAME_ATTRIB = "ER_NEED_NAME_ATTRIB"; + public static final String ER_NO_CONTEXT_OWNERDOC = "ER_NO_CONTEXT_OWNERDOC"; + public static final String ER_COULD_NOT_CREATE_XML_PROC_LIAISON = + "ER_COULD_NOT_CREATE_XML_PROC_LIAISON"; + public static final String ER_PROCESS_NOT_SUCCESSFUL = + "ER_PROCESS_NOT_SUCCESSFUL"; + public static final String ER_NOT_SUCCESSFUL = "ER_NOT_SUCCESSFUL"; + public static final String ER_ENCODING_NOT_SUPPORTED = + "ER_ENCODING_NOT_SUPPORTED"; + public static final String ER_COULD_NOT_CREATE_TRACELISTENER = + "ER_COULD_NOT_CREATE_TRACELISTENER"; + public static final String ER_KEY_REQUIRES_NAME_ATTRIB = + "ER_KEY_REQUIRES_NAME_ATTRIB"; + public static final String ER_KEY_REQUIRES_MATCH_ATTRIB = + "ER_KEY_REQUIRES_MATCH_ATTRIB"; + public static final String ER_KEY_REQUIRES_USE_ATTRIB = + "ER_KEY_REQUIRES_USE_ATTRIB"; + public static final String ER_REQUIRES_ELEMENTS_ATTRIB = + "ER_REQUIRES_ELEMENTS_ATTRIB"; + public static final String ER_MISSING_PREFIX_ATTRIB = + "ER_MISSING_PREFIX_ATTRIB"; + public static final String ER_BAD_STYLESHEET_URL = "ER_BAD_STYLESHEET_URL"; + public static final String ER_FILE_NOT_FOUND = "ER_FILE_NOT_FOUND"; + public static final String ER_IOEXCEPTION = "ER_IOEXCEPTION"; + public static final String ER_NO_HREF_ATTRIB = "ER_NO_HREF_ATTRIB"; + public static final String ER_STYLESHEET_INCLUDES_ITSELF = + "ER_STYLESHEET_INCLUDES_ITSELF"; + public static final String ER_PROCESSINCLUDE_ERROR = "ER_PROCESSINCLUDE_ERROR"; + public static final String ER_MISSING_LANG_ATTRIB = "ER_MISSING_LANG_ATTRIB"; + public static final String ER_MISSING_CONTAINER_ELEMENT_COMPONENT = + "ER_MISSING_CONTAINER_ELEMENT_COMPONENT"; + public static final String ER_CAN_ONLY_OUTPUT_TO_ELEMENT = + "ER_CAN_ONLY_OUTPUT_TO_ELEMENT"; + public static final String ER_PROCESS_ERROR = "ER_PROCESS_ERROR"; + public static final String ER_UNIMPLNODE_ERROR = "ER_UNIMPLNODE_ERROR"; + public static final String ER_NO_SELECT_EXPRESSION = "ER_NO_SELECT_EXPRESSION"; + public static final String ER_CANNOT_SERIALIZE_XSLPROCESSOR = + "ER_CANNOT_SERIALIZE_XSLPROCESSOR"; + public static final String ER_NO_INPUT_STYLESHEET = "ER_NO_INPUT_STYLESHEET"; + public static final String ER_FAILED_PROCESS_STYLESHEET = + "ER_FAILED_PROCESS_STYLESHEET"; + public static final String ER_COULDNT_PARSE_DOC = "ER_COULDNT_PARSE_DOC"; + public static final String ER_COULDNT_FIND_FRAGMENT = + "ER_COULDNT_FIND_FRAGMENT"; + public static final String ER_NODE_NOT_ELEMENT = "ER_NODE_NOT_ELEMENT"; + public static final String ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB = + "ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB = + "ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB"; + public static final String ER_NO_CLONE_OF_DOCUMENT_FRAG = + "ER_NO_CLONE_OF_DOCUMENT_FRAG"; + public static final String ER_CANT_CREATE_ITEM = "ER_CANT_CREATE_ITEM"; + public static final String ER_XMLSPACE_ILLEGAL_VALUE = + "ER_XMLSPACE_ILLEGAL_VALUE"; + public static final String ER_NO_XSLKEY_DECLARATION = + "ER_NO_XSLKEY_DECLARATION"; + public static final String ER_CANT_CREATE_URL = "ER_CANT_CREATE_URL"; + public static final String ER_XSLFUNCTIONS_UNSUPPORTED = + "ER_XSLFUNCTIONS_UNSUPPORTED"; + public static final String ER_PROCESSOR_ERROR = "ER_PROCESSOR_ERROR"; + public static final String ER_NOT_ALLOWED_INSIDE_STYLESHEET = + "ER_NOT_ALLOWED_INSIDE_STYLESHEET"; + public static final String ER_RESULTNS_NOT_SUPPORTED = + "ER_RESULTNS_NOT_SUPPORTED"; + public static final String ER_DEFAULTSPACE_NOT_SUPPORTED = + "ER_DEFAULTSPACE_NOT_SUPPORTED"; + public static final String ER_INDENTRESULT_NOT_SUPPORTED = + "ER_INDENTRESULT_NOT_SUPPORTED"; + public static final String ER_ILLEGAL_ATTRIB = "ER_ILLEGAL_ATTRIB"; + public static final String ER_UNKNOWN_XSL_ELEM = "ER_UNKNOWN_XSL_ELEM"; + public static final String ER_BAD_XSLSORT_USE = "ER_BAD_XSLSORT_USE"; + public static final String ER_MISPLACED_XSLWHEN = "ER_MISPLACED_XSLWHEN"; + public static final String ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_MISPLACED_XSLOTHERWISE = + "ER_MISPLACED_XSLOTHERWISE"; + public static final String ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE = + "ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE"; + public static final String ER_NOT_ALLOWED_INSIDE_TEMPLATE = + "ER_NOT_ALLOWED_INSIDE_TEMPLATE"; + public static final String ER_UNKNOWN_EXT_NS_PREFIX = + "ER_UNKNOWN_EXT_NS_PREFIX"; + public static final String ER_IMPORTS_AS_FIRST_ELEM = + "ER_IMPORTS_AS_FIRST_ELEM"; + public static final String ER_IMPORTING_ITSELF = "ER_IMPORTING_ITSELF"; + public static final String ER_XMLSPACE_ILLEGAL_VAL = "ER_XMLSPACE_ILLEGAL_VAL"; + public static final String ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL = + "ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL"; + public static final String ER_SAX_EXCEPTION = "ER_SAX_EXCEPTION"; + public static final String ER_XSLT_ERROR = "ER_XSLT_ERROR"; + public static final String ER_CURRENCY_SIGN_ILLEGAL = + "ER_CURRENCY_SIGN_ILLEGAL"; + public static final String ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM = + "ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM"; + public static final String ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER = + "ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER"; + public static final String ER_REDIRECT_COULDNT_GET_FILENAME = + "ER_REDIRECT_COULDNT_GET_FILENAME"; + public static final String ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT = + "ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT"; + public static final String ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX = + "ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX"; + public static final String ER_MISSING_NS_URI = "ER_MISSING_NS_URI"; + public static final String ER_MISSING_ARG_FOR_OPTION = + "ER_MISSING_ARG_FOR_OPTION"; + public static final String ER_INVALID_OPTION = "ER_INVALID_OPTION"; + public static final String ER_MALFORMED_FORMAT_STRING = + "ER_MALFORMED_FORMAT_STRING"; + public static final String ER_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "ER_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String ER_ILLEGAL_ATTRIBUTE_VALUE = + "ER_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String ER_CHOOSE_REQUIRES_WHEN = "ER_CHOOSE_REQUIRES_WHEN"; + public static final String ER_NO_APPLY_IMPORT_IN_FOR_EACH = + "ER_NO_APPLY_IMPORT_IN_FOR_EACH"; + public static final String ER_CANT_USE_DTM_FOR_OUTPUT = + "ER_CANT_USE_DTM_FOR_OUTPUT"; + public static final String ER_CANT_USE_DTM_FOR_INPUT = + "ER_CANT_USE_DTM_FOR_INPUT"; + public static final String ER_CALL_TO_EXT_FAILED = "ER_CALL_TO_EXT_FAILED"; + public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE"; + public static final String ER_INVALID_UTF16_SURROGATE = + "ER_INVALID_UTF16_SURROGATE"; + public static final String ER_XSLATTRSET_USED_ITSELF = + "ER_XSLATTRSET_USED_ITSELF"; + public static final String ER_CANNOT_MIX_XERCESDOM = "ER_CANNOT_MIX_XERCESDOM"; + public static final String ER_TOO_MANY_LISTENERS = "ER_TOO_MANY_LISTENERS"; + public static final String ER_IN_ELEMTEMPLATEELEM_READOBJECT = + "ER_IN_ELEMTEMPLATEELEM_READOBJECT"; + public static final String ER_DUPLICATE_NAMED_TEMPLATE = + "ER_DUPLICATE_NAMED_TEMPLATE"; + public static final String ER_INVALID_KEY_CALL = "ER_INVALID_KEY_CALL"; + public static final String ER_REFERENCING_ITSELF = "ER_REFERENCING_ITSELF"; + public static final String ER_ILLEGAL_DOMSOURCE_INPUT = + "ER_ILLEGAL_DOMSOURCE_INPUT"; + public static final String ER_CLASS_NOT_FOUND_FOR_OPTION = + "ER_CLASS_NOT_FOUND_FOR_OPTION"; + public static final String ER_REQUIRED_ELEM_NOT_FOUND = + "ER_REQUIRED_ELEM_NOT_FOUND"; + public static final String ER_INPUT_CANNOT_BE_NULL = "ER_INPUT_CANNOT_BE_NULL"; + public static final String ER_URI_CANNOT_BE_NULL = "ER_URI_CANNOT_BE_NULL"; + public static final String ER_FILE_CANNOT_BE_NULL = "ER_FILE_CANNOT_BE_NULL"; + public static final String ER_SOURCE_CANNOT_BE_NULL = + "ER_SOURCE_CANNOT_BE_NULL"; + public static final String ER_CANNOT_INIT_BSFMGR = "ER_CANNOT_INIT_BSFMGR"; + public static final String ER_CANNOT_CMPL_EXTENSN = "ER_CANNOT_CMPL_EXTENSN"; + public static final String ER_CANNOT_CREATE_EXTENSN = + "ER_CANNOT_CREATE_EXTENSN"; + public static final String ER_INSTANCE_MTHD_CALL_REQUIRES = + "ER_INSTANCE_MTHD_CALL_REQUIRES"; + public static final String ER_INVALID_ELEMENT_NAME = "ER_INVALID_ELEMENT_NAME"; + public static final String ER_ELEMENT_NAME_METHOD_STATIC = + "ER_ELEMENT_NAME_METHOD_STATIC"; + public static final String ER_EXTENSION_FUNC_UNKNOWN = + "ER_EXTENSION_FUNC_UNKNOWN"; + public static final String ER_MORE_MATCH_CONSTRUCTOR = + "ER_MORE_MATCH_CONSTRUCTOR"; + public static final String ER_MORE_MATCH_METHOD = "ER_MORE_MATCH_METHOD"; + public static final String ER_MORE_MATCH_ELEMENT = "ER_MORE_MATCH_ELEMENT"; + public static final String ER_INVALID_CONTEXT_PASSED = + "ER_INVALID_CONTEXT_PASSED"; + public static final String ER_POOL_EXISTS = "ER_POOL_EXISTS"; + public static final String ER_NO_DRIVER_NAME = "ER_NO_DRIVER_NAME"; + public static final String ER_NO_URL = "ER_NO_URL"; + public static final String ER_POOL_SIZE_LESSTHAN_ONE = + "ER_POOL_SIZE_LESSTHAN_ONE"; + public static final String ER_INVALID_DRIVER = "ER_INVALID_DRIVER"; + public static final String ER_NO_STYLESHEETROOT = "ER_NO_STYLESHEETROOT"; + public static final String ER_ILLEGAL_XMLSPACE_VALUE = + "ER_ILLEGAL_XMLSPACE_VALUE"; + public static final String ER_PROCESSFROMNODE_FAILED = + "ER_PROCESSFROMNODE_FAILED"; + public static final String ER_RESOURCE_COULD_NOT_LOAD = + "ER_RESOURCE_COULD_NOT_LOAD"; + public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = + "ER_BUFFER_SIZE_LESSTHAN_ZERO"; + public static final String ER_UNKNOWN_ERROR_CALLING_EXTENSION = + "ER_UNKNOWN_ERROR_CALLING_EXTENSION"; + public static final String ER_NO_NAMESPACE_DECL = "ER_NO_NAMESPACE_DECL"; + public static final String ER_ELEM_CONTENT_NOT_ALLOWED = + "ER_ELEM_CONTENT_NOT_ALLOWED"; + public static final String ER_STYLESHEET_DIRECTED_TERMINATION = + "ER_STYLESHEET_DIRECTED_TERMINATION"; + public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO"; + public static final String ER_TWO_OR_THREE = "ER_TWO_OR_THREE"; + public static final String ER_COULD_NOT_LOAD_RESOURCE = + "ER_COULD_NOT_LOAD_RESOURCE"; + public static final String ER_CANNOT_INIT_DEFAULT_TEMPLATES = + "ER_CANNOT_INIT_DEFAULT_TEMPLATES"; + public static final String ER_RESULT_NULL = "ER_RESULT_NULL"; + public static final String ER_RESULT_COULD_NOT_BE_SET = + "ER_RESULT_COULD_NOT_BE_SET"; + public static final String ER_NO_OUTPUT_SPECIFIED = "ER_NO_OUTPUT_SPECIFIED"; + public static final String ER_CANNOT_TRANSFORM_TO_RESULT_TYPE = + "ER_CANNOT_TRANSFORM_TO_RESULT_TYPE"; + public static final String ER_CANNOT_TRANSFORM_SOURCE_TYPE = + "ER_CANNOT_TRANSFORM_SOURCE_TYPE"; + public static final String ER_NULL_CONTENT_HANDLER = "ER_NULL_CONTENT_HANDLER"; + public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER"; + public static final String ER_CANNOT_CALL_PARSE = "ER_CANNOT_CALL_PARSE"; + public static final String ER_NO_PARENT_FOR_FILTER = "ER_NO_PARENT_FOR_FILTER"; + public static final String ER_NO_STYLESHEET_IN_MEDIA = + "ER_NO_STYLESHEET_IN_MEDIA"; + public static final String ER_NO_STYLESHEET_PI = "ER_NO_STYLESHEET_PI"; + public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED"; + public static final String ER_PROPERTY_VALUE_BOOLEAN = + "ER_PROPERTY_VALUE_BOOLEAN"; + public static final String ER_COULD_NOT_FIND_EXTERN_SCRIPT = + "ER_COULD_NOT_FIND_EXTERN_SCRIPT"; + public static final String ER_RESOURCE_COULD_NOT_FIND = + "ER_RESOURCE_COULD_NOT_FIND"; + public static final String ER_OUTPUT_PROPERTY_NOT_RECOGNIZED = + "ER_OUTPUT_PROPERTY_NOT_RECOGNIZED"; + public static final String ER_FAILED_CREATING_ELEMLITRSLT = + "ER_FAILED_CREATING_ELEMLITRSLT"; + public static final String ER_VALUE_SHOULD_BE_NUMBER = + "ER_VALUE_SHOULD_BE_NUMBER"; + public static final String ER_VALUE_SHOULD_EQUAL = "ER_VALUE_SHOULD_EQUAL"; + public static final String ER_FAILED_CALLING_METHOD = + "ER_FAILED_CALLING_METHOD"; + public static final String ER_FAILED_CREATING_ELEMTMPL = + "ER_FAILED_CREATING_ELEMTMPL"; + public static final String ER_CHARS_NOT_ALLOWED = "ER_CHARS_NOT_ALLOWED"; + public static final String ER_ATTR_NOT_ALLOWED = "ER_ATTR_NOT_ALLOWED"; + public static final String ER_BAD_VALUE = "ER_BAD_VALUE"; + public static final String ER_ATTRIB_VALUE_NOT_FOUND = + "ER_ATTRIB_VALUE_NOT_FOUND"; + public static final String ER_ATTRIB_VALUE_NOT_RECOGNIZED = + "ER_ATTRIB_VALUE_NOT_RECOGNIZED"; + public static final String ER_NULL_URI_NAMESPACE = "ER_NULL_URI_NAMESPACE"; + public static final String ER_NUMBER_TOO_BIG = "ER_NUMBER_TOO_BIG"; + public static final String ER_CANNOT_FIND_SAX1_DRIVER = + "ER_CANNOT_FIND_SAX1_DRIVER"; + public static final String ER_SAX1_DRIVER_NOT_LOADED = + "ER_SAX1_DRIVER_NOT_LOADED"; + public static final String ER_SAX1_DRIVER_NOT_INSTANTIATED = + "ER_SAX1_DRIVER_NOT_INSTANTIATED"; + public static final String ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER = + "ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER"; + public static final String ER_PARSER_PROPERTY_NOT_SPECIFIED = + "ER_PARSER_PROPERTY_NOT_SPECIFIED"; + public static final String ER_PARSER_ARG_CANNOT_BE_NULL = + "ER_PARSER_ARG_CANNOT_BE_NULL"; + public static final String ER_FEATURE = "ER_FEATURE"; + public static final String ER_PROPERTY = "ER_PROPERTY"; + public static final String ER_NULL_ENTITY_RESOLVER = "ER_NULL_ENTITY_RESOLVER"; + public static final String ER_NULL_DTD_HANDLER = "ER_NULL_DTD_HANDLER"; + public static final String ER_NO_DRIVER_NAME_SPECIFIED = + "ER_NO_DRIVER_NAME_SPECIFIED"; + public static final String ER_NO_URL_SPECIFIED = "ER_NO_URL_SPECIFIED"; + public static final String ER_POOLSIZE_LESS_THAN_ONE = + "ER_POOLSIZE_LESS_THAN_ONE"; + public static final String ER_INVALID_DRIVER_NAME = "ER_INVALID_DRIVER_NAME"; + public static final String ER_ERRORLISTENER = "ER_ERRORLISTENER"; + public static final String ER_ASSERT_NO_TEMPLATE_PARENT = + "ER_ASSERT_NO_TEMPLATE_PARENT"; + public static final String ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR = + "ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR"; + public static final String ER_NOT_ALLOWED_IN_POSITION = + "ER_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION = + "ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION"; + public static final String ER_NAMESPACE_CONTEXT_NULL_NAMESPACE = + "ER_NAMESPACE_CONTEXT_NULL_NAMESPACE"; + public static final String ER_NAMESPACE_CONTEXT_NULL_PREFIX = + "ER_NAMESPACE_CONTEXT_NULL_PREFIX"; + public static final String ER_XPATH_RESOLVER_NULL_QNAME = + "ER_XPATH_RESOLVER_NULL_QNAME"; + public static final String ER_XPATH_RESOLVER_NEGATIVE_ARITY = + "ER_XPATH_RESOLVER_NEGATIVE_ARITY"; + public static final String INVALID_TCHAR = "INVALID_TCHAR"; + public static final String INVALID_QNAME = "INVALID_QNAME"; + public static final String INVALID_ENUM = "INVALID_ENUM"; + public static final String INVALID_NMTOKEN = "INVALID_NMTOKEN"; + public static final String INVALID_NCNAME = "INVALID_NCNAME"; + public static final String INVALID_BOOLEAN = "INVALID_BOOLEAN"; + public static final String INVALID_NUMBER = "INVALID_NUMBER"; + public static final String ER_ARG_LITERAL = "ER_ARG_LITERAL"; + public static final String ER_DUPLICATE_GLOBAL_VAR = "ER_DUPLICATE_GLOBAL_VAR"; + public static final String ER_DUPLICATE_VAR = "ER_DUPLICATE_VAR"; + public static final String ER_TEMPLATE_NAME_MATCH = "ER_TEMPLATE_NAME_MATCH"; + public static final String ER_INVALID_PREFIX = "ER_INVALID_PREFIX"; + public static final String ER_NO_ATTRIB_SET = "ER_NO_ATTRIB_SET"; + public static final String ER_FUNCTION_NOT_FOUND = + "ER_FUNCTION_NOT_FOUND"; + public static final String ER_CANT_HAVE_CONTENT_AND_SELECT = + "ER_CANT_HAVE_CONTENT_AND_SELECT"; + public static final String ER_INVALID_SET_PARAM_VALUE = "ER_INVALID_SET_PARAM_VALUE"; + public static final String ER_SET_FEATURE_NULL_NAME = + "ER_SET_FEATURE_NULL_NAME"; + public static final String ER_GET_FEATURE_NULL_NAME = + "ER_GET_FEATURE_NULL_NAME"; + public static final String ER_UNSUPPORTED_FEATURE = + "ER_UNSUPPORTED_FEATURE"; + public static final String ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING = + "ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING"; + + public static final String WG_FOUND_CURLYBRACE = "WG_FOUND_CURLYBRACE"; + public static final String WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR = + "WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR"; + public static final String WG_EXPR_ATTRIB_CHANGED_TO_SELECT = + "WG_EXPR_ATTRIB_CHANGED_TO_SELECT"; + public static final String WG_NO_LOCALE_IN_FORMATNUMBER = + "WG_NO_LOCALE_IN_FORMATNUMBER"; + public static final String WG_LOCALE_NOT_FOUND = "WG_LOCALE_NOT_FOUND"; + public static final String WG_CANNOT_MAKE_URL_FROM = "WG_CANNOT_MAKE_URL_FROM"; + public static final String WG_CANNOT_LOAD_REQUESTED_DOC = + "WG_CANNOT_LOAD_REQUESTED_DOC"; + public static final String WG_CANNOT_FIND_COLLATOR = "WG_CANNOT_FIND_COLLATOR"; + public static final String WG_FUNCTIONS_SHOULD_USE_URL = + "WG_FUNCTIONS_SHOULD_USE_URL"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_UTF8 = + "WG_ENCODING_NOT_SUPPORTED_USING_UTF8"; + public static final String WG_ENCODING_NOT_SUPPORTED_USING_JAVA = + "WG_ENCODING_NOT_SUPPORTED_USING_JAVA"; + public static final String WG_SPECIFICITY_CONFLICTS = + "WG_SPECIFICITY_CONFLICTS"; + public static final String WG_PARSING_AND_PREPARING = + "WG_PARSING_AND_PREPARING"; + public static final String WG_ATTR_TEMPLATE = "WG_ATTR_TEMPLATE"; + public static final String WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESPACE = "WG_CONFLICT_BETWEEN_XSLSTRIPSPACE_AND_XSLPRESERVESP"; + public static final String WG_ATTRIB_NOT_HANDLED = "WG_ATTRIB_NOT_HANDLED"; + public static final String WG_NO_DECIMALFORMAT_DECLARATION = + "WG_NO_DECIMALFORMAT_DECLARATION"; + public static final String WG_OLD_XSLT_NS = "WG_OLD_XSLT_NS"; + public static final String WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED = + "WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED"; + public static final String WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE = + "WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE"; + public static final String WG_ILLEGAL_ATTRIBUTE = "WG_ILLEGAL_ATTRIBUTE"; + public static final String WG_COULD_NOT_RESOLVE_PREFIX = + "WG_COULD_NOT_RESOLVE_PREFIX"; + public static final String WG_STYLESHEET_REQUIRES_VERSION_ATTRIB = + "WG_STYLESHEET_REQUIRES_VERSION_ATTRIB"; + public static final String WG_ILLEGAL_ATTRIBUTE_NAME = + "WG_ILLEGAL_ATTRIBUTE_NAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_VALUE = + "WG_ILLEGAL_ATTRIBUTE_VALUE"; + public static final String WG_EMPTY_SECOND_ARG = "WG_EMPTY_SECOND_ARG"; + public static final String WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML = + "WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML"; + public static final String WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = + "WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME"; + public static final String WG_ILLEGAL_ATTRIBUTE_POSITION = + "WG_ILLEGAL_ATTRIBUTE_POSITION"; + public static final String NO_MODIFICATION_ALLOWED_ERR = + "NO_MODIFICATION_ALLOWED_ERR"; + + /* + * Now fill in the message text. + * Then fill in the message text for that message code in the + * array. Use the new error code as the index into the array. + */ + + // Error messages... + + /** + * Get the lookup table for error messages. + * + * @return The message lookup table. + */ + public Object[][] getContents() { + return new Object[][]{ + + /** Error message ID that has a null message, but takes in a single object. */ + {"ER0000", "{0}"}, + + {ER_NO_CURLYBRACE, + "\u932F\u8AA4: \u8868\u793A\u5F0F\u4E2D\u4E0D\u53EF\u6709 '{'"}, + + {ER_ILLEGAL_ATTRIBUTE, + "{0} \u5177\u6709\u7121\u6548\u5C6C\u6027: {1}"}, + + {ER_NULL_SOURCENODE_APPLYIMPORTS, + "sourceNode \u5728 xsl:apply-imports \u4E2D\u662F\u7A7A\u503C\uFF01"}, + + {ER_CANNOT_ADD, + "\u7121\u6CD5\u65B0\u589E {0} \u81F3 {1}"}, + + {ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES, + "sourceNode \u5728 handleApplyTemplatesInstruction \u4E2D\u662F\u7A7A\u503C\uFF01"}, + + {ER_NO_NAME_ATTRIB, + "{0} \u5FC5\u9808\u6709\u540D\u7A31\u5C6C\u6027\u3002"}, + + {ER_TEMPLATE_NOT_FOUND, + "\u627E\u4E0D\u5230\u4E0B\u5217\u540D\u7A31\u7684\u6A23\u677F: {0}"}, + + {ER_CANT_RESOLVE_NAME_AVT, + "\u7121\u6CD5\u89E3\u6790 xsl:call-template \u4E2D\u7684\u540D\u7A31 AVT\u3002"}, + + {ER_REQUIRES_ATTRIB, + "{0} \u9700\u8981\u5C6C\u6027: {1}"}, + + {ER_MUST_HAVE_TEST_ATTRIB, + "{0} \u5FC5\u9808\u6709 ''test'' \u5C6C\u6027\u3002"}, + + {ER_BAD_VAL_ON_LEVEL_ATTRIB, + "\u932F\u8AA4\u7684\u503C\u4F4D\u65BC\u5C64\u6B21\u5C6C\u6027: {0}"}, + + {ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML, + "processing-instruction \u540D\u7A31\u4E0D\u53EF\u70BA 'xml'"}, + + {ER_PROCESSINGINSTRUCTION_NOTVALID_NCNAME, + "processing-instruction \u540D\u7A31\u5FC5\u9808\u662F\u6709\u6548\u7684 NCName: {0}"}, + + {ER_NEED_MATCH_ATTRIB, + "{0} \u82E5\u5177\u6709\u6A21\u5F0F\uFF0C\u5247\u5FC5\u9808\u6709\u914D\u5C0D\u5C6C\u6027\u3002"}, + + {ER_NEED_NAME_OR_MATCH_ATTRIB, + "{0} \u9700\u8981\u540D\u7A31\u6216\u914D\u5C0D\u5C6C\u6027\u3002"}, + + {ER_CANT_RESOLVE_NSPREFIX, + "\u7121\u6CD5\u89E3\u6790\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC: {0}"}, + + {ER_ILLEGAL_VALUE, + "xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + {ER_NO_OWNERDOC, + "\u5B50\u9805\u7BC0\u9EDE\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\uFF01"}, + + {ER_ELEMTEMPLATEELEM_ERR, + "ElemTemplateElement \u932F\u8AA4: {0}"}, + + {ER_NULL_CHILD, + "\u5617\u8A66\u65B0\u589E\u7A7A\u503C\u5B50\u9805\uFF01"}, + + {ER_NEED_SELECT_ATTRIB, + "{0} \u9700\u8981\u9078\u53D6\u5C6C\u6027\u3002"}, + + {ER_NEED_TEST_ATTRIB, + "xsl:when \u5FC5\u9808\u5177\u6709 'test' \u5C6C\u6027\u3002"}, + + {ER_NEED_NAME_ATTRIB, + "xsl:with-param \u5FC5\u9808\u5177\u6709 'name' \u5C6C\u6027\u3002"}, + + {ER_NO_CONTEXT_OWNERDOC, + "\u76F8\u95DC\u8CC7\u8A0A\u74B0\u5883\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\uFF01"}, + + {ER_COULD_NOT_CREATE_XML_PROC_LIAISON, + "\u7121\u6CD5\u5EFA\u7ACB XML TransformerFactory Liaison: {0}"}, + + {ER_PROCESS_NOT_SUCCESSFUL, + "Xalan: \u8655\u7406\u4F5C\u696D\u5931\u6557\u3002"}, + + {ER_NOT_SUCCESSFUL, + "Xalan: \u5931\u6557\uFF01"}, + + {ER_ENCODING_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4\u7DE8\u78BC: {0}"}, + + {ER_COULD_NOT_CREATE_TRACELISTENER, + "\u7121\u6CD5\u5EFA\u7ACB TraceListener: {0}"}, + + {ER_KEY_REQUIRES_NAME_ATTRIB, + "xsl:key \u9700\u8981 'name' \u5C6C\u6027\uFF01"}, + + {ER_KEY_REQUIRES_MATCH_ATTRIB, + "xsl:key \u9700\u8981 'match' \u5C6C\u6027\uFF01"}, + + {ER_KEY_REQUIRES_USE_ATTRIB, + "xsl:key \u9700\u8981 'use' \u5C6C\u6027\uFF01"}, + + {ER_REQUIRES_ELEMENTS_ATTRIB, + "(StylesheetHandler) {0} \u9700\u8981 ''elements'' \u5C6C\u6027\uFF01"}, + + {ER_MISSING_PREFIX_ATTRIB, + "(StylesheetHandler) \u907A\u6F0F {0} \u5C6C\u6027 ''prefix''"}, + + {ER_BAD_STYLESHEET_URL, + "\u6A23\u5F0F\u8868 URL \u932F\u8AA4: {0}"}, + + {ER_FILE_NOT_FOUND, + "\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\u6A94\u6848: {0}"}, + + {ER_IOEXCEPTION, + "\u6A23\u5F0F\u8868\u6A94\u6848\u767C\u751F IO \u7570\u5E38\u72C0\u6CC1: {0}"}, + + {ER_NO_HREF_ATTRIB, + "(StylesheetHandler) \u627E\u4E0D\u5230 {0} \u7684 href \u5C6C\u6027"}, + + {ER_STYLESHEET_INCLUDES_ITSELF, + "(StylesheetHandler) {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u5305\u542B\u672C\u8EAB\uFF01"}, + + {ER_PROCESSINCLUDE_ERROR, + "StylesheetHandler.processInclude \u932F\u8AA4\uFF0C{0}"}, + + {ER_MISSING_LANG_ATTRIB, + "(StylesheetHandler) \u907A\u6F0F {0} \u5C6C\u6027 ''lang''"}, + + {ER_MISSING_CONTAINER_ELEMENT_COMPONENT, + "(StylesheetHandler) {0} \u5143\u7D20\u7684\u4F4D\u7F6E\u932F\u8AA4\uFF1F\u907A\u6F0F\u5BB9\u5668\u5143\u7D20 ''component''"}, + + {ER_CAN_ONLY_OUTPUT_TO_ELEMENT, + "\u53EA\u80FD\u8F38\u51FA\u81F3 Element\u3001DocumentFragment\u3001Document \u6216 PrintWriter\u3002"}, + + {ER_PROCESS_ERROR, + "StylesheetRoot.process \u932F\u8AA4"}, + + {ER_UNIMPLNODE_ERROR, + "UnImplNode \u932F\u8AA4: {0}"}, + + {ER_NO_SELECT_EXPRESSION, + "\u932F\u8AA4\uFF01\u627E\u4E0D\u5230 xpath \u9078\u53D6\u8868\u793A\u5F0F (-select)\u3002"}, + + {ER_CANNOT_SERIALIZE_XSLPROCESSOR, + "\u7121\u6CD5\u5E8F\u5217\u5316 XSLProcessor\uFF01"}, + + {ER_NO_INPUT_STYLESHEET, + "\u672A\u6307\u5B9A\u6A23\u5F0F\u8868\u8F38\u5165\uFF01"}, + + {ER_FAILED_PROCESS_STYLESHEET, + "\u7121\u6CD5\u8655\u7406\u6A23\u5F0F\u8868\uFF01"}, + + {ER_COULDNT_PARSE_DOC, + "\u7121\u6CD5\u5256\u6790 {0} \u6587\u4EF6\uFF01"}, + + {ER_COULDNT_FIND_FRAGMENT, + "\u627E\u4E0D\u5230\u7247\u6BB5: {0}"}, + + {ER_NODE_NOT_ELEMENT, + "\u7247\u6BB5 ID \u6307\u5411\u7684\u7BC0\u9EDE\u4E0D\u662F\u5143\u7D20: {0}"}, + + {ER_FOREACH_NEED_MATCH_OR_NAME_ATTRIB, + "for-each \u5FC5\u9808\u6709\u914D\u5C0D\u6216\u540D\u7A31\u5C6C\u6027"}, + + {ER_TEMPLATES_NEED_MATCH_OR_NAME_ATTRIB, + "\u6A23\u677F\u5FC5\u9808\u6709\u914D\u5C0D\u6216\u540D\u7A31\u5C6C\u6027"}, + + {ER_NO_CLONE_OF_DOCUMENT_FRAG, + "\u6C92\u6709\u6587\u4EF6\u7247\u6BB5\u7684\u8907\u88FD\uFF01"}, + + {ER_CANT_CREATE_ITEM, + "\u7121\u6CD5\u5728\u7D50\u679C\u6A39\u72C0\u7D50\u69CB\u4E2D\u5EFA\u7ACB\u9805\u76EE: {0}"}, + + {ER_XMLSPACE_ILLEGAL_VALUE, + "\u4F86\u6E90 XML \u4E2D\u7684 xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + {ER_NO_XSLKEY_DECLARATION, + "{0} \u6C92\u6709 xsl:key \u5BA3\u544A\uFF01"}, + + {ER_CANT_CREATE_URL, + "\u932F\u8AA4\uFF01\u7121\u6CD5\u70BA {0} \u5EFA\u7ACB url"}, + + {ER_XSLFUNCTIONS_UNSUPPORTED, + "\u4E0D\u652F\u63F4 xsl:functions"}, + + {ER_PROCESSOR_ERROR, + "XSLT TransformerFactory \u932F\u8AA4"}, + + {ER_NOT_ALLOWED_INSIDE_STYLESHEET, + "(StylesheetHandler) \u6A23\u5F0F\u8868\u5167\u4E0D\u5141\u8A31 {0}\uFF01"}, + + {ER_RESULTNS_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 result-ns\uFF01\u8ACB\u6539\u7528 xsl:output\u3002"}, + + {ER_DEFAULTSPACE_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 default-space\uFF01\u8ACB\u6539\u7528 xsl:strip-space \u6216 xsl:preserve-space\u3002"}, + + {ER_INDENTRESULT_NOT_SUPPORTED, + "\u4E0D\u518D\u652F\u63F4 indent-result\uFF01\u8ACB\u6539\u7528 xsl:output\u3002"}, + + {ER_ILLEGAL_ATTRIB, + "(StylesheetHandler) {0} \u5177\u6709\u7121\u6548\u5C6C\u6027: {1}"}, + + {ER_UNKNOWN_XSL_ELEM, + "\u4E0D\u660E\u7684 XSL \u5143\u7D20: {0}"}, + + {ER_BAD_XSLSORT_USE, + "(StylesheetHandler) xsl:sort \u53EA\u80FD\u8207 xsl:apply-templates \u6216 xsl:for-each \u4E00\u8D77\u4F7F\u7528\u3002"}, + + {ER_MISPLACED_XSLWHEN, + "(StylesheetHandler) xsl:when \u4F4D\u7F6E\u932F\u8AA4\uFF01"}, + + {ER_XSLWHEN_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:when \u7684\u7236\u9805\u4E0D\u662F xsl:choose\uFF01"}, + + {ER_MISPLACED_XSLOTHERWISE, + "(StylesheetHandler) xsl:otherwise \u4F4D\u7F6E\u932F\u8AA4\uFF01"}, + + {ER_XSLOTHERWISE_NOT_PARENTED_BY_XSLCHOOSE, + "(StylesheetHandler) xsl:otherwise \u7684\u7236\u9805\u4E0D\u662F xsl:choose\uFF01"}, + + {ER_NOT_ALLOWED_INSIDE_TEMPLATE, + "(StylesheetHandler) \u6A23\u677F\u5167\u4E0D\u5141\u8A31 {0}\uFF01"}, + + {ER_UNKNOWN_EXT_NS_PREFIX, + "(StylesheetHandler) \u4E0D\u660E\u7684 {0} \u64F4\u5145\u5957\u4EF6\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC {1}"}, + + {ER_IMPORTS_AS_FIRST_ELEM, + "(StylesheetHandler) \u532F\u5165\u53EA\u80FD\u767C\u751F\u65BC\u6A23\u5F0F\u8868\u4E2D\u7684\u7B2C\u4E00\u500B\u5143\u7D20\uFF01"}, + + {ER_IMPORTING_ITSELF, + "(StylesheetHandler) {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u532F\u5165\u672C\u8EAB\uFF01"}, + + {ER_XMLSPACE_ILLEGAL_VAL, + "(StylesheetHandler) xml:space \u5177\u6709\u7121\u6548\u503C: {0}"}, + + {ER_PROCESSSTYLESHEET_NOT_SUCCESSFUL, + "processStylesheet \u5931\u6557\uFF01"}, + + {ER_SAX_EXCEPTION, + "SAX \u7570\u5E38\u72C0\u6CC1"}, + +// add this message to fix bug 21478 + {ER_FUNCTION_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4\u51FD\u6578\uFF01"}, + + {ER_XSLT_ERROR, + "XSLT \u932F\u8AA4"}, + + {ER_CURRENCY_SIGN_ILLEGAL, + "\u683C\u5F0F\u6A23\u5F0F\u5B57\u4E32\u4E2D\u4E0D\u5141\u8A31\u8CA8\u5E63\u7B26\u865F"}, + + {ER_DOCUMENT_FUNCTION_INVALID_IN_STYLESHEET_DOM, + "Stylesheet DOM \u4E2D\u4E0D\u652F\u63F4\u6587\u4EF6\u51FD\u6578\uFF01"}, + + {ER_CANT_RESOLVE_PREFIX_OF_NON_PREFIX_RESOLVER, + "\u7121\u6CD5\u89E3\u6790\u975E\u524D\u7F6E\u78BC\u89E3\u6790\u5668\u7684\u524D\u7F6E\u78BC\uFF01"}, + + {ER_REDIRECT_COULDNT_GET_FILENAME, + "\u91CD\u5C0E\u64F4\u5145\u5957\u4EF6: \u7121\u6CD5\u53D6\u5F97\u6A94\u6848\u540D\u7A31 - \u6A94\u6848\u6216\u9078\u53D6\u5C6C\u6027\u5FC5\u9808\u50B3\u56DE\u6709\u6548\u5B57\u4E32\u3002"}, + + {ER_CANNOT_BUILD_FORMATTERLISTENER_IN_REDIRECT, + "\u7121\u6CD5\u5728\u91CD\u5C0E\u64F4\u5145\u5957\u4EF6\u4E2D\u5EFA\u7ACB FormatterListener\uFF01"}, + + {ER_INVALID_PREFIX_IN_EXCLUDERESULTPREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F6E\u78BC\u7121\u6548: {0}"}, + + {ER_MISSING_NS_URI, + "\u907A\u6F0F\u6307\u5B9A\u524D\u7F6E\u78BC\u7684\u547D\u540D\u7A7A\u9593 URI"}, + + {ER_MISSING_ARG_FOR_OPTION, + "\u907A\u6F0F\u9078\u9805\u7684\u5F15\u6578: {0}"}, + + {ER_INVALID_OPTION, + "\u7121\u6548\u7684\u9078\u9805: {0}"}, + + {ER_MALFORMED_FORMAT_STRING, + "\u683C\u5F0F\u932F\u8AA4\u7684\u683C\u5F0F\u5B57\u4E32: {0}"}, + + {ER_STYLESHEET_REQUIRES_VERSION_ATTRIB, + "xsl:stylesheet \u9700\u8981 'version' \u5C6C\u6027\uFF01"}, + + {ER_ILLEGAL_ATTRIBUTE_VALUE, + "\u5C6C\u6027: {0} \u5177\u6709\u7121\u6548\u503C: {1}"}, + + {ER_CHOOSE_REQUIRES_WHEN, + "xsl:choose \u9700\u8981 xsl:when"}, + + {ER_NO_APPLY_IMPORT_IN_FOR_EACH, + "xsl:for-each \u4E2D\u4E0D\u5141\u8A31 xsl:apply-imports"}, + + {ER_CANT_USE_DTM_FOR_OUTPUT, + "DTMLiaison \u7121\u6CD5\u7528\u65BC\u8F38\u51FA DOM \u7BC0\u9EDE\u3002\u8ACB\u6539\u70BA\u50B3\u9001 com.sun.org.apache.xpath.internal.DOM2Helper\uFF01"}, + + {ER_CANT_USE_DTM_FOR_INPUT, + "DTMLiaison \u7121\u6CD5\u7528\u65BC\u8F38\u5165 DOM \u7BC0\u9EDE\u3002\u8ACB\u6539\u70BA\u50B3\u9001 com.sun.org.apache.xpath.internal.DOM2Helper\uFF01"}, + + {ER_CALL_TO_EXT_FAILED, + "\u547C\u53EB\u64F4\u5145\u5957\u4EF6\u5143\u7D20\u5931\u6557: {0}"}, + + {ER_PREFIX_MUST_RESOLVE, + "\u524D\u7F6E\u78BC\u5FC5\u9808\u89E3\u6790\u70BA\u547D\u540D\u7A7A\u9593: {0}"}, + + {ER_INVALID_UTF16_SURROGATE, + "\u5075\u6E2C\u5230\u7121\u6548\u7684 UTF-16 \u4EE3\u7406: {0}\uFF1F"}, + + {ER_XSLATTRSET_USED_ITSELF, + "xsl:attribute-set {0} \u4F7F\u7528\u672C\u8EAB\uFF0C\u5982\u6B64\u5C07\u9020\u6210\u7121\u9650\u8FF4\u5708\u3002"}, + + {ER_CANNOT_MIX_XERCESDOM, + "\u7121\u6CD5\u6DF7\u5408\u975E Xerces-DOM \u8F38\u5165\u8207 Xerces-DOM \u8F38\u51FA\uFF01"}, + + {ER_TOO_MANY_LISTENERS, + "addTraceListenersToStylesheet - TooManyListenersException"}, + + {ER_IN_ELEMTEMPLATEELEM_READOBJECT, + "\u5728 ElemTemplateElement.readObject \u4E2D: {0}"}, + + {ER_DUPLICATE_NAMED_TEMPLATE, + "\u627E\u5230\u8D85\u904E\u4E00\u500B\u4E0B\u5217\u540D\u7A31\u7684\u6A23\u677F: {0}"}, + + {ER_INVALID_KEY_CALL, + "\u7121\u6548\u7684\u51FD\u6578\u547C\u53EB: \u4E0D\u5141\u8A31\u905E\u8FF4 key() \u547C\u53EB"}, + + {ER_REFERENCING_ITSELF, + "\u8B8A\u6578 {0} \u76F4\u63A5\u6216\u9593\u63A5\u5730\u53C3\u7167\u672C\u8EAB\uFF01"}, + + {ER_ILLEGAL_DOMSOURCE_INPUT, + "newTemplates \u4E4B DOMSource \u7684\u8F38\u5165\u7BC0\u9EDE\u4E0D\u53EF\u70BA\u7A7A\u503C\uFF01"}, + + {ER_CLASS_NOT_FOUND_FOR_OPTION, + "\u627E\u4E0D\u5230\u9078\u9805 {0} \u7684\u985E\u5225\u6A94\u6848"}, + + {ER_REQUIRED_ELEM_NOT_FOUND, + "\u627E\u4E0D\u5230\u9700\u8981\u7684\u5143\u7D20: {0}"}, + + {ER_INPUT_CANNOT_BE_NULL, + "InputStream \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + {ER_URI_CANNOT_BE_NULL, + "URI \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + {ER_FILE_CANNOT_BE_NULL, + "File \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + {ER_SOURCE_CANNOT_BE_NULL, + "InputSource \u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + {ER_CANNOT_INIT_BSFMGR, + "\u7121\u6CD5\u8D77\u59CB BSF \u7BA1\u7406\u7A0B\u5F0F"}, + + {ER_CANNOT_CMPL_EXTENSN, + "\u7121\u6CD5\u7DE8\u8B6F\u64F4\u5145\u5957\u4EF6"}, + + {ER_CANNOT_CREATE_EXTENSN, + "\u7121\u6CD5\u5EFA\u7ACB\u64F4\u5145\u5957\u4EF6: {0}\uFF0C\u56E0\u70BA: {1}"}, + + {ER_INSTANCE_MTHD_CALL_REQUIRES, + "\u57F7\u884C\u8655\u7406\u65B9\u6CD5\u547C\u53EB\u65B9\u6CD5 {0} \u6642\uFF0C\u9700\u8981 Object \u57F7\u884C\u8655\u7406\u4F5C\u70BA\u7B2C\u4E00\u500B\u5F15\u6578"}, + + {ER_INVALID_ELEMENT_NAME, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u5143\u7D20\u540D\u7A31 {0}"}, + + {ER_ELEMENT_NAME_METHOD_STATIC, + "\u5143\u7D20\u540D\u7A31\u65B9\u6CD5\u5FC5\u9808\u662F\u975C\u614B {0}"}, + + {ER_EXTENSION_FUNC_UNKNOWN, + "\u64F4\u5145\u5957\u4EF6\u51FD\u6578 {0} : {1} \u4E0D\u660E"}, + + {ER_MORE_MATCH_CONSTRUCTOR, + "{0} \u7684\u5EFA\u69CB\u5B50\u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + {ER_MORE_MATCH_METHOD, + "\u65B9\u6CD5 {0} \u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + {ER_MORE_MATCH_ELEMENT, + "\u5143\u7D20\u65B9\u6CD5 {0} \u6709\u8D85\u904E\u4E00\u500B\u4EE5\u4E0A\u7684\u6700\u4F73\u914D\u5C0D"}, + + {ER_INVALID_CONTEXT_PASSED, + "\u50B3\u9001\u4E86\u7121\u6548\u7684\u76F8\u95DC\u8CC7\u8A0A\u74B0\u5883\u4F86\u8A55\u4F30 {0}"}, + + {ER_POOL_EXISTS, + "\u96C6\u5340\u5DF2\u7D93\u5B58\u5728"}, + + {ER_NO_DRIVER_NAME, + "\u672A\u6307\u5B9A\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31"}, + + {ER_NO_URL, + "\u672A\u6307\u5B9A URL"}, + + {ER_POOL_SIZE_LESSTHAN_ONE, + "\u96C6\u5340\u5927\u5C0F\u5C0F\u65BC\u4E00\uFF01"}, + + {ER_INVALID_DRIVER, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + {ER_NO_STYLESHEETROOT, + "\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\u6839\uFF01"}, + + {ER_ILLEGAL_XMLSPACE_VALUE, + "xml:space \u7684\u503C\u7121\u6548"}, + + {ER_PROCESSFROMNODE_FAILED, + "processFromNode \u5931\u6557"}, + + {ER_RESOURCE_COULD_NOT_LOAD, + "\u7121\u6CD5\u8F09\u5165\u8CC7\u6E90 [ {0} ]: {1} \n {2} \t {3}"}, + + {ER_BUFFER_SIZE_LESSTHAN_ZERO, + "\u7DE9\u885D\u5340\u5927\u5C0F <=0"}, + + {ER_UNKNOWN_ERROR_CALLING_EXTENSION, + "\u547C\u53EB\u64F4\u5145\u5957\u4EF6\u6642\uFF0C\u767C\u751F\u4E0D\u660E\u7684\u932F\u8AA4"}, + + {ER_NO_NAMESPACE_DECL, + "\u524D\u7F6E\u78BC {0} \u6C92\u6709\u5C0D\u61C9\u7684\u547D\u540D\u7A7A\u9593\u5BA3\u544A"}, + + {ER_ELEM_CONTENT_NOT_ALLOWED, + "\u5143\u7D20\u5167\u5BB9\u4E0D\u5141\u8A31 lang=javaclass {0}"}, + + {ER_STYLESHEET_DIRECTED_TERMINATION, + "\u6A23\u5F0F\u8868\u5C0E\u5411\u7684\u7D42\u6B62"}, + + {ER_ONE_OR_TWO, + "1 \u6216 2"}, + + {ER_TWO_OR_THREE, + "2 \u6216 3"}, + + {ER_COULD_NOT_LOAD_RESOURCE, + "\u7121\u6CD5\u8F09\u5165 {0} (\u6AA2\u67E5 CLASSPATH)\uFF0C\u76EE\u524D\u53EA\u4F7F\u7528\u9810\u8A2D\u503C"}, + + {ER_CANNOT_INIT_DEFAULT_TEMPLATES, + "\u7121\u6CD5\u8D77\u59CB\u9810\u8A2D\u6A23\u677F"}, + + {ER_RESULT_NULL, + "\u7D50\u679C\u4E0D\u61C9\u70BA\u7A7A\u503C"}, + + {ER_RESULT_COULD_NOT_BE_SET, + "\u7121\u6CD5\u8A2D\u5B9A\u7D50\u679C"}, + + {ER_NO_OUTPUT_SPECIFIED, + "\u672A\u6307\u5B9A\u8F38\u51FA"}, + + {ER_CANNOT_TRANSFORM_TO_RESULT_TYPE, + "\u7121\u6CD5\u8F49\u63DB\u70BA\u985E\u578B {0} \u7684\u7D50\u679C"}, + + {ER_CANNOT_TRANSFORM_SOURCE_TYPE, + "\u7121\u6CD5\u8F49\u63DB\u985E\u578B {0} \u7684\u4F86\u6E90"}, + + {ER_NULL_CONTENT_HANDLER, + "\u7A7A\u503C\u5167\u5BB9\u8655\u7406\u7A0B\u5F0F"}, + + {ER_NULL_ERROR_HANDLER, + "\u7A7A\u503C\u932F\u8AA4\u8655\u7406\u7A0B\u5F0F"}, + + {ER_CANNOT_CALL_PARSE, + "\u82E5\u672A\u8A2D\u5B9A ContentHandler\uFF0C\u5247\u7121\u6CD5\u547C\u53EB\u5256\u6790"}, + + {ER_NO_PARENT_FOR_FILTER, + "\u7BE9\u9078\u6C92\u6709\u7236\u9805"}, + + {ER_NO_STYLESHEET_IN_MEDIA, + "\u5728 {0} \u4E2D\u627E\u4E0D\u5230\u6A23\u5F0F\u8868\uFF0C\u5A92\u9AD4 = {1}"}, + + {ER_NO_STYLESHEET_PI, + "\u5728 {0} \u4E2D\u627E\u4E0D\u5230 xml-stylesheet PI"}, + + {ER_NOT_SUPPORTED, + "\u4E0D\u652F\u63F4: {0}"}, + + {ER_PROPERTY_VALUE_BOOLEAN, + "\u5C6C\u6027 {0} \u7684\u503C\u61C9\u70BA\u5E03\u6797\u57F7\u884C\u8655\u7406"}, + + {ER_COULD_NOT_FIND_EXTERN_SCRIPT, + "\u7121\u6CD5\u5728 {0} \u53D6\u5F97\u5916\u90E8\u547D\u4EE4\u6A94"}, + + {ER_RESOURCE_COULD_NOT_FIND, + "\u627E\u4E0D\u5230\u8CC7\u6E90 [ {0} ]\u3002\n{1}"}, + + {ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, + "\u7121\u6CD5\u8FA8\u8B58\u7684\u8F38\u51FA\u5C6C\u6027: {0}"}, + + {ER_FAILED_CREATING_ELEMLITRSLT, + "\u7121\u6CD5\u5EFA\u7ACB ElemLiteralResult \u57F7\u884C\u8655\u7406"}, + + //Earlier (JDK 1.4 XALAN 2.2-D11) at key code '204' the key name was ER_PRIORITY_NOT_PARSABLE + // In latest Xalan code base key name is ER_VALUE_SHOULD_BE_NUMBER. This should also be taken care + //in locale specific files like XSLTErrorResources_de.java, XSLTErrorResources_fr.java etc. + //NOTE: Not only the key name but message has also been changed. + {ER_VALUE_SHOULD_BE_NUMBER, + "{0} \u7684\u503C\u61C9\u5305\u542B\u53EF\u5256\u6790\u7684\u6578\u5B57"}, + + {ER_VALUE_SHOULD_EQUAL, + "{0} \u7684\u503C\u61C9\u7B49\u65BC yes \u6216 no"}, + + {ER_FAILED_CALLING_METHOD, + "\u7121\u6CD5\u547C\u53EB {0} \u65B9\u6CD5"}, + + {ER_FAILED_CREATING_ELEMTMPL, + "\u7121\u6CD5\u5EFA\u7ACB ElemTemplateElement \u57F7\u884C\u8655\u7406"}, + + {ER_CHARS_NOT_ALLOWED, + "\u6587\u4EF6\u6B64\u8655\u4E0D\u5141\u8A31\u5B57\u5143"}, + + {ER_ATTR_NOT_ALLOWED, + "{1} \u5143\u7D20\u4E0D\u5141\u8A31 \"{0}\" \u5C6C\u6027\uFF01"}, + + {ER_BAD_VALUE, + "{0} \u7121\u6548\u503C {1} "}, + + {ER_ATTRIB_VALUE_NOT_FOUND, + "\u627E\u4E0D\u5230 {0} \u5C6C\u6027\u503C"}, + + {ER_ATTRIB_VALUE_NOT_RECOGNIZED, + "{0} \u5C6C\u6027\u503C\u7121\u6CD5\u8FA8\u8B58 "}, + + {ER_NULL_URI_NAMESPACE, + "\u5617\u8A66\u4EE5\u7A7A\u503C URI \u7522\u751F\u547D\u540D\u7A7A\u9593\u524D\u7F6E\u78BC"}, + + {ER_NUMBER_TOO_BIG, + "\u5617\u8A66\u683C\u5F0F\u5316\u5927\u65BC\u6700\u5927\u9577\u6574\u6578\u7684\u6578\u5B57"}, + + {ER_CANNOT_FIND_SAX1_DRIVER, + "\u627E\u4E0D\u5230 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}"}, + + {ER_SAX1_DRIVER_NOT_LOADED, + "\u627E\u5230 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}\uFF0C\u4F46\u7121\u6CD5\u8F09\u5165"}, + + {ER_SAX1_DRIVER_NOT_INSTANTIATED, + "\u5DF2\u8F09\u5165 SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0}\uFF0C\u4F46\u7121\u6CD5\u5EFA\u7ACB"}, + + {ER_SAX1_DRIVER_NOT_IMPLEMENT_PARSER, + "SAX1 \u9A45\u52D5\u7A0B\u5F0F\u985E\u5225 {0} \u672A\u5BE6\u884C org.xml.sax.Parser"}, + + {ER_PARSER_PROPERTY_NOT_SPECIFIED, + "\u672A\u6307\u5B9A\u7CFB\u7D71\u5C6C\u6027 org.xml.sax.parser"}, + + {ER_PARSER_ARG_CANNOT_BE_NULL, + "\u5256\u6790\u5668\u5F15\u6578\u4E0D\u53EF\u70BA\u7A7A\u503C"}, + + {ER_FEATURE, + "\u529F\u80FD: {0}"}, + + {ER_PROPERTY, + "\u5C6C\u6027: {0}"}, + + {ER_NULL_ENTITY_RESOLVER, + "\u7A7A\u503C\u5BE6\u9AD4\u89E3\u6790\u5668"}, + + {ER_NULL_DTD_HANDLER, + "\u7A7A\u503C DTD \u8655\u7406\u7A0B\u5F0F"}, + + {ER_NO_DRIVER_NAME_SPECIFIED, + "\u672A\u6307\u5B9A\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + {ER_NO_URL_SPECIFIED, + "\u672A\u6307\u5B9A URL\uFF01"}, + + {ER_POOLSIZE_LESS_THAN_ONE, + "\u96C6\u5340\u5927\u5C0F\u5C0F\u65BC 1\uFF01"}, + + {ER_INVALID_DRIVER_NAME, + "\u6307\u5B9A\u4E86\u7121\u6548\u7684\u9A45\u52D5\u7A0B\u5F0F\u540D\u7A31\uFF01"}, + + {ER_ERRORLISTENER, + "ErrorListener"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The name +// 'ElemTemplateElement' is the name of a class, and should not be +// translated. + {ER_ASSERT_NO_TEMPLATE_PARENT, + "\u7A0B\u5F0F\u8A2D\u8A08\u4EBA\u54E1\u7684\u932F\u8AA4\uFF01\u8868\u793A\u5F0F\u6C92\u6709 ElemTemplateElement \u7236\u9805\uFF01"}, + + +// Note to translators: The following message should not normally be displayed +// to users. It describes a situation in which the processor has detected +// an internal consistency problem in itself, and it provides this message +// for the developer to help diagnose the problem. The substitution text +// provides further information in order to diagnose the problem. The name +// 'RedundentExprEliminator' is the name of a class, and should not be +// translated. + {ER_ASSERT_REDUNDENT_EXPR_ELIMINATOR, + "\u7A0B\u5F0F\u8A2D\u8A08\u4EBA\u54E1\u5728 RedundentExprEliminator \u4E2D\u7684\u5BA3\u544A: {0}"}, + + {ER_NOT_ALLOWED_IN_POSITION, + "\u6A23\u5F0F\u8868\u6B64\u4F4D\u7F6E\u4E0D\u5141\u8A31 {0}\uFF01"}, + + {ER_NONWHITESPACE_NOT_ALLOWED_IN_POSITION, + "\u6A23\u5F0F\u8868\u6B64\u4F4D\u7F6E\u4E0D\u5141\u8A31\u975E\u7A7A\u683C\u6587\u5B57\uFF01"}, + + // This code is shared with warning codes. + // SystemId Unknown + {INVALID_TCHAR, + "\u7121\u6548\u503C: {1} \u7528\u65BC CHAR \u5C6C\u6027: {0}\u3002\u985E\u578B CHAR \u7684\u5C6C\u6027\u5FC5\u9808\u50C5\u70BA 1 \u500B\u5B57\u5143\uFF01"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "QNAME" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value and {0} is the attribute name. + //The following codes are shared with the warning codes... + {INVALID_QNAME, + "\u7121\u6548\u503C: {1} \u7528\u65BC QNAME \u5C6C\u6027: {0}"}, + + // Note to translators: The following message is used if the value of + // an attribute in a stylesheet is invalid. "ENUM" is the XML data-type of + // the attribute, and should not be translated. The substitution text {1} is + // the attribute value, {0} is the attribute name, and {2} is a list of valid + // values. + {INVALID_ENUM, + "\u7121\u6548\u503C: {1} \u7528\u65BC ENUM \u5C6C\u6027: {0}\u3002\u6709\u6548\u503C\u70BA: {2}\u3002"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NMTOKEN" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NMTOKEN, + "\u7121\u6548\u503C: {1} \u7528\u65BC NMTOKEN \u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "NCNAME" is the XML data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NCNAME, + "\u7121\u6548\u503C: {1} \u7528\u65BC NCNAME \u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "boolean" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_BOOLEAN, + "\u7121\u6548\u503C: {1} \u7528\u65BC\u5E03\u6797\u5C6C\u6027: {0}"}, + +// Note to translators: The following message is used if the value of +// an attribute in a stylesheet is invalid. "number" is the XSLT data-type +// of the attribute, and should not be translated. The substitution text {1} is +// the attribute value and {0} is the attribute name. + {INVALID_NUMBER, + "\u7121\u6548\u503C: {1} \u7528\u65BC\u6578\u5B57\u5C6C\u6027: {0}"}, + + + // End of shared codes... + +// Note to translators: A "match pattern" is a special form of XPath expression +// that is used for matching patterns. The substitution text is the name of +// a function. The message indicates that when this function is referenced in +// a match pattern, its argument must be a string literal (or constant.) +// ER_ARG_LITERAL - new error message for bugzilla //5202 + {ER_ARG_LITERAL, + "\u914D\u5C0D\u6A23\u5F0F\u4E2D {0} \u7684\u5F15\u6578\u5FC5\u9808\u662F\u6587\u5B57\u3002"}, + +// Note to translators: The following message indicates that two definitions of +// a variable. A "global variable" is a variable that is accessible everywher +// in the stylesheet. +// ER_DUPLICATE_GLOBAL_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_GLOBAL_VAR, + "\u91CD\u8907\u7684\u5168\u57DF\u8B8A\u6578\u5BA3\u544A\u3002"}, + + +// Note to translators: The following message indicates that two definitions of +// a variable were encountered. +// ER_DUPLICATE_VAR - new error message for bugzilla #790 + {ER_DUPLICATE_VAR, + "\u91CD\u8907\u7684\u8B8A\u6578\u5BA3\u544A\u3002"}, + + // Note to translators: "xsl:template, "name" and "match" are XSLT keywords + // which must not be translated. + // ER_TEMPLATE_NAME_MATCH - new error message for bugzilla #789 + {ER_TEMPLATE_NAME_MATCH, + "xsl:template \u5FC5\u9808\u6709\u540D\u7A31\u6216\u914D\u5C0D\u5C6C\u6027 (\u6216\u5177\u6709\u5169\u8005)"}, + + // Note to translators: "exclude-result-prefixes" is an XSLT keyword which + // should not be translated. The message indicates that a namespace prefix + // encountered as part of the value of the exclude-result-prefixes attribute + // was in error. + // ER_INVALID_PREFIX - new error message for bugzilla #788 + {ER_INVALID_PREFIX, + "exclude-result-prefixes \u4E2D\u7684\u524D\u7F6E\u78BC\u7121\u6548: {0}"}, + + // Note to translators: An "attribute set" is a set of attributes that can + // be added to an element in the output document as a group. The message + // indicates that there was a reference to an attribute set named {0} that + // was never defined. + // ER_NO_ATTRIB_SET - new error message for bugzilla #782 + {ER_NO_ATTRIB_SET, + "\u4E0D\u5B58\u5728\u540D\u7A31\u70BA {0} \u7684 attribute-set"}, + + // Note to translators: This message indicates that there was a reference + // to a function named {0} for which no function definition could be found. + {ER_FUNCTION_NOT_FOUND, + "\u4E0D\u5B58\u5728\u540D\u7A31\u70BA {0} \u7684\u51FD\u6578"}, + + // Note to translators: This message indicates that the XSLT instruction + // that is named by the substitution text {0} must not contain other XSLT + // instructions (content) or a "select" attribute. The word "select" is + // an XSLT keyword in this case and must not be translated. + {ER_CANT_HAVE_CONTENT_AND_SELECT, + "{0} \u5143\u7D20\u4E0D\u53EF\u540C\u6642\u5177\u6709\u5167\u5BB9\u8207\u9078\u53D6\u5C6C\u6027\u3002"}, + + // Note to translators: This message indicates that the value argument + // of setParameter must be a valid Java Object. + {ER_INVALID_SET_PARAM_VALUE, + "\u53C3\u6578 {0} \u7684\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684 Java \u7269\u4EF6"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C6C\u6027\u5177\u6709\u503C '#default'\uFF0C\u4F46\u662F\u5143\u7D20\u7BC4\u570D\u4E2D\u6C92\u6709\u9810\u8A2D\u547D\u540D\u7A7A\u9593\u7684\u5BA3\u544A"}, + + {ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX, + "xsl:namespace-alias \u5143\u7D20\u7684 result-prefix \u5C6C\u6027\u5177\u6709\u503C ''{0}''\uFF0C\u4F46\u662F\u5143\u7D20\u7BC4\u570D\u4E2D\u6C92\u6709\u524D\u7F6E\u78BC ''{0}'' \u7684\u547D\u540D\u7A7A\u9593\u5BA3\u544A\u3002"}, + + {ER_SET_FEATURE_NULL_NAME, + "TransformerFactory.setFeature(\u5B57\u4E32\u540D\u7A31, \u5E03\u6797\u503C) \u4E2D\u7684\u529F\u80FD\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + {ER_GET_FEATURE_NULL_NAME, + "TransformerFactory.getFeature(\u5B57\u4E32\u540D\u7A31) \u4E2D\u7684\u529F\u80FD\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + {ER_UNSUPPORTED_FEATURE, + "\u7121\u6CD5\u5728\u6B64 TransformerFactory \u4E0A\u8A2D\u5B9A\u529F\u80FD ''{0}''\u3002"}, + + {ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, + "\u7576\u5B89\u5168\u8655\u7406\u529F\u80FD\u8A2D\u70BA\u771F\u6642\uFF0C\u4E0D\u5141\u8A31\u4F7F\u7528\u64F4\u5145\u5957\u4EF6\u5143\u7D20 ''{0}''\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, + "\u7121\u6CD5\u53D6\u5F97\u7A7A\u503C\u547D\u540D\u7A7A\u9593 uri \u7684\u524D\u7F6E\u78BC\u3002"}, + + {ER_NAMESPACE_CONTEXT_NULL_PREFIX, + "\u7121\u6CD5\u53D6\u5F97\u7A7A\u503C\u524D\u7F6E\u78BC\u7684\u547D\u540D\u7A7A\u9593 uri\u3002"}, + + {ER_XPATH_RESOLVER_NULL_QNAME, + "\u51FD\u6578\u540D\u7A31\u4E0D\u53EF\u70BA\u7A7A\u503C\u3002"}, + + {ER_XPATH_RESOLVER_NEGATIVE_ARITY, + "Arity \u4E0D\u53EF\u70BA\u8CA0\u503C\u3002"}, + // Warnings... + + {WG_FOUND_CURLYBRACE, + "\u627E\u5230 '}'\uFF0C\u4F46\u6C92\u6709\u958B\u555F\u7684\u5C6C\u6027\u6A23\u677F\uFF01"}, + + {WG_COUNT_ATTRIB_MATCHES_NO_ANCESTOR, + "\u8B66\u544A: \u8A08\u6578\u5C6C\u6027\u4E0D\u7B26\u5408 xsl:number \u4E2D\u7684\u7956\u7CFB\uFF01\u76EE\u6A19 = {0}"}, + + {WG_EXPR_ATTRIB_CHANGED_TO_SELECT, + "\u820A\u8A9E\u6CD5: 'expr' \u5C6C\u6027\u7684\u540D\u7A31\u5DF2\u8B8A\u66F4\u70BA 'select'\u3002"}, + + {WG_NO_LOCALE_IN_FORMATNUMBER, + "Xalan \u5C1A\u672A\u8655\u7406 format-number \u51FD\u6578\u4E2D\u7684\u5730\u5340\u8A2D\u5B9A\u540D\u7A31\u3002"}, + + {WG_LOCALE_NOT_FOUND, + "\u8B66\u544A: \u627E\u4E0D\u5230 xml:lang={0} \u7684\u5730\u5340\u8A2D\u5B9A"}, + + {WG_CANNOT_MAKE_URL_FROM, + "\u7121\u6CD5\u5F9E {0} \u5EFA\u7ACB URL"}, + + {WG_CANNOT_LOAD_REQUESTED_DOC, + "\u7121\u6CD5\u8F09\u5165\u8981\u6C42\u7684\u6587\u4EF6: {0}"}, + + {WG_CANNOT_FIND_COLLATOR, + "\u627E\u4E0D\u5230 >>>>>> Xalan \u7248\u672C "}, + {"version2", "<<<<<<<"}, + {"yes", "\u662F"}, + {"line", "\u884C\u865F"}, + {"column", "\u8CC7\u6599\u6B04\u7DE8\u865F"}, + {"xsldone", "XSLProcessor: \u5B8C\u6210"}, + + + // Note to translators: The following messages provide usage information + // for the Xalan Process command line. "Process" is the name of a Java class, + // and should not be translated. + {"xslProc_option", "Xalan-J \u547D\u4EE4\u884C\u8655\u7406\u4F5C\u696D\u985E\u5225\u9078\u9805:"}, + {"xslProc_option", "Xalan-J \u547D\u4EE4\u884C\u8655\u7406\u4F5C\u696D\u985E\u5225\u9078\u9805:"}, + {"xslProc_invalid_xsltc_option", "XSLTC \u6A21\u5F0F\u4E2D\u4E0D\u652F\u63F4\u9078\u9805 {0}\u3002"}, + {"xslProc_invalid_xalan_option", "\u9078\u9805 {0} \u53EA\u80FD\u8207 -XSLTC \u4E00\u8D77\u4F7F\u7528\u3002"}, + {"xslProc_no_input", "\u932F\u8AA4: \u672A\u6307\u5B9A\u6A23\u5F0F\u8868\u6216\u8F38\u5165 xml\u3002\u4E0D\u4F7F\u7528\u4EFB\u4F55\u9078\u9805\u4F86\u57F7\u884C\u6B64\u547D\u4EE4\uFF0C\u53EF\u53D6\u5F97\u7528\u6CD5\u6307\u793A\u3002"}, + {"xslProc_common_options", "-\u4E00\u822C\u9078\u9805-"}, + {"xslProc_xalan_options", "-Xalan \u7684\u9078\u9805-"}, + {"xslProc_xsltc_options", "-XSLTC \u7684\u9078\u9805-"}, + {"xslProc_return_to_continue", "(\u6309 \u4EE5\u7E7C\u7E8C)"}, + + // Note to translators: The option name and the parameter name do not need to + // be translated. Only translate the messages in parentheses. Note also that + // leading whitespace in the messages is used to indent the usage information + // for each option in the English messages. + // Do not translate the keywords: XSLTC, SAX, DOM and DTM. + {"optionXSLTC", " [-XSLTC (\u4F7F\u7528 XSLTC \u9032\u884C\u8F49\u63DB)]"}, + {"optionIN", " [-IN inputXMLURL]"}, + {"optionXSL", " [-XSL XSLTransformationURL]"}, + {"optionOUT", " [-OUT outputFileName]"}, + {"optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, + {"optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, + {"optionPARSER", " [-PARSER \u5256\u6790\u5668\u806F\u7D61\u7684\u5B8C\u6574\u985E\u5225\u540D\u7A31]"}, + {"optionE", " [-E (\u52FF\u5C55\u958B\u5BE6\u9AD4\u53C3\u7167)]"}, + {"optionV", " [-E (\u52FF\u5C55\u958B\u5BE6\u9AD4\u53C3\u7167)]"}, + {"optionQC", " [-QC (\u975C\u97F3\u6A23\u5F0F\u885D\u7A81\u8B66\u544A)]"}, + {"optionQ", " [-Q (\u975C\u97F3\u6A21\u5F0F)]"}, + {"optionLF", " [-LF (\u8F38\u51FA\u4E0A\u50C5\u4F7F\u7528\u63DB\u884C\u5B57\u5143 {\u9810\u8A2D\u70BA CR/LF})]"}, + {"optionCR", " [-CR (\u8F38\u51FA\u4E0A\u50C5\u4F7F\u7528\u6B78\u4F4D\u5B57\u5143 {\u9810\u8A2D\u70BA CR/LF})]"}, + {"optionESCAPE", " [-ESCAPE (\u8981\u9041\u96E2\u7684\u5B57\u5143 {\u9810\u8A2D\u70BA <>&\"'\\r\\n}]"}, + {"optionINDENT", " [-INDENT (\u63A7\u5236\u8981\u7E2E\u6392\u7684\u7A7A\u9593 {\u9810\u8A2D\u70BA 0})]"}, + {"optionTT", " [-TT (\u8FFD\u8E64\u547C\u53EB\u7684\u6A23\u677F\u3002)]"}, + {"optionTG", " [-TG (\u8FFD\u8E64\u6BCF\u500B\u7522\u751F\u4E8B\u4EF6\u3002)]"}, + {"optionTS", " [-TS (\u8FFD\u8E64\u6BCF\u500B\u9078\u53D6\u4E8B\u4EF6\u3002)]"}, + {"optionTTC", " [-TTC (\u8FFD\u8E64\u8655\u7406\u7684\u6A23\u677F\u5B50\u9805\u3002)]"}, + {"optionTCLASS", " [-TCLASS (\u8FFD\u8E64\u64F4\u5145\u5957\u4EF6\u7684 TraceListener \u985E\u5225\u3002)]"}, + {"optionVALIDATE", " [-VALIDATE (\u8A2D\u5B9A\u662F\u5426\u57F7\u884C\u9A57\u8B49\u3002\u9810\u8A2D\u4E0D\u6703\u57F7\u884C\u9A57\u8B49\u3002)]"}, + {"optionEDUMP", " [-EDUMP {\u9078\u64C7\u6027\u6A94\u6848\u540D\u7A31} (\u767C\u751F\u932F\u8AA4\u6642\u6703\u57F7\u884C\u5806\u758A\u50BE\u5370\u3002)]"}, + {"optionXML", " [-XML (\u4F7F\u7528 XML \u683C\u5F0F\u5668\u4E26\u65B0\u589E XML \u6A19\u982D\u3002)]"}, + {"optionTEXT", " [-TEXT (\u4F7F\u7528\u7C21\u55AE Text \u683C\u5F0F\u5668\u3002)]"}, + {"optionHTML", " [-HTML (\u4F7F\u7528 HTML \u683C\u5F0F\u5668\u3002)]"}, + {"optionPARAM", " [-PARAM \u540D\u7A31\u8868\u793A\u5F0F (\u8A2D\u5B9A\u6A23\u5F0F\u8868\u53C3\u6578)]"}, + {"noParsermsg1", "XSL \u8655\u7406\u4F5C\u696D\u5931\u6557\u3002"}, + {"noParsermsg2", "** \u627E\u4E0D\u5230\u5256\u6790\u5668 **"}, + {"noParsermsg3", "\u8ACB\u6AA2\u67E5\u985E\u5225\u8DEF\u5F91\u3002"}, + {"noParsermsg4", "\u82E5\u7121 IBM \u7684 XML Parser for Java\uFF0C\u53EF\u4E0B\u8F09\u81EA"}, + {"noParsermsg5", "IBM \u7684 AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, + {"optionURIRESOLVER", " [-URIRESOLVER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u89E3\u6790 URI \u7684 URIResolver)]"}, + {"optionENTITYRESOLVER", " [-ENTITYRESOLVER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u89E3\u6790\u5BE6\u9AD4\u7684 EntityResolver )]"}, + {"optionCONTENTHANDLER", " [-CONTENTHANDLER \u5B8C\u6574\u985E\u5225\u540D\u7A31 (\u7528\u4F86\u5E8F\u5217\u5316\u8F38\u51FA\u7684 ContentHandler)]"}, + {"optionLINENUMBERS", " [-L \u4F7F\u7528\u884C\u865F\u65BC\u4F86\u6E90\u6587\u4EF6]"}, + {"optionSECUREPROCESSING", " [-SECURE (\u5C07\u5B89\u5168\u8655\u7406\u529F\u80FD\u8A2D\u70BA\u771F\u3002)]"}, + + // Following are the new options added in XSLTErrorResources.properties files after Jdk 1.4 (Xalan 2.2-D11) + + + {"optionMEDIA", " [-MEDIA mediaType (\u4F7F\u7528\u5A92\u9AD4\u5C6C\u6027\u4F86\u5C0B\u627E\u8207\u6587\u4EF6\u95DC\u806F\u7684\u6A23\u5F0F\u8868\u3002)]"}, + {"optionFLAVOR", " [-FLAVOR flavorName (\u660E\u78BA\u4F7F\u7528 s2s=SAX \u6216 d2d=DOM \u4F86\u57F7\u884C\u8F49\u63DB\u3002)] "}, // Added by sboag/scurcuru; experimental + {"optionDIAG", " [-DIAG (\u5217\u5370\u8F49\u63DB\u6240\u9700\u8981\u7684\u5168\u90E8\u6BEB\u79D2\u3002)]"}, + {"optionINCREMENTAL", " [-INCREMENTAL (\u8A2D\u5B9A http://xml.apache.org/xalan/features/incremental \u70BA\u771F\uFF0C\u4EE5\u8981\u6C42\u6F38\u9032 DTM \u5EFA\u69CB\u3002)]"}, + {"optionNOOPTIMIMIZE", " [-NOOPTIMIMIZE (\u8A2D\u5B9A http://xml.apache.org/xalan/features/optimize \u70BA\u507D\uFF0C\u4EE5\u8981\u6C42\u7121\u6A23\u5F0F\u8868\u6700\u4F73\u5316\u8655\u7406\u3002)]"}, + {"optionRL", " [-RL recursionlimit (\u5BA3\u544A\u6A23\u5F0F\u8868\u905E\u8FF4\u6DF1\u5EA6\u7684\u6578\u5B57\u9650\u5236\u3002)]"}, + {"optionXO", " [-XO [transletName] (\u6307\u6D3E\u6240\u7522\u751F translet \u7684\u540D\u7A31)]"}, + {"optionXD", " [-XD destinationDirectory (\u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304)]"}, + {"optionXJ", " [-XJ jarfile (\u5C01\u88DD translet \u985E\u5225\u6210\u70BA\u540D\u7A31\u70BA \u7684 jar \u6A94\u6848)]"}, + {"optionXP", " [-XP \u5957\u88DD\u7A0B\u5F0F (\u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\u540D\u7A31\u524D\u7F6E\u78BC)]"}, + + //AddITIONAL STRINGS that need L10n + // Note to translators: The following message describes usage of a particular + // command-line option that is used to enable the "template inlining" + // optimization. The optimization involves making a copy of the code + // generated for a template in another template that refers to it. + {"optionXN", " [-XN (\u555F\u7528\u6A23\u677F\u5167\u5D4C)]"}, + {"optionXX", " [-XX (\u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA)]"}, + {"optionXT", " [-XT (\u82E5\u6709\u53EF\u80FD\uFF0C\u4F7F\u7528 translet \u4F86\u8F49\u63DB)]"}, + {"diagTiming", " --------- \u7D93\u7531 {1} \u7684 {0} \u8F49\u63DB\u6B77\u6642 {2} \u6BEB\u79D2"}, + {"recursionTooDeep", "\u6A23\u677F\u5DE2\u72C0\u7D50\u69CB\u904E\u6DF1\u3002\u5DE2\u72C0\u7D50\u69CB = {0}\uFF0C\u6A23\u677F {1} {2}"}, + {"nameIs", "\u540D\u7A31\u70BA"}, + {"matchPatternIs", "\u914D\u5C0D\u6A23\u5F0F\u70BA"} + + }; + + } + // ================= INFRASTRUCTURE ====================== + + /** + * String for use when a bad error code was encountered. + */ + public static final String BAD_CODE = "BAD_CODE"; + + /** + * String for use when formatting of the error string failed. + */ + public static final String FORMAT_FAILED = "FORMAT_FAILED"; + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties new file mode 100644 index 0000000..5ffdea1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/XSLTInfo.properties @@ -0,0 +1,29 @@ +########################################################################### +# reserved comment block +# DO NOT REMOVE OR ALTER! +########################################################################### +########################################################################### +# Copyright 2000-2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## +# +# $Id: XSLTInfo.properties,v 1.1.2.1 2005/08/01 02:10:48 jeffsuttor Exp $ +# +# XSLT Resource File +# +vendor=Apache Software Foundation +vendor-url=http://xml.apache.org/xalan-j +# Product Version: Xalan-Java @impl.version@ +# W3C XSL Transformations (XSLT) Version 1.0 +version=1.0 diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html new file mode 100644 index 0000000..4f879e0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/res/package.html @@ -0,0 +1,29 @@ + + + + +Xalan resource Package. + +

Contains strings that require internationalization. +

+ + + + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java new file mode 100644 index 0000000..980363d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/Constants.java @@ -0,0 +1,428 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.templates; + + +/** + * Primary constants used in the TransformerImpl classes. + * + * @xsl.usage advanced + */ +public class Constants extends com.sun.org.apache.xml.internal.utils.Constants { + + /** + * IDs for XSL element types. These are associated + * with the string literals in the TransformerImpl class. + * Don't change the numbers. NOTE THAT THESE ARE NOT IN + * ALPHABETICAL ORDER! + * (It's a pity Java doesn't have a real Enumerated Mnemonic + * datatype... or a C-like preprocessor in lieu thereof which + * could be used to generate and maintain synch between these lists.) + */ + public static final int ELEMNAME_UNDEFINED = -1, ELEMNAME_WITHPARAM = 2, + ELEMNAME_ADDATTRIBUTE = 4, ELEMNAME_ANCHOR = 22, + + // ELEMNAME_ANCHOR_PATTERN = 23, + ELEMNAME_APPLY_TEMPLATES = 50, ELEMNAME_USE = 34, ELEMNAME_CHILDREN = 6, + ELEMNAME_CHOOSE = 37, ELEMNAME_COMMENT = 59, // my own + ELEMNAME_CONSTRUCT = 7, // my own + ELEMNAME_CONTENTS = 8, ELEMNAME_COPY = 9, + ELEMNAME_COPY_OF = 74, + ELEMNAME_DECIMALFORMAT = 83, + ELEMNAME_DEFINEATTRIBUTESET = 40, + + // ELEMNAME_DEFINECONSTANT = 29, + // ELEMNAME_DEFINEMACRO = 10, + ELEMNAME_DEFINESCRIPT = 11, ELEMNAME_DISPLAYIF = 12, // my own + ELEMNAME_EMPTY = 14, ELEMNAME_EVAL = 15, + ELEMNAME_EXPECTEDCHILDREN = 16, + ELEMNAME_EXTENSION = 54, + ELEMNAME_EXTENSIONHANDLER = 63, + ELEMNAME_FOREACH = 28, ELEMNAME_KEY = 31, + ELEMNAME_IF = 36, ELEMNAME_IMPORT = 26, + ELEMNAME_INCLUDE = 27, + ELEMNAME_CALLTEMPLATE = 17, + ELEMNAME_PARAMVARIABLE = 41, + ELEMNAME_NUMBER = 35, ELEMNAME_NSALIAS = 84, + ELEMNAME_OTHERWISE = 39, ELEMNAME_PI = 58, + ELEMNAME_PRESERVESPACE = 33, + ELEMNAME_REMOVEATTRIBUTE = 5, + ELEMNAME_TEMPLATE = 19, ELEMNAME_SORT = 64, + ELEMNAME_STRIPSPACE = 32, + ELEMNAME_STYLESHEET = 25, ELEMNAME_TEXT = 42, + ELEMNAME_VALUEOF = 30, ELEMNAME_WHEN = 38, + + // Pattern by example support + ELEMNAME_ROOT = 44, ELEMNAME_ANY = 45, ELEMNAME_ELEMENT = 46, + ELEMNAME_TARGETELEMENT = 47, ELEMNAME_ATTRIBUTE = 48, + ELEMNAME_TARGETATTRIBUTE = 49, ELEMNAME_URL = 52, // my own + ELEMNAME_CALL = 55, // my own + + // ELEMNAME_WITHPARAM = 56, + ELEMNAME_FALLBACK = 57, // my own + ELEMNAME_TARGETPI = 60, // my own + ELEMNAME_TARGETCOMMENT = 61, // my own + ELEMNAME_TARGETTEXT = 62, // my own + ELEMNAME_CSSSTYLECONVERSION = 65, // my own + ELEMNAME_COUNTER = 66, ELEMNAME_COUNTERS = 67, + ELEMNAME_COUNTERINCREMENT = 68, ELEMNAME_COUNTERRESET = 69, + ELEMNAME_COUNTERSCOPE = 71, ELEMNAME_APPLY_IMPORTS = 72, + ELEMNAME_VARIABLE = 73, ELEMNAME_MESSAGE = 75, ELEMNAME_LOCALE = 76, + ELEMNAME_LITERALRESULT = 77, ELEMNAME_TEXTLITERALRESULT = 78, + ELEMNAME_EXTENSIONCALL = 79, ELEMNAME_EXTENSIONDECL = 85, + ELEMNAME_EXTENSIONSCRIPT = 86, ELEMNAME_OUTPUT = 80, + ELEMNAME_COMPONENT = 81, ELEMNAME_SCRIPT = 82; + + // Next free number: 90 (88 and 89 used for EXSLT elements); + + /** + * Literals for XSL element names. Note that there are more + * names than IDs, because some names map to the same ID. + */ + public static final String + ELEMNAME_ANCHOR_STRING = "anchor", + ELEMNAME_ANY_STRING = "any", // pattern-by-example support + ELEMNAME_APPLY_IMPORTS_STRING = "apply-imports", + ELEMNAME_APPLY_TEMPLATES_STRING = "apply-templates", + ELEMNAME_ARG_STRING = "arg", + ELEMNAME_ATTRIBUTESET_STRING = "attribute-set", + ELEMNAME_ATTRIBUTE_STRING = "attribute", // pattern-by-example support + ELEMNAME_CALLTEMPLATEARG_STRING = "invoke-arg", + ELEMNAME_CALLTEMPLATE_STRING = "call-template", + ELEMNAME_CALL_STRING = "call", + ELEMNAME_CHILDREN_STRING = "children", + ELEMNAME_CHOOSE_STRING = "choose", + ELEMNAME_COMMENT_STRING = "comment", + ELEMNAME_COMPONENT_STRING = "component", + ELEMNAME_CONSTRUCT_STRING = "construct", // my own + ELEMNAME_CONTENTS_STRING = "contents", + ELEMNAME_COPY_OF_STRING = "copy-of", + ELEMNAME_COPY_STRING = "copy", + ELEMNAME_COUNTERINCREMENT_STRING = "counter-increment", + ELEMNAME_COUNTERRESET_STRING = "counter-reset", + ELEMNAME_COUNTERSCOPE_STRING = "counter-scope", + ELEMNAME_COUNTERS_STRING = "counters", + ELEMNAME_COUNTER_STRING = "counter", + ELEMNAME_CSSSTYLECONVERSION_STRING = "css-style-conversion", + ELEMNAME_DECIMALFORMAT_STRING = "decimal-format", + ELEMNAME_DISPLAYIF_STRING = "display-if", // my own + ELEMNAME_ELEMENT_STRING = "element", // pattern-by-example support + ELEMNAME_EMPTY_STRING = "empty", + ELEMNAME_EVAL_STRING = "eval", + ELEMNAME_EXPECTEDCHILDREN_STRING = "expectedchildren", + ELEMNAME_EXTENSIONHANDLER_STRING = "code-dispatcher", + ELEMNAME_EXTENSION_STRING = "functions", + ELEMNAME_FALLBACK_STRING = "fallback", + ELEMNAME_FOREACH_STRING = "for-each", + ELEMNAME_IF_STRING = "if", + ELEMNAME_IMPORT_STRING = "import", + ELEMNAME_INCLUDE_STRING = "include", + ELEMNAME_KEY_STRING = "key", + ELEMNAME_LOCALE_STRING = "locale", + ELEMNAME_MESSAGE_STRING = "message", + ELEMNAME_NSALIAS_STRING = "namespace-alias", + ELEMNAME_NUMBER_STRING = "number", + ELEMNAME_OTHERWISE_STRING = "otherwise", + ELEMNAME_OUTPUT_STRING = "output", + ELEMNAME_PARAMVARIABLE_STRING = "param", + ELEMNAME_PI_OLD_STRING = "pi", + ELEMNAME_PI_STRING = "processing-instruction", + ELEMNAME_PRESERVESPACE_STRING = "preserve-space", + ELEMNAME_ROOT_STRING = "root", // pattern-by-example support + ELEMNAME_SCRIPT_STRING = "script", + ELEMNAME_SORT_STRING = "sort", + ELEMNAME_STRIPSPACE_STRING = "strip-space", + ELEMNAME_STYLESHEET_STRING = "stylesheet", + ELEMNAME_TARGETATTRIBUTE_STRING = "target-attribute", // pattern-by-example support + ELEMNAME_TARGETCOMMENT_STRING = "target-comment", + ELEMNAME_TARGETELEMENT_STRING = "target-element", // pattern-by-example support + ELEMNAME_TARGETPI_STRING = "target-pi", + ELEMNAME_TARGETTEXT_STRING = "target-text", + ELEMNAME_TEMPLATE_STRING = "template", + ELEMNAME_TEXT_STRING = "text", + ELEMNAME_TRANSFORM_STRING = "transform", + ELEMNAME_URL_STRING = "uri", // pattern-by-example support + ELEMNAME_USE_STRING = "use", + ELEMNAME_VALUEOF_STRING = "value-of", + ELEMNAME_VARIABLE_STRING = "variable", + ELEMNAME_WHEN_STRING = "when", + ELEMNAME_WITHPARAM_STRING = "with-param"; + + /** + * Literals for EXSLT function elements. + */ + public static final String + EXSLT_ELEMNAME_FUNCTION_STRING = "function", + EXSLT_ELEMNAME_FUNCRESULT_STRING = "result"; + public static final int + EXSLT_ELEMNAME_FUNCTION = 88, + EXSLT_ELEMNAME_FUNCRESULT = 89; + + + /** + * Literals for XSL attribute names. Note that there may be more + * names than IDs, because some names may map to the same ID. + */ + public static final String + ATTRNAME_AMOUNT = "amount", + ATTRNAME_ANCESTOR = "ancestor", + ATTRNAME_ARCHIVE = "archive", + ATTRNAME_ATTRIBUTE = "attribute", + ATTRNAME_ATTRIBUTE_SET = "attribute-set", + ATTRNAME_CASEORDER = "case-order", + ATTRNAME_CLASS = "class", + ATTRNAME_CLASSID = "classid", + ATTRNAME_CODEBASE = "codebase", + ATTRNAME_CODETYPE = "type", + ATTRNAME_CONDITION = "condition", + ATTRNAME_COPYTYPE = "copy-type", + ATTRNAME_COUNT = "count", + ATTRNAME_DATATYPE = "data-type", + ATTRNAME_DECIMALSEPARATOR = "decimal-separator", + ATTRNAME_DEFAULT = "default", + ATTRNAME_DEFAULTSPACE = "default-space", + ATTRNAME_DEPTH = "with-children", + ATTRNAME_DIGIT = "digit", + ATTRNAME_DIGITGROUPSEP = "digit-group-sep", + ATTRNAME_DISABLE_OUTPUT_ESCAPING = "disable-output-escaping", + ATTRNAME_ELEMENT = "element", + ATTRNAME_ELEMENTS = "elements", + ATTRNAME_EXCLUDE_RESULT_PREFIXES = "exclude-result-prefixes", + ATTRNAME_EXPR = "expr", + ATTRNAME_EXTENSIONELEMENTPREFIXES = "extension-element-prefixes", + ATTRNAME_FORMAT = "format", + ATTRNAME_FROM = "from", + ATTRNAME_GROUPINGSEPARATOR = "grouping-separator", + ATTRNAME_GROUPINGSIZE = "grouping-size", + ATTRNAME_HREF = "href", + ATTRNAME_ID = "id", + ATTRNAME_IMPORTANCE = "importance", + ATTRNAME_INDENTRESULT = "indent-result", + ATTRNAME_INFINITY = "infinity", + ATTRNAME_LANG = "lang", + ATTRNAME_LETTERVALUE = "letter-value", + ATTRNAME_LEVEL = "level", + ATTRNAME_MATCH = "match", + ATTRNAME_METHOD = "calls", + ATTRNAME_MINUSSIGN = "minus-sign", + ATTRNAME_MODE = "mode", + ATTRNAME_NAME = "name", + ATTRNAME_NAMESPACE = "namespace", + ATTRNAME_NAN = "NaN", + ATTRNAME_NDIGITSPERGROUP = "n-digits-per-group", + ATTRNAME_NS = "ns", + ATTRNAME_ONLY = "only", + ATTRNAME_ORDER = "order", + ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = "cdata-section-elements", + ATTRNAME_OUTPUT_DOCTYPE_PUBLIC = "doctype-public", + ATTRNAME_OUTPUT_DOCTYPE_SYSTEM = "doctype-system", + ATTRNAME_OUTPUT_ENCODING = "encoding", + ATTRNAME_OUTPUT_INDENT = "indent", + ATTRNAME_OUTPUT_MEDIATYPE = "media-type", + ATTRNAME_OUTPUT_METHOD = "method", // qname, + ATTRNAME_OUTPUT_OMITXMLDECL = "omit-xml-declaration", + ATTRNAME_OUTPUT_STANDALONE = "standalone", + ATTRNAME_OUTPUT_VERSION = "version", + ATTRNAME_PATTERNSEPARATOR = "pattern-separator", + ATTRNAME_PERCENT = "percent", + ATTRNAME_PERMILLE = "per-mille", + ATTRNAME_PRIORITY = "priority", + ATTRNAME_REFID = "refID", + ATTRNAME_RESULTNS = "result-ns", + ATTRNAME_RESULT_PREFIX = "result-prefix", + ATTRNAME_SELECT = "select", + ATTRNAME_SEQUENCESRC = "sequence-src", + ATTRNAME_STYLE = "style", + ATTRNAME_STYLESHEET_PREFIX = "stylesheet-prefix", + ATTRNAME_TERMINATE = "terminate", + ATTRNAME_TEST = "test", + ATTRNAME_TOSTRING = "to-string", + ATTRNAME_TYPE = "type", + ATTRNAME_USE = "use", + ATTRNAME_USEATTRIBUTESETS = "use-attribute-sets", + ATTRNAME_VALUE = "value", + ATTRNAME_VERSION = "version", + ATTRNAME_XMLNS = "xmlns:", // namespace declaration prefix -- NOT an attribute by itself + ATTRNAME_XMLNSDEF = "xmlns", // default namespace + ATTRNAME_XMLSPACE = "xml:space", + ATTRNAME_ZERODIGIT = "zero-digit"; + + /** + * IDs for XSL attribute types. These are associated + * with the string literals in the TransformerImpl class. + * Don't change the numbers. NOTE THAT THESE ARE NOT IN + * ALPHABETICAL ORDER! + */ + public static final int TATTRNAME_OUTPUT_METHOD = 1, TATTRNAME_AMOUNT = 2, + TATTRNAME_ANCESTOR = 3, TATTRNAME_ARCHIVE = 4, + TATTRNAME_ATTRIBUTE = 5, + TATTRNAME_ATTRIBUTE_SET = 6, + TATTRNAME_CASEORDER = 7, TATTRNAME_CLASS = 8, + TATTRNAME_CLASSID = 9, TATTRNAME_CODEBASE = 10, + TATTRNAME_CODETYPE = 11, TATTRNAME_CONDITION = 12, + TATTRNAME_COPYTYPE = 13, TATTRNAME_COUNT = 14, + TATTRNAME_DATATYPE = 15, TATTRNAME_DEFAULT = 16, + TATTRNAME_DEFAULTSPACE = 17, TATTRNAME_DEPTH = 18, + TATTRNAME_DIGITGROUPSEP = 19, + TATTRNAME_DISABLE_OUTPUT_ESCAPING = 20, + TATTRNAME_ELEMENT = 21, TATTRNAME_ELEMENTS = 22, + TATTRNAME_EXPR = 23, + TATTRNAME_EXTENSIONELEMENTPREFIXES = 24, + TATTRNAME_FORMAT = 25, TATTRNAME_FROM = 26, + TATTRNAME_GROUPINGSEPARATOR = 27, + TATTRNAME_GROUPINGSIZE = 28, TATTRNAME_HREF = 29, + TATTRNAME_ID = 30, TATTRNAME_IMPORTANCE = 31, + TATTRNAME_INDENTRESULT = 32, TATTRNAME_LANG = 33, + TATTRNAME_LETTERVALUE = 34, TATTRNAME_LEVEL = 35, + TATTRNAME_MATCH = 36, TATTRNAME_METHOD = 37, + TATTRNAME_MODE = 38, TATTRNAME_NAME = 39, + TATTRNAME_NAMESPACE = 40, + TATTRNAME_NDIGITSPERGROUP = 41, TATTRNAME_NS = 42, + TATTRNAME_ONLY = 43, TATTRNAME_ORDER = 44, + TATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = 45, + TATTRNAME_OUTPUT_DOCTYPE_PUBLIC = 46, + TATTRNAME_OUTPUT_DOCTYPE_SYSTEM = 47, + TATTRNAME_OUTPUT_ENCODING = 48, + TATTRNAME_OUTPUT_INDENT = 49, + TATTRNAME_OUTPUT_MEDIATYPE = 50, + TATTRNAME_OUTPUT_STANDALONE = 51, + TATTRNAME_OUTPUT_VERSION = 52, + TATTRNAME_OUTPUT_OMITXMLDECL = 53, + TATTRNAME_PRIORITY = 54, TATTRNAME_REFID = 55, + TATTRNAME_RESULTNS = 56, TATTRNAME_SELECT = 57, + TATTRNAME_SEQUENCESRC = 58, TATTRNAME_STYLE = 59, + TATTRNAME_TEST = 60, TATTRNAME_TOSTRING = 61, + TATTRNAME_TYPE = 62, TATTRNAME_USE = 63, + TATTRNAME_USEATTRIBUTESETS = 64, + TATTRNAME_VALUE = 65, TATTRNAME_XMLNSDEF = 66, + TATTRNAME_XMLNS = 67, TATTRNAME_XMLSPACE = 68, + TATTRNAME_EXCLUDE_RESULT_PREFIXES = 69; + + /** + * Mnemonics for the possible values of the xsl:output element's + * method= attribute: + *

    + *
  • ATTRVAL_OUTPUT_METHOD_XML = Use an XML formatter to + * produce the output document (basic XSLT operation).
  • + *
  • ATTRVAL_OUTPUT_METHOD_HTML: Use an HTML formatter to + * produce the output document. When generating HTML documents, + * this may yield better results; it does things like escaping + * characters in href attributes.
  • + * ATTRVAL_OUTPUT_METHOD_TEXT: Use a Text formatter to + * produce the output document. Generally the right choice if your + * stylesheet wants to take over _all_ the details of formatting, + * most often when producing something that isn't an XML or HTML + * document. + *
+ */ + public static final String ATTRVAL_OUTPUT_METHOD_HTML = "html", + ATTRVAL_OUTPUT_METHOD_XML = "xml", + ATTRVAL_OUTPUT_METHOD_TEXT = "text"; + + + /* For space-att*/ + public static final int ATTRVAL_PRESERVE = 1, ATTRVAL_STRIP = 2; + + + /** + * For indent-result + */ + public static final boolean ATTRVAL_YES = true, ATTRVAL_NO = false; + + + /** + * For letter-value attribute (part of conversion attributes). + */ + public static final String ATTRVAL_ALPHABETIC = "alphabetic", + ATTRVAL_OTHER = "other", + ATTRVAL_TRADITIONAL = "traditional"; + + + /** + * For level attribute in xsl:number. + */ + public static final String ATTRVAL_SINGLE = "single", + ATTRVAL_MULTI = "multiple", ATTRVAL_ANY = "any"; + + + /** + * For Stylesheet-prefix and result-prefix in xsl:namespace-alias + */ + public static final String ATTRVAL_DEFAULT_PREFIX = "#default"; + + /** + * Integer equivalents for above + */ + public static final int NUMBERLETTER_ALPHABETIC = 1, NUMBERLETTER_TRADITIONAL = 2; + + /** + * Integer equivelents for above + */ + public static final int NUMBERLEVEL_SINGLE = 1, NUMBERLEVEL_MULTI = 2, + NUMBERLEVEL_ANY = 3, MAX_MULTI_COUNTING_DEPTH = 32; + + + /** + * some stuff for my patterns-by-example + */ + public static final String ATTRVAL_THIS = ".", ATTRVAL_PARENT = "..", + ATTRVAL_ANCESTOR = "ancestor", ATTRVAL_ID = "id"; + + + /** + * Stuff for sorting + */ + public static final String ATTRVAL_DATATYPE_TEXT = "text", + ATTRVAL_DATATYPE_NUMBER = "number", + ATTRVAL_ORDER_ASCENDING = "ascending", + ATTRVAL_ORDER_DESCENDING = "descending", + ATTRVAL_CASEORDER_UPPER = "upper-first", + ATTRVAL_CASEORDER_LOWER = "lower-first"; + + /** + * Integer equivelents for DATATYPE attribute + */ + public static final int SORTDATATYPE_TEXT = 1, SORTDATATYPE_NUMBER = 2; + + /** + * Integer equivelents for ORDER attribute + */ + public static final int SORTORDER_ASCENDING = 1, SORTORDER_DESCENDING = 2; + + /** + * Integer equivelents for CASE-ORDER attribute + */ + public static final int SORTCASEORDER_UPPERFIRST = 1, SORTCASEORDER_LOWERFIRST = 2; + + /** + * some stuff for Decimal-format + */ + public static final String ATTRVAL_INFINITY = "Infinity", + ATTRVAL_NAN = "NaN", + DEFAULT_DECIMAL_FORMAT = "#default"; + + + /** + * temp dummy + */ + public static final String ATTRNAME_XXXX = "XXXX"; +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html new file mode 100644 index 0000000..f451cb0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/templates/package.html @@ -0,0 +1,16 @@ + + + Xalan Templates Package. + + + +

This package now only contain the classes used by XSLTC. In J2SE 1.5 only XSLTC is bundled as + Transformer for supporting JAXP

+ + + + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java new file mode 100644 index 0000000..23282d8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.utils; + +/** + * A configuration error. This was an internal class in ObjectFactory previously + * + * @LastModified: Oct 2017 + */ +public final class ConfigurationError + extends Error { + private static final long serialVersionUID = 749136645488750664L; + + // + // Data + // + + /** + * Exception. + */ + private Exception exception; + + // + // Constructors + // + + /** + * Construct a new instance with the specified detail string and + * exception. + */ + ConfigurationError(String msg, Exception x) { + super(msg); + this.exception = x; + } // (String,Exception) + + // + // methods + // + + /** + * Returns the exception associated to this error. + */ + public Exception getException() { + return exception; + } // getException():Exception + +} // class ConfigurationError diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java new file mode 100644 index 0000000..cfd41d9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; + +/** + * This is the base class for features and properties + * + * @LastModified: May 2021 + */ +public abstract class FeaturePropertyBase { + + /** + * States of the settings of a property, in the order: default value, value + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system + * properties, and jaxp api properties + */ + public static enum State { + //this order reflects the overriding order + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY + } + + + /** + * Values of the properties as defined in enum Properties + */ + String[] values = null; + /** + * States of the settings for each property in Properties above + */ + State[] states = {State.DEFAULT, State.DEFAULT}; + + + /** + * Set the value for a specific property. + * + * @param property the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(Enum property, State state, String value) { + //only update if it shall override + if (state.compareTo(states[property.ordinal()]) >= 0) { + values[property.ordinal()] = value; + states[property.ordinal()] = state; + } + } + + /** + * Set the value of a property by its index + * + * @param index the index of the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(int index, State state, String value) { + //only update if it shall override + if (state.compareTo(states[index]) >= 0) { + values[index] = value; + states[index] = state; + } + } + + /** + * Set value by property name and state + * + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, Object value) { + int index = getIndex(propertyName); + if (index > -1) { + setValue(index, state, (String) value); + return true; + } + return false; + } + + /** + * Set value by property name and state + * + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, boolean value) { + int index = getIndex(propertyName); + if (index > -1) { + if (value) { + setValue(index, state, JdkConstants.FEATURE_TRUE); + } else { + setValue(index, state, JdkConstants.FEATURE_FALSE); + } + return true; + } + return false; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(Enum property) { + return values[property.ordinal()]; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(String property) { + int index = getIndex(property); + if (index > -1) { + return getValueByIndex(index); + } + return null; + } + + /** + * Return the value of the specified property. + * + * @param propertyName the property name + * @return the value of the property as a string. If a property is managed + * by this manager, its value shall not be null. + */ + public String getValueAsString(String propertyName) { + int index = getIndex(propertyName); + if (index > -1) { + return getValueByIndex(index); + } + + return null; + } + + /** + * Return the value of a property by its ordinal + * + * @param index the index of a property + * @return value of a property + */ + public String getValueByIndex(int index) { + return values[index]; + } + + /** + * Get the index by property name + * + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public abstract int getIndex(String propertyName); + + public > int getIndex(Class property, String propertyName) { + for (Enum enumItem : property.getEnumConstants()) { + if (enumItem.toString().equals(propertyName)) { + //internally, ordinal is used as index + return enumItem.ordinal(); + } + } + return -1; + } + + ; + + + /** + * Read from system properties, or those in jaxp.properties + * + * @param property the property + * @param systemProperty the name of the system property + */ + void getSystemProperty(Enum property, String systemProperty) { + try { + String value = SecuritySupport.getSystemProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.SYSTEMPROPERTY; + return; + } + + value = SecuritySupport.readJAXPProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.JAXPDOTPROPERTIES; + } + } catch (NumberFormatException e) { + //invalid setting ignored + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java new file mode 100644 index 0000000..a60e4cf --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import java.util.function.Supplier; + +import jdk.xml.internal.SecuritySupport; + +/** + * This class is duplicated for each JAXP subpackage so keep it in sync. + * It is package private and therefore is not exposed as part of the JAXP + * API. + *

+ * This class was moved from the javax.xml.parsers.ObjectFactory + * class and modified to be used as a general utility for creating objects + * dynamically. + * + * @LastModified: Oct 2017 + */ +public class ObjectFactory { + + // + // Constants + // + private static final String JAXP_INTERNAL = "com.sun.org.apache"; + private static final String STAX_INTERNAL = "com.sun.xml.internal"; + + /** + * Set to true for debugging + */ + private static final boolean DEBUG = false; + + + /** + * Prints a message to standard error if debugging is enabled. + */ + private static void debugPrintln(Supplier msgGen) { + if (DEBUG) { + System.err.println("JAXP: " + msgGen.get()); + } + } // debugPrintln(String) + + /** + * Figure out which ClassLoader to use. For JDK 1.2 and later use + * the context ClassLoader. + */ + @SuppressWarnings("removal") + public static ClassLoader findClassLoader() { + if (System.getSecurityManager() != null) { + //this will ensure bootclassloader is used + return null; + } + + // Figure out which ClassLoader to use for loading the provider + // class. If there is a Context ClassLoader then use it. + ClassLoader context = SecuritySupport.getContextClassLoader(); + ClassLoader system = SecuritySupport.getSystemClassLoader(); + + ClassLoader chain = system; + while (true) { + if (context == chain) { + // Assert: we are on JDK 1.1 or we have no Context ClassLoader + // or any Context ClassLoader in chain of system classloader + // (including extension ClassLoader) so extend to widest + // ClassLoader (always look in system ClassLoader if Xalan + // is in boot/extension/system classpath and in current + // ClassLoader otherwise); normal classloaders delegate + // back to system ClassLoader first so this widening doesn't + // change the fact that context ClassLoader will be consulted + ClassLoader current = ObjectFactory.class.getClassLoader(); + + chain = system; + while (true) { + if (current == chain) { + // Assert: Current ClassLoader in chain of + // boot/extension/system ClassLoaders + return system; + } + if (chain == null) { + break; + } + chain = SecuritySupport.getParentClassLoader(chain); + } + + // Assert: Current ClassLoader not in chain of + // boot/extension/system ClassLoaders + return current; + } + + if (chain == null) { + // boot ClassLoader reached + break; + } + + // Check for any extension ClassLoaders in chain up to + // boot ClassLoader + chain = SecuritySupport.getParentClassLoader(chain); + } + + // Assert: Context ClassLoader not in chain of + // boot/extension/system ClassLoaders + return context; + } // findClassLoader():ClassLoader + + /** + * Create an instance of a class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place + */ + public static Object newInstance(String className, boolean doFallback) + throws ConfigurationError { + @SuppressWarnings("removal") + ClassLoader cl = System.getSecurityManager() != null ? null : findClassLoader(); + try { + Class providerClass = findProviderClass(className, cl, doFallback); + Object instance = providerClass.getConstructor().newInstance(); + debugPrintln(() -> "created new instance of " + providerClass + + " using ClassLoader: " + cl); + return instance; + } catch (ClassNotFoundException x) { + throw new ConfigurationError( + "Provider " + className + " not found", x); + } catch (Exception x) { + throw new ConfigurationError( + "Provider " + className + " could not be instantiated: " + x, + x); + } + } + + /** + * Find a Class using the same class loader for the ObjectFactory by default + * or boot class loader when Security Manager is in place + */ + public static Class findProviderClass(String className, boolean doFallback) + throws ClassNotFoundException, ConfigurationError { + return findProviderClass(className, + findClassLoader(), doFallback); + } + + /** + * Find a Class using the specified ClassLoader + */ + private static Class findProviderClass(String className, ClassLoader cl, + boolean doFallback) + throws ClassNotFoundException, ConfigurationError { + //throw security exception if the calling thread is not allowed to access the + //class. Restrict the access to the package classes as specified in java.security policy. + @SuppressWarnings("removal") + SecurityManager security = System.getSecurityManager(); + try { + if (security != null) { + if (className.startsWith(JAXP_INTERNAL) || + className.startsWith(STAX_INTERNAL)) { + cl = null; + } else { + final int lastDot = className.lastIndexOf("."); + String packageName = className; + if (lastDot != -1) packageName = className.substring(0, lastDot); + security.checkPackageAccess(packageName); + } + } + } catch (SecurityException e) { + throw e; + } + + Class providerClass; + if (cl == null) { + providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader()); + } else { + try { + providerClass = cl.loadClass(className); + } catch (ClassNotFoundException x) { + if (doFallback) { + // Fall back to current classloader + ClassLoader current = ObjectFactory.class.getClassLoader(); + if (current == null) { + providerClass = Class.forName(className); + } else if (cl != current) { + cl = current; + providerClass = cl.loadClass(className); + } else { + throw x; + } + } else { + throw x; + } + } + } + + return providerClass; + } + +} // class ObjectFactory diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java new file mode 100644 index 0000000..f1da5b5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import javax.xml.XMLConstants; + +import jdk.xml.internal.JdkConstants; + +/** + * This class manages security related properties + */ +public final class XMLSecurityPropertyManager extends FeaturePropertyBase { + + /** + * Properties managed by the security property manager + */ + public static enum Property { + ACCESS_EXTERNAL_DTD(XMLConstants.ACCESS_EXTERNAL_DTD, + JdkConstants.EXTERNAL_ACCESS_DEFAULT), + ACCESS_EXTERNAL_STYLESHEET(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, + JdkConstants.EXTERNAL_ACCESS_DEFAULT); + + final String name; + final String defaultValue; + + Property(String name, String value) { + this.name = name; + this.defaultValue = value; + } + + public boolean equalsName(String propertyName) { + return (propertyName == null) ? false : name.equals(propertyName); + } + + String defaultValue() { + return defaultValue; + } + } + + + /** + * Default constructor. Establishes default values + */ + public XMLSecurityPropertyManager() { + values = new String[Property.values().length]; + for (Property property : Property.values()) { + values[property.ordinal()] = property.defaultValue(); + } + //read system properties or jaxp.properties + readSystemProperties(); + } + + /** + * Get the index by property name + * + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public int getIndex(String propertyName) { + for (Property property : Property.values()) { + if (property.equalsName(propertyName)) { + //internally, ordinal is used as index + return property.ordinal(); + } + } + return -1; + } + + /** + * Read from system properties, or those in jaxp.properties + */ + private void readSystemProperties() { + getSystemProperty(Property.ACCESS_EXTERNAL_DTD, + JdkConstants.SP_ACCESS_EXTERNAL_DTD); + getSystemProperty(Property.ACCESS_EXTERNAL_STYLESHEET, + JdkConstants.SP_ACCESS_EXTERNAL_STYLESHEET); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html new file mode 100644 index 0000000..2ab565b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xslt/package.html @@ -0,0 +1,29 @@ + + + + +Xalan command-line interface. + +

Implementation of Xalan command-line interface. +

+ + + + diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java new file mode 100644 index 0000000..22bdc24 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/CollatorFactory.java @@ -0,0 +1,36 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import java.text.Collator; +import java.util.Locale; + +/** + * @author W. Eliot Kimber (eliot@isogen.com) + * @author Santiago Pericas-Geertsen + */ +public interface CollatorFactory { + + public Collator getCollator(String lang, String country); + + public Collator getCollator(Locale locale); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java new file mode 100644 index 0000000..12894d1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOM.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; + +import java.util.Map; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface DOM { + public final static int FIRST_TYPE = 0; + + public final static int NO_TYPE = -1; + + // 0 is reserved for NodeIterator.END + public final static int NULL = 0; + + // used by some node iterators to know which node to return + public final static int RETURN_CURRENT = 0; + public final static int RETURN_PARENT = 1; + + // Constants used by getResultTreeFrag to indicate the types of the RTFs. + public final static int SIMPLE_RTF = 0; + public final static int ADAPTIVE_RTF = 1; + public final static int TREE_RTF = 2; + + /** + * returns singleton iterator containg the document root + */ + public DTMAxisIterator getIterator(); + + public String getStringValue(); + + public DTMAxisIterator getChildren(final int node); + + public DTMAxisIterator getTypedChildren(final int type); + + public DTMAxisIterator getAxisIterator(final int axis); + + public DTMAxisIterator getTypedAxisIterator(final int axis, final int type); + + public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself); + + public DTMAxisIterator getNamespaceAxisIterator(final int axis, final int ns); + + public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType, + String value, boolean op); + + public DTMAxisIterator orderNodes(DTMAxisIterator source, int node); + + public String getNodeName(final int node); + + public String getNodeNameX(final int node); + + public String getNamespaceName(final int node); + + public int getExpandedTypeID(final int node); + + public int getNamespaceType(final int node); + + public int getParent(final int node); + + public int getAttributeNode(final int gType, final int element); + + public String getStringValueX(final int node); + + public void copy(final int node, SerializationHandler handler) + throws TransletException; + + public void copy(DTMAxisIterator nodes, SerializationHandler handler) + throws TransletException; + + public String shallowCopy(final int node, SerializationHandler handler) + throws TransletException; + + public boolean lessThan(final int node1, final int node2); + + public void characters(final int textNode, SerializationHandler handler) + throws TransletException; + + public Node makeNode(int index); + + public Node makeNode(DTMAxisIterator iter); + + public NodeList makeNodeList(int index); + + public NodeList makeNodeList(DTMAxisIterator iter); + + public String getLanguage(int node); + + public int getSize(); + + public String getDocumentURI(int node); + + public void setFilter(StripFilter filter); + + public void setupMapping(String[] names, String[] urisArray, int[] typesArray, String[] namespaces); + + public boolean isElement(final int node); + + public boolean isAttribute(final int node); + + public String lookupNamespace(int node, String prefix) + throws TransletException; + + public int getNodeIdent(final int nodehandle); + + public int getNodeHandle(final int nodeId); + + public DOM getResultTreeFrag(int initialSize, int rtfType); + + public DOM getResultTreeFrag(int initialSize, int rtfType, boolean addToDTMManager); + + public SerializationHandler getOutputDomBuilder(); + + public int getNSType(int node); + + public int getDocument(); + + public String getUnparsedEntityURI(String name); + + public Map getElementsWithIDs(); + + public void release(); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java new file mode 100644 index 0000000..ec69930 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMCache.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * @author Morten Jorgensen + */ +public interface DOMCache { + + /** + * This method is responsible for: + *

+ * (1) building the DOMImpl tree + *

+ * Parser _parser = new Parser(); + * DOMImpl _dom = new DOMImpl(); + * _parser.setDocumentHandler(_dom.getBuilder()); + * _parser.setDTDHandler(_dom.getBuilder()); + * _parser.parse(uri); + *

+ * (2) giving the translet an early opportunity to extract anything from + * the DOMImpl that it would like + *

+ * translet.documentPrepass(_dom); + *

+ * (3) setting the document URI: + *

+ * _dom.setDocumentURI(uri); + * + * @param baseURI The base URI used by the document call. + * @param href The href argument passed to the document function. + * @param translet A reference to the translet requesting the document + */ + public DOM retrieveDocument(String baseURI, String href, Translet translet); + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java new file mode 100644 index 0000000..49650bb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/DOMEnhancedForDTM.java @@ -0,0 +1,53 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +/** + * Interface for SAXImpl which adds methods used at run-time, over and above + * those provided by the XSLTC DOM interface. An attempt to avoid the current + * "Is the DTM a DOM, if so is it a SAXImpl, . . . + * which was producing some ugly replicated code + * and introducing bugs where that multipathing had not been + * done. This makes it easier to provide other DOM/DOMEnhancedForDTM + * implementations, rather than hard-wiring XSLTC to SAXImpl. + * + * @author Joseph Kesselman + */ +public interface DOMEnhancedForDTM extends DOM { + public short[] getMapping(String[] names, String[] uris, int[] types); + + public int[] getReverseMapping(String[] names, String[] uris, int[] types); + + public short[] getNamespaceMapping(String[] namespaces); + + public short[] getReverseNamespaceMapping(String[] namespaces); + + public String getDocumentURI(); + + public void setDocumentURI(String uri); + + public int getExpandedTypeID2(int nodeHandle); + + public boolean hasDOMSource(); + + public int getElementById(String idString); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java new file mode 100644 index 0000000..a8eba91 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/NodeIterator.java @@ -0,0 +1,84 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTM; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface NodeIterator extends Cloneable { + public static final int END = DTM.NULL; + + /** + * Callers should not call next() after it returns END. + */ + public int next(); + + /** + * Resets the iterator to the last start node. + */ + public NodeIterator reset(); + + /** + * Returns the number of elements in this iterator. + */ + public int getLast(); + + /** + * Returns the position of the current node in the set. + */ + public int getPosition(); + + /** + * Remembers the current node for the next call to gotoMark(). + */ + public void setMark(); + + /** + * Restores the current node remembered by setMark(). + */ + public void gotoMark(); + + /** + * Set start to END should 'close' the iterator, + * i.e. subsequent call to next() should return END. + */ + public NodeIterator setStartNode(int node); + + /** + * True if this iterator has a reversed axis. + */ + public boolean isReverse(); + + /** + * Returns a deep copy of this iterator. + */ + public NodeIterator cloneIterator(); + + /** + * Prevents or allows iterator restarts. + */ + public void setRestartable(boolean isRestartable); + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java new file mode 100644 index 0000000..6fcbbc0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/ProcessorVersion.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * Admin class that assigns a version number to the XSLTC software. + * The version number is made up from three fields as in: + * MAJOR.MINOR[.DELTA]. Fields are incremented based on the following: + * DELTA field: changes for each bug fix, developer fixing the bug should + * increment this field. + * MINOR field: API changes or a milestone culminating from several + * bug fixes. DELTA field goes to zero and MINOR is + * incremented such as: {1.0,1.0.1,1.0.2,1.0.3,...1.0.18,1.1} + * MAJOR field: milestone culminating in fundamental API changes or + * architectural changes. MINOR field goes to zero + * and MAJOR is incremented such as: {...,1.1.14,1.2,2.0} + * Stability of a release follows: X.0 > X.X > X.X.X + * + * @author G. Todd Miller + */ +public class ProcessorVersion { + private static int MAJOR = 1; + private static int MINOR = 0; + private static int DELTA = 0; + + public static void main(String[] args) { + System.out.println("XSLTC version " + MAJOR + "." + MINOR + + ((DELTA > 0) ? ("." + DELTA) : (""))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java new file mode 100644 index 0000000..5339301 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/StripFilter.java @@ -0,0 +1,31 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface StripFilter { + public boolean stripSpace(DOM dom, int node, int type); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java new file mode 100644 index 0000000..e2a208d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/Translet.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +public interface Translet { + + public void transform(DOM document, SerializationHandler handler) + throws TransletException; + + public void transform(DOM document, SerializationHandler[] handlers) + throws TransletException; + + public void transform(DOM document, DTMAxisIterator iterator, + SerializationHandler handler) + throws TransletException; + + public Object addParameter(String name, Object value); + + public void buildKeys(DOM document, DTMAxisIterator iterator, + SerializationHandler handler, int root) + throws TransletException; + + public void addAuxiliaryClass(Class auxClass); + + public Class getAuxiliaryClass(String className); + + public String[] getNamesArray(); + + public String[] getUrisArray(); + + public int[] getTypesArray(); + + public String[] getNamespaceArray(); + + public boolean overrideDefaultParser(); + + public void setOverrideDefaultParser(boolean flag); + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java new file mode 100644 index 0000000..d330f6b --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/TransletException.java @@ -0,0 +1,46 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc; + +import org.xml.sax.SAXException; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +public final class TransletException extends SAXException { + static final long serialVersionUID = -878916829521217293L; + + public TransletException() { + super("Translet error"); + } + + public TransletException(Exception e) { + super(e.toString()); + initCause(e); + } + + public TransletException(String message) { + super(message); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java new file mode 100644 index 0000000..33ce8a0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsoluteLocationPath.java @@ -0,0 +1,127 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AbsoluteLocationPath extends Expression { + private Expression _path; // may be null + + public AbsoluteLocationPath() { + _path = null; + } + + public AbsoluteLocationPath(Expression path) { + _path = path; + if (path != null) { + _path.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_path != null) { + _path.setParser(parser); + } + } + + public Expression getPath() { + return (_path); + } + + public String toString() { + return "AbsoluteLocationPath(" + + (_path != null ? _path.toString() : "null") + ')'; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_path != null) { + final Type ptype = _path.typeCheck(stable); + if (ptype instanceof NodeType) { // promote to node-set + _path = new CastExpr(_path, Type.NodeSet); + } + } + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + if (_path != null) { + final int initAI = cpg.addMethodref(ABSOLUTE_ITERATOR, + "", + "(" + + NODE_ITERATOR_SIG + + ")V"); + + // Compile relative path iterator(s) + // + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // this argument to its constructor. Instead we calculate the + // value of the argument to the constructor first, store it in + // a temporary variable, create the object and reload the argument + // from the temporary to avoid the problem. + _path.translate(classGen, methodGen); + LocalVariableGen relPathIterator + = methodGen.addLocalVariable("abs_location_path_tmp", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + relPathIterator.setStart( + il.append(new ASTORE(relPathIterator.getIndex()))); + + // Create new AbsoluteIterator + il.append(new NEW(cpg.addClass(ABSOLUTE_ITERATOR))); + il.append(DUP); + relPathIterator.setEnd( + il.append(new ALOAD(relPathIterator.getIndex()))); + + // Initialize AbsoluteIterator with iterator from the stack + il.append(new INVOKESPECIAL(initAI)); + } else { + final int gitr = cpg.addInterfaceMethodref(DOM_INTF, + "getIterator", + "()" + NODE_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(new INVOKEINTERFACE(gitr, 1)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java new file mode 100644 index 0000000..7fb11de --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AbsolutePathPattern.java @@ -0,0 +1,139 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPEQ; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.DTM; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AbsolutePathPattern extends LocationPathPattern { + private final RelativePathPattern _left; // may be null + + public AbsolutePathPattern(RelativePathPattern left) { + _left = left; + if (left != null) { + left.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_left != null) + _left.setParser(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _left == null ? Type.Root : _left.typeCheck(stable); + } + + public boolean isWildcard() { + return false; + } + + public StepPattern getKernelPattern() { + return _left != null ? _left.getKernelPattern() : null; + } + + public void reduceKernelPattern() { + _left.reduceKernelPattern(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + if (_left != null) { + if (_left instanceof StepPattern) { + final LocalVariableGen local = + // absolute path pattern temporary + methodGen.addLocalVariable2("apptmp", + Util.getJCRefType(NODE_SIG), + null); + il.append(DUP); + local.setStart(il.append(new ISTORE(local.getIndex()))); + _left.translate(classGen, methodGen); + il.append(methodGen.loadDOM()); + local.setEnd(il.append(new ILOAD(local.getIndex()))); + methodGen.removeLocalVariable(local); + } else { + _left.translate(classGen, methodGen); + } + } + + final int getParent = cpg.addInterfaceMethodref(DOM_INTF, + GET_PARENT, + GET_PARENT_SIG); + final int getType = cpg.addInterfaceMethodref(DOM_INTF, + "getExpandedTypeID", + "(I)I"); + + InstructionHandle begin = il.append(methodGen.loadDOM()); + il.append(SWAP); + il.append(new INVOKEINTERFACE(getParent, 2)); + if (_left instanceof AncestorPattern) { + il.append(methodGen.loadDOM()); + il.append(SWAP); + } + il.append(new INVOKEINTERFACE(getType, 2)); + il.append(new PUSH(cpg, DTM.DOCUMENT_NODE)); + + final BranchHandle skip = il.append(new IF_ICMPEQ(null)); + _falseList.add(il.append(new GOTO_W(null))); + skip.setTarget(il.append(NOP)); + + if (_left != null) { + _left.backPatchTrueList(begin); + + /* + * If _left is an ancestor pattern, backpatch this pattern's false + * list to the loop that searches for more ancestors. + */ + if (_left instanceof AncestorPattern) { + final AncestorPattern ancestor = (AncestorPattern) _left; + _falseList.backPatch(ancestor.getLoopHandle()); // clears list + } + _falseList.append(_left._falseList); + } + } + + public String toString() { + return "absolutePathPattern(" + (_left != null ? _left.toString() : ")"); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java new file mode 100644 index 0000000..12df7b0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AlternativePattern.java @@ -0,0 +1,100 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class AlternativePattern extends Pattern { + private final Pattern _left; + private final Pattern _right; + + /** + * Construct an alternative pattern. The method setParent + * should not be called in this case. + */ + public AlternativePattern(Pattern left, Pattern right) { + _left = left; + _right = right; + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public Pattern getLeft() { + return _left; + } + + public Pattern getRight() { + return _right; + } + + /** + * The type of an '|' is not really defined, hence null is returned. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _left.typeCheck(stable); + _right.typeCheck(stable); + return null; + } + + public double getPriority() { + double left = _left.getPriority(); + double right = _right.getPriority(); + + if (left < right) + return (left); + else + return (right); + } + + public String toString() { + return "alternative(" + _left + ", " + _right + ')'; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + _left.translate(classGen, methodGen); + final InstructionHandle gotot = il.append(new GOTO(null)); + il.append(methodGen.loadContextNode()); + _right.translate(classGen, methodGen); + + _left._trueList.backPatch(gotot); + _left._falseList.backPatch(gotot.getNext()); + + _trueList.append(_right._trueList.add(gotot)); + _falseList.append(_right._falseList); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java new file mode 100644 index 0000000..7fcf145 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AncestorPattern.java @@ -0,0 +1,178 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Erwin Bolwidt + */ +final class AncestorPattern extends RelativePathPattern { + + private final Pattern _left; // may be null + private final RelativePathPattern _right; + private InstructionHandle _loop; + + public AncestorPattern(RelativePathPattern right) { + this(null, right); + } + + public AncestorPattern(Pattern left, RelativePathPattern right) { + _left = left; + (_right = right).setParent(this); + if (left != null) { + left.setParent(this); + } + } + + public InstructionHandle getLoopHandle() { + return _loop; + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_left != null) { + _left.setParser(parser); + } + _right.setParser(parser); + } + + public boolean isWildcard() { + //!!! can be wildcard + return false; + } + + public StepPattern getKernelPattern() { + return _right.getKernelPattern(); + } + + public void reduceKernelPattern() { + _right.reduceKernelPattern(); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_left != null) { + _left.typeCheck(stable); + } + return _right.typeCheck(stable); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + InstructionHandle parent; + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + /* + * The scope of this local var must be the entire method since + * a another pattern may decide to jump back into the loop + */ + final LocalVariableGen local = + methodGen.addLocalVariable2("app", Util.getJCRefType(NODE_SIG), + il.getEnd()); + + final com.sun.org.apache.bcel.internal.generic.Instruction loadLocal = + new ILOAD(local.getIndex()); + final com.sun.org.apache.bcel.internal.generic.Instruction storeLocal = + new ISTORE(local.getIndex()); + + if (_right instanceof StepPattern) { + il.append(DUP); + il.append(storeLocal); + _right.translate(classGen, methodGen); + il.append(methodGen.loadDOM()); + il.append(loadLocal); + } else { + _right.translate(classGen, methodGen); + + if (_right instanceof AncestorPattern) { + il.append(methodGen.loadDOM()); + il.append(SWAP); + } + } + + if (_left != null) { + final int getParent = cpg.addInterfaceMethodref(DOM_INTF, + GET_PARENT, + GET_PARENT_SIG); + parent = il.append(new INVOKEINTERFACE(getParent, 2)); + + il.append(DUP); + il.append(storeLocal); + _falseList.add(il.append(new IFLT(null))); + il.append(loadLocal); + + _left.translate(classGen, methodGen); + + final SyntaxTreeNode p = getParent(); + if (p == null || p instanceof Instruction || + p instanceof TopLevelElement) { + // do nothing + } else { + il.append(loadLocal); + } + + final BranchHandle exit = il.append(new GOTO(null)); + _loop = il.append(methodGen.loadDOM()); + il.append(loadLocal); + local.setEnd(_loop); + il.append(new GOTO(parent)); + exit.setTarget(il.append(NOP)); + _left.backPatchFalseList(_loop); + + _trueList.append(_left._trueList); + } else { + il.append(POP2); + } + + /* + * If _right is an ancestor pattern, backpatch this pattern's false + * list to the loop that searches for more ancestors. + */ + if (_right instanceof AncestorPattern) { + final AncestorPattern ancestor = (AncestorPattern) _right; + _falseList.backPatch(ancestor.getLoopHandle()); // clears list + } + + _trueList.append(_right._trueList); + _falseList.append(_right._falseList); + } + + public String toString() { + return "AncestorPattern(" + _left + ", " + _right + ')'; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java new file mode 100644 index 0000000..8e5aa84 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java @@ -0,0 +1,159 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import java.util.Enumeration; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +final class ApplyImports extends Instruction { + + private QName _modeName; + private int _precedence; + + public void display(int indent) { + indent(indent); + Util.println("ApplyTemplates"); + indent(indent + IndentIncrement); + if (_modeName != null) { + indent(indent + IndentIncrement); + Util.println("mode " + _modeName); + } + } + + /** + * Returns true if this element has parameters + */ + public boolean hasWithParams() { + return hasContents(); + } + + /** + * Determine the lowest import precedence for any stylesheet imported + * or included by the stylesheet in which this + * element occured. The templates that are imported by the stylesheet in + * which this element occured will all have higher import precedence than + * the integer returned by this method. + */ + private int getMinPrecedence(int max) { + // Move to root of include tree + Stylesheet includeRoot = getStylesheet(); + while (includeRoot._includedFrom != null) { + includeRoot = includeRoot._includedFrom; + } + + return includeRoot.getMinimumDescendantPrecedence(); + } + + /** + * Parse the attributes and contents of an element. + */ + public void parseContents(Parser parser) { + // Indicate to the top-level stylesheet that all templates must be + // compiled into separate methods. + Stylesheet stylesheet = getStylesheet(); + stylesheet.setTemplateInlining(false); + + // Get the mode we are currently in (might not be any) + Template template = getTemplate(); + _modeName = template.getModeName(); + _precedence = template.getImportPrecedence(); + + // Get the method name for in this mode + stylesheet = parser.getTopLevelStylesheet(); + + parseChildren(parser); // with-params + } + + /** + * Type-check the attributes/contents of an element. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); // with-params + return Type.Void; + } + + /** + * Translate call-template. A parameter frame is pushed only if + * some template in the stylesheet uses parameters. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // Push the arguments that are passed to applyTemplates() + il.append(classGen.loadTranslet()); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadIterator()); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + + // Push a new parameter frame in case imported template might expect + // parameters. The apply-imports has nothing that it can pass. + if (stylesheet.hasLocalParams()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + } + + // Get the [min,max> precedence of all templates imported under the + // current stylesheet + final int maxPrecedence = _precedence; + final int minPrecedence = getMinPrecedence(maxPrecedence); + final Mode mode = stylesheet.getMode(_modeName); + + // Get name of appropriate apply-templates function for this + // xsl:apply-imports instruction + String functionName = mode.functionName(minPrecedence, maxPrecedence); + + // Construct the translet class-name and the signature of the method + final String className = classGen.getStylesheet().getClassName(); + final String signature = classGen.getApplyTemplatesSigForImport(); + final int applyTemplates = cpg.addMethodref(className, + functionName, + signature); + il.append(new INVOKEVIRTUAL(applyTemplates)); + + // Pop any parameter frame that was pushed above. + if (stylesheet.hasLocalParams()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + } + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java new file mode 100644 index 0000000..a05e8ac --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ApplyTemplates extends Instruction { + private Expression _select; + private Type _type = null; + private QName _modeName; + private String _functionName; + + public void display(int indent) { + indent(indent); + Util.println("ApplyTemplates"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + if (_modeName != null) { + indent(indent + IndentIncrement); + Util.println("mode " + _modeName); + } + } + + public boolean hasWithParams() { + return hasContents(); + } + + public void parseContents(Parser parser) { + final String select = getAttribute("select"); + final String mode = getAttribute("mode"); + + if (select.length() > 0) { + _select = parser.parseExpression(this, "select", null); + + } + + if (mode.length() > 0) { + if (!XML11Char.isXML11ValidQName(mode)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, mode, this); + parser.reportError(Constants.ERROR, err); + } + _modeName = parser.getQNameIgnoreDefaultNs(mode); + } + + // instantiate Mode if needed, cache (apply temp) function name + _functionName = + parser.getTopLevelStylesheet().getMode(_modeName).functionName(); + parseChildren(parser);// with-params + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_select != null) { + _type = _select.typeCheck(stable); + if (_type instanceof NodeType || _type instanceof ReferenceType) { + _select = new CastExpr(_select, Type.NodeSet); + _type = Type.NodeSet; + } + if (_type instanceof NodeSetType || _type instanceof ResultTreeType) { + typeCheckContents(stable); // with-params + return Type.Void; + } + throw new TypeCheckError(this); + } else { + typeCheckContents(stable); // with-params + return Type.Void; + } + } + + /** + * Translate call-template. A parameter frame is pushed only if + * some template in the stylesheet uses parameters. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + boolean setStartNodeCalled = false; + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // check if sorting nodes is required + final List sortObjects = new ArrayList<>(); + for (final SyntaxTreeNode child : getContents()) { + if (child instanceof Sort) { + sortObjects.add((Sort) child); + } + } + + // Push a new parameter frame + if (stylesheet.hasLocalParams() || hasContents()) { + il.append(classGen.loadTranslet()); + final int pushFrame = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(pushFrame)); + // translate with-params + translateContents(classGen, methodGen); + } + + + il.append(classGen.loadTranslet()); + + // The 'select' expression is a result-tree + if ((_type != null) && (_type instanceof ResultTreeType)) { + // cannot be applied to a result tree - issue warning + if (sortObjects.size() > 0) { + ErrorMsg err = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR, this); + getParser().reportError(WARNING, err); + } + // Put the result tree (a DOM adapter) on the stack + _select.translate(classGen, methodGen); + // Get back the DOM and iterator (not just iterator!!!) + _type.translateTo(classGen, methodGen, Type.NodeSet); + } else { + il.append(methodGen.loadDOM()); + + // compute node iterator for applyTemplates + if (sortObjects.size() > 0) { + Sort.translateSortIterator(classGen, methodGen, + _select, sortObjects); + int setStartNode = cpg.addInterfaceMethodref(NODE_ITERATOR, + SET_START_NODE, + "(I)" + + NODE_ITERATOR_SIG); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEINTERFACE(setStartNode, 2)); + setStartNodeCalled = true; + } else { + if (_select == null) + Mode.compileGetChildren(classGen, methodGen, current); + else + _select.translate(classGen, methodGen); + } + } + + if (_select != null && !setStartNodeCalled) { + _select.startIterator(classGen, methodGen); + } + + //!!! need to instantiate all needed modes + final String className = classGen.getStylesheet().getClassName(); + il.append(methodGen.loadHandler()); + final String applyTemplatesSig = classGen.getApplyTemplatesSig(); + final int applyTemplates = cpg.addMethodref(className, + _functionName, + applyTemplatesSig); + il.append(new INVOKEVIRTUAL(applyTemplates)); + + // unmap parameters to release temporary result trees + for (final SyntaxTreeNode child : getContents()) { + if (child instanceof WithParam) { + ((WithParam) child).releaseResultTree(classGen, methodGen); + } + } + + // Pop parameter frame + if (stylesheet.hasLocalParams() || hasContents()) { + il.append(classGen.loadTranslet()); + final int popFrame = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(new INVOKEVIRTUAL(popFrame)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java new file mode 100644 index 0000000..d32d530 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ArgumentList.java @@ -0,0 +1,42 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class ArgumentList { + private final Expression _arg; + private final ArgumentList _rest; + + public ArgumentList(Expression arg, ArgumentList rest) { + _arg = arg; + _rest = rest; + } + + public String toString() { + return _rest == null + ? _arg.toString() + : _arg.toString() + ", " + _rest.toString(); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java new file mode 100644 index 0000000..a659d2e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Attribute.java @@ -0,0 +1,45 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class Attribute extends Instruction { + private QName _name; + + public void display(int indent) { + indent(indent); + Util.println("Attribute " + _name); + displayContents(indent + IndentIncrement); + } + + public void parseContents(Parser parser) { + _name = parser.getQName(getAttribute("name")); + parseChildren(parser); + //!!! add text nodes + //!!! take care of value templates + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java new file mode 100644 index 0000000..ecdcc38 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: AttributeSet.java,v 1.5 2005/09/28 13:48:04 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.AttributeSetMethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +import java.util.Iterator; +import java.util.List; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class AttributeSet extends TopLevelElement { + + // This prefix is used for the method name of attribute set methods + private static final String AttributeSetPrefix = "$as$"; + + // Element contents + private QName _name; + private UseAttributeSets _useSets; + private AttributeSet _mergeSet; + private String _method; + private boolean _ignore = false; + + /** + * Returns the QName of this attribute set + */ + public QName getName() { + return _name; + } + + /** + * Returns the method name of this attribute set. This method name is + * generated by the compiler (XSLTC) + */ + public String getMethodName() { + return _method; + } + + /** + * Call this method to prevent a method for being compiled for this set. + * This is used in case several elements constitute + * a single set (with one name). The last element will merge itself with + * any previous set(s) with the same name and disable the other set(s). + */ + public void ignore() { + _ignore = true; + } + + /** + * Parse the contents of this attribute set. Recognised attributes are + * "name" (required) and "use-attribute-sets" (optional). + */ + public void parseContents(Parser parser) { + + // Get this attribute set's name + final String name = getAttribute("name"); + + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + _name = parser.getQNameIgnoreDefaultNs(name); + if ((_name == null) || (_name.getStringRep().equals(EMPTYSTRING))) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.UNNAMED_ATTRIBSET_ERR, this); + parser.reportError(Constants.ERROR, msg); + } + + // Get any included attribute sets (similar to inheritance...) + final String useSets = getAttribute("use-attribute-sets"); + if (useSets.length() > 0) { + if (!Util.isValidQNames(useSets)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this); + parser.reportError(Constants.ERROR, err); + } + _useSets = new UseAttributeSets(useSets, parser); + } + + // Parse the contents of this node. All child elements must be + // elements. Other elements cause an error. + final List contents = getContents(); + final int count = contents.size(); + for (int i = 0; i < count; i++) { + SyntaxTreeNode child = contents.get(i); + if (child instanceof XslAttribute) { + parser.getSymbolTable().setCurrentNode(child); + child.parseContents(parser); + } else if (child instanceof Text) { + // ignore + } else { + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_CHILD_ERR, this); + parser.reportError(Constants.ERROR, msg); + } + } + + // Point the symbol table back at us... + parser.getSymbolTable().setCurrentNode(this); + } + + /** + * Type check the contents of this element + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + + if (_ignore) return (Type.Void); + + // _mergeSet Point to any previous definition of this attribute set + _mergeSet = stable.addAttributeSet(this); + + _method = AttributeSetPrefix + getXSLTC().nextAttributeSetSerial(); + + if (_useSets != null) _useSets.typeCheck(stable); + typeCheckContents(stable); + return Type.Void; + } + + /** + * Compile a method that outputs the attributes in this set + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + if (_ignore) return; + + // Create a new method generator for an attribute set method + methodGen = new AttributeSetMethodGenerator(_method, classGen); + + // Generate a reference to previous attribute-set definitions with the + // same name first. Those later in the stylesheet take precedence. + if (_mergeSet != null) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final String methodName = _mergeSet.getMethodName(); + + il.append(classGen.loadTranslet()); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadIterator()); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + final int method = cpg.addMethodref(classGen.getClassName(), + methodName, ATTR_SET_SIG); + il.append(new INVOKESPECIAL(method)); + } + + // Translate other used attribute sets first, as local attributes + // take precedence (last attributes overrides first) + if (_useSets != null) _useSets.translate(classGen, methodGen); + + // Translate all local attributes + final Iterator attributes = elements(); + while (attributes.hasNext()) { + SyntaxTreeNode element = attributes.next(); + if (element instanceof XslAttribute) { + final XslAttribute attribute = (XslAttribute) element; + attribute.translate(classGen, methodGen); + } + } + final InstructionList il = methodGen.getInstructionList(); + il.append(RETURN); + + classGen.addMethod(methodGen); + } + + public String toString() { + StringBuffer buf = new StringBuffer("attribute-set: "); + // Translate all local attributes + final Iterator attributes = elements(); + while (attributes.hasNext()) { + final XslAttribute attribute = + (XslAttribute) attributes.next(); + buf.append(attribute); + } + return (buf.toString()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java new file mode 100644 index 0000000..a4189cb --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValue.java @@ -0,0 +1,46 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class AttributeValue extends Expression { + + public static final AttributeValue create(SyntaxTreeNode parent, + String text, Parser parser) { + + AttributeValue result; + if (text.indexOf('{') != -1) { + result = new AttributeValueTemplate(text, parser, parent); + } else if (text.indexOf('}') != -1) { + result = new AttributeValueTemplate(text, parser, parent); + } else { + result = new SimpleAttributeValue(text); + result.setParser(parser); + result.setParent(parent); + } + return result; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java new file mode 100644 index 0000000..929a6b9 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: AttributeValueTemplate.java,v 1.2.4.1 2005/09/01 10:26:57 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.StringTokenizer; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class AttributeValueTemplate extends AttributeValue { + + final static int OUT_EXPR = 0; + final static int IN_EXPR = 1; + final static int IN_EXPR_SQUOTES = 2; + final static int IN_EXPR_DQUOTES = 3; + final static String DELIMITER = "\uFFFE"; // A Unicode nonchar + + public AttributeValueTemplate(String value, Parser parser, + SyntaxTreeNode parent) { + setParent(parent); + setParser(parser); + + try { + parseAVTemplate(value, parser); + } catch (NoSuchElementException e) { + reportError(parent, parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, value); + } + } + + /** + * Two-pass parsing of ATVs. In the first pass, double curly braces are + * replaced by one, and expressions are delimited using DELIMITER. The + * second pass splits up the resulting buffer into literal and non-literal + * expressions. Errors are reported during the first pass. + */ + private void parseAVTemplate(String text, Parser parser) { + StringTokenizer tokenizer = + new StringTokenizer(text, "{}\"\'", true); + + /* + * First pass: replace double curly braces and delimit expressions + * Simple automaton to parse ATVs, delimit expressions and report + * errors. + */ + String t = null; + String lookahead = null; + StringBuilder buffer = new StringBuilder(); + int state = OUT_EXPR; + + while (tokenizer.hasMoreTokens()) { + // Use lookahead if available + if (lookahead != null) { + t = lookahead; + lookahead = null; + } else { + t = tokenizer.nextToken(); + } + + if (t.length() == 1) { + switch (t.charAt(0)) { + case '{': + switch (state) { + case OUT_EXPR: + lookahead = tokenizer.nextToken(); + if (lookahead.equals("{")) { + buffer.append(lookahead); // replace {{ by { + lookahead = null; + } else { + buffer.append(DELIMITER); + state = IN_EXPR; + } + break; + case IN_EXPR: + case IN_EXPR_SQUOTES: + case IN_EXPR_DQUOTES: + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + break; + } + break; + case '}': + switch (state) { + case OUT_EXPR: + lookahead = tokenizer.nextToken(); + if (lookahead.equals("}")) { + buffer.append(lookahead); // replace }} by } + lookahead = null; + } else { + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + } + break; + case IN_EXPR: + buffer.append(DELIMITER); + state = OUT_EXPR; + break; + case IN_EXPR_SQUOTES: + case IN_EXPR_DQUOTES: + buffer.append(t); + break; + } + break; + case '\'': + switch (state) { + case IN_EXPR: + state = IN_EXPR_SQUOTES; + break; + case IN_EXPR_SQUOTES: + state = IN_EXPR; + break; + case OUT_EXPR: + case IN_EXPR_DQUOTES: + break; + } + buffer.append(t); + break; + case '\"': + switch (state) { + case IN_EXPR: + state = IN_EXPR_DQUOTES; + break; + case IN_EXPR_DQUOTES: + state = IN_EXPR; + break; + case OUT_EXPR: + case IN_EXPR_SQUOTES: + break; + } + buffer.append(t); + break; + default: + buffer.append(t); + break; + } + } else { + buffer.append(t); + } + } + + // Must be in OUT_EXPR at the end of parsing + if (state != OUT_EXPR) { + reportError(getParent(), parser, + ErrorMsg.ATTR_VAL_TEMPLATE_ERR, text); + } + + /* + * Second pass: split up buffer into literal and non-literal expressions. + */ + tokenizer = new StringTokenizer(buffer.toString(), DELIMITER, true); + + while (tokenizer.hasMoreTokens()) { + t = tokenizer.nextToken(); + + if (t.equals(DELIMITER)) { + addElement(parser.parseExpression(this, tokenizer.nextToken())); + tokenizer.nextToken(); // consume other delimiter + } else { + addElement(new LiteralExpr(t)); + } + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final List contents = getContents(); + final int n = contents.size(); + for (int i = 0; i < n; i++) { + final Expression exp = (Expression) contents.get(i); + if (!exp.typeCheck(stable).identicalTo(Type.String)) { + contents.set(i, new CastExpr(exp, Type.String)); + } + } + return _type = Type.String; + } + + public String toString() { + final StringBuilder buffer = new StringBuilder("AVT:["); + final int count = elementCount(); + for (int i = 0; i < count; i++) { + buffer.append(elementAt(i).toString()); + if (i < count - 1) + buffer.append(' '); + } + return buffer.append(']').toString(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + if (elementCount() == 1) { + final Expression exp = (Expression) elementAt(0); + exp.translate(classGen, methodGen); + } else { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int initBuffer = cpg.addMethodref(STRING_BUFFER_CLASS, + "", "()V"); + final Instruction append = + new INVOKEVIRTUAL(cpg.addMethodref(STRING_BUFFER_CLASS, + "append", + "(" + STRING_SIG + ")" + + STRING_BUFFER_SIG)); + + final int toString = cpg.addMethodref(STRING_BUFFER_CLASS, + "toString", + "()" + STRING_SIG); + il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); + il.append(DUP); + il.append(new INVOKESPECIAL(initBuffer)); + // StringBuilder is on the stack + final Iterator elements = elements(); + while (elements.hasNext()) { + final Expression exp = (Expression) elements.next(); + exp.translate(classGen, methodGen); + il.append(append); + } + il.append(new INVOKEVIRTUAL(toString)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java new file mode 100644 index 0000000..ecfe5b2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Nov 2017 + */ +final class BinOpExpr extends Expression { + public static final int PLUS = 0; + public static final int MINUS = 1; + public static final int TIMES = 2; + public static final int DIV = 3; + public static final int MOD = 4; + + private static final String[] Ops = { + "+", "-", "*", "/", "%" + }; + + private int _op; + private Expression _left, _right; + + public BinOpExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + if (_left.hasPositionCall()) return true; + if (_right.hasPositionCall()) return true; + return false; + } + + /** + * Returns true if this expressions contains a call to last() + */ + public boolean hasLastCall() { + return (_left.hasLastCall() || _right.hasLastCall()); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tleft = _left.typeCheck(stable); + final Type tright = _right.typeCheck(stable); + final MethodType ptype = lookupPrimop(stable, Ops[_op], + new MethodType(Type.Void, + tleft, tright)); + if (ptype != null) { + final Type arg1 = ptype.argsType().get(0); + if (!arg1.identicalTo(tleft)) { + _left = new CastExpr(_left, arg1); + } + final Type arg2 = ptype.argsType().get(1); + if (!arg2.identicalTo(tright)) { + _right = new CastExpr(_right, arg1); + } + return _type = ptype.resultType(); + } + throw new TypeCheckError(this); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + + switch (_op) { + case PLUS: + il.append(_type.ADD()); + break; + case MINUS: + il.append(_type.SUB()); + break; + case TIMES: + il.append(_type.MUL()); + break; + case DIV: + il.append(_type.DIV()); + break; + case MOD: + il.append(_type.REM()); + break; + default: + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_BINARY_OP_ERR, this); + getParser().reportError(Constants.ERROR, msg); + } + } + + public String toString() { + return Ops[_op] + '(' + _left + ", " + _right + ')'; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java new file mode 100644 index 0000000..6aae677 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanCall.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class BooleanCall extends FunctionCall { + + private Expression _arg = null; + + public BooleanCall(QName fname, List arguments) { + super(fname, arguments); + _arg = argument(0); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _arg.typeCheck(stable); + return _type = Type.Boolean; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + _arg.translate(classGen, methodGen); + final Type targ = _arg.getType(); + if (!targ.identicalTo(Type.Boolean)) { + _arg.startIterator(classGen, methodGen); + targ.translateTo(classGen, methodGen, Type.Boolean); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java new file mode 100644 index 0000000..c264c30 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/BooleanExpr.java @@ -0,0 +1,79 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * This class implements inlined calls to the XSLT standard functions + * true() and false(). + * + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class BooleanExpr extends Expression { + private boolean _value; + + public BooleanExpr(boolean value) { + _value = value; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _type = Type.Boolean; + return _type; + } + + public String toString() { + return _value ? "true()" : "false()"; + } + + public boolean getValue() { + return _value; + } + + public boolean contextDependent() { + return false; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + if (_value) { + il.append(NOP); // true list falls through + } else { + _falseList.add(il.append(new GOTO(null))); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java new file mode 100644 index 0000000..3c9ef24 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Erwin Bolwidt + * @LastModified: Oct 2017 + */ +final class CallTemplate extends Instruction { + + /** + * Name of template to call. + */ + private QName _name; + + /** + * The array of effective parameters in this CallTemplate. An object in + * this array can be either a WithParam or a Param if no WithParam + * exists for a particular parameter. + */ + private SyntaxTreeNode[] _parameters = null; + + /** + * The corresponding template which this CallTemplate calls. + */ + private Template _calleeTemplate = null; + + public void display(int indent) { + indent(indent); + System.out.print("CallTemplate"); + Util.println(" name " + _name); + displayContents(indent + IndentIncrement); + } + + public boolean hasWithParams() { + return elementCount() > 0; + } + + public void parseContents(Parser parser) { + final String name = getAttribute("name"); + if (name.length() > 0) { + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + _name = parser.getQNameIgnoreDefaultNs(name); + } else { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); + } + parseChildren(parser); + } + + /** + * Verify that a template with this name exists. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Template template = stable.lookupTemplate(_name); + if (template != null) { + typeCheckContents(stable); + } else { + ErrorMsg err = new ErrorMsg(ErrorMsg.TEMPLATE_UNDEF_ERR, _name, this); + throw new TypeCheckError(err); + } + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Stylesheet stylesheet = classGen.getStylesheet(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // If there are Params in the stylesheet or WithParams in this call? + if (stylesheet.hasLocalParams() || hasContents()) { + _calleeTemplate = getCalleeTemplate(); + + // Build the parameter list if the called template is simple named + if (_calleeTemplate != null) { + buildParameterList(); + } + // This is only needed when the called template is not + // a simple named template. + else { + // Push parameter frame + final int push = cpg.addMethodref(TRANSLET_CLASS, + PUSH_PARAM_FRAME, + PUSH_PARAM_FRAME_SIG); + il.append(classGen.loadTranslet()); + il.append(new INVOKEVIRTUAL(push)); + translateContents(classGen, methodGen); + } + } + + // Generate a valid Java method name + final String className = stylesheet.getClassName(); + String methodName = Util.escape(_name.toString()); + + // Load standard arguments + il.append(classGen.loadTranslet()); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadIterator()); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + + // Initialize prefix of method signature + StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG + + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG); + + // If calling a simply named template, push actual arguments + if (_calleeTemplate != null) { + int numParams = _parameters.length; + + for (int i = 0; i < numParams; i++) { + SyntaxTreeNode node = _parameters[i]; + methodSig.append(OBJECT_SIG); // append Object to signature + + // Push 'null' if Param to indicate no actual parameter specified + if (node instanceof Param) { + il.append(ACONST_NULL); + } else { // translate WithParam + node.translate(classGen, methodGen); + } + } + } + + // Complete signature and generate invokevirtual call + methodSig.append(")V"); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(className, + methodName, + methodSig.toString()))); + + // release temporary result trees + if (_parameters != null) { + for (int i = 0; i < _parameters.length; i++) { + if (_parameters[i] instanceof WithParam) { + ((WithParam) _parameters[i]).releaseResultTree(classGen, methodGen); + } + } + } + + // Do not need to call Translet.popParamFrame() if we are + // calling a simple named template. + if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) { + // Pop parameter frame + final int pop = cpg.addMethodref(TRANSLET_CLASS, + POP_PARAM_FRAME, + POP_PARAM_FRAME_SIG); + il.append(classGen.loadTranslet()); + il.append(new INVOKEVIRTUAL(pop)); + } + } + + /** + * Return the simple named template which this CallTemplate calls. + * Return false if there is no matched template or the matched + * template is not a simple named template. + */ + public Template getCalleeTemplate() { + Template foundTemplate + = getXSLTC().getParser().getSymbolTable().lookupTemplate(_name); + + return foundTemplate.isSimpleNamedTemplate() ? foundTemplate : null; + } + + /** + * Build the list of effective parameters in this CallTemplate. + * The parameters of the called template are put into the array first. + * Then we visit the WithParam children of this CallTemplate and replace + * the Param with a corresponding WithParam having the same name. + */ + private void buildParameterList() { + // Put the parameters from the called template into the array first. + // This is to ensure the order of the parameters. + List defaultParams = _calleeTemplate.getParameters(); + int numParams = defaultParams.size(); + _parameters = new SyntaxTreeNode[numParams]; + for (int i = 0; i < numParams; i++) { + _parameters[i] = defaultParams.get(i); + } + + // Replace a Param with a WithParam if they have the same name. + int count = elementCount(); + for (int i = 0; i < count; i++) { + Object node = elementAt(i); + + // Ignore if not WithParam + if (node instanceof WithParam) { + WithParam withParam = (WithParam) node; + QName name = withParam.getName(); + + // Search for a Param with the same name + for (int k = 0; k < numParams; k++) { + SyntaxTreeNode parm = _parameters[k]; + if (parm instanceof Param + && ((Param) parm).getName().equals(name)) { + withParam.setDoParameterOptimization(true); + _parameters[k] = withParam; + break; + } else if (parm instanceof WithParam + && ((WithParam) parm).getName().equals(name)) { + withParam.setDoParameterOptimization(true); + _parameters[k] = withParam; + break; + } + } + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java new file mode 100644 index 0000000..3c32bdc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastCall.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.CHECKCAST; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class CastCall extends FunctionCall { + + /** + * Name of the class that is the target of the cast. Must be a + * fully-qualified Java class Name. + */ + private String _className; + + /** + * A reference to the expression being casted. + */ + private Expression _right; + + /** + * Constructor. + */ + public CastCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Type check the two parameters for this function + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Check that the function was passed exactly two arguments + if (argumentCount() != 2) { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, + getName(), this)); + } + + // The first argument must be a literal String + Expression exp = argument(0); + if (exp instanceof LiteralExpr) { + _className = ((LiteralExpr) exp).getValue(); + _type = Type.newObjectType(_className); + } else { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + getName(), this)); + } + + // Second argument must be of type reference or object + _right = argument(1); + Type tright = _right.typeCheck(stable); + if (tright != Type.Reference && + tright instanceof ObjectType == false) { + throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, + tright, _type, this)); + } + + return _type; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + _right.translate(classGen, methodGen); + il.append(new CHECKCAST(cpg.addClass(_className))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java new file mode 100644 index 0000000..833e283 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CastExpr.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: CastExpr.java,v 1.2.4.1 2005/09/12 10:06:35 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPNE; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.SIPUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.dtm.Axis; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + */ +final class CastExpr extends Expression { + /** + * Legal conversions between internal types. + */ + private static final MultiHashtable InternalTypeMap = new MultiHashtable<>(); + + static { + // Possible type conversions between internal types + InternalTypeMap.put(Type.Boolean, Type.Boolean); + InternalTypeMap.put(Type.Boolean, Type.Real); + InternalTypeMap.put(Type.Boolean, Type.String); + InternalTypeMap.put(Type.Boolean, Type.Reference); + InternalTypeMap.put(Type.Boolean, Type.Object); + + InternalTypeMap.put(Type.Real, Type.Real); + InternalTypeMap.put(Type.Real, Type.Int); + InternalTypeMap.put(Type.Real, Type.Boolean); + InternalTypeMap.put(Type.Real, Type.String); + InternalTypeMap.put(Type.Real, Type.Reference); + InternalTypeMap.put(Type.Real, Type.Object); + + InternalTypeMap.put(Type.Int, Type.Int); + InternalTypeMap.put(Type.Int, Type.Real); + InternalTypeMap.put(Type.Int, Type.Boolean); + InternalTypeMap.put(Type.Int, Type.String); + InternalTypeMap.put(Type.Int, Type.Reference); + InternalTypeMap.put(Type.Int, Type.Object); + + InternalTypeMap.put(Type.String, Type.String); + InternalTypeMap.put(Type.String, Type.Boolean); + InternalTypeMap.put(Type.String, Type.Real); + InternalTypeMap.put(Type.String, Type.Reference); + InternalTypeMap.put(Type.String, Type.Object); + + InternalTypeMap.put(Type.NodeSet, Type.NodeSet); + InternalTypeMap.put(Type.NodeSet, Type.Boolean); + InternalTypeMap.put(Type.NodeSet, Type.Real); + InternalTypeMap.put(Type.NodeSet, Type.String); + InternalTypeMap.put(Type.NodeSet, Type.Node); + InternalTypeMap.put(Type.NodeSet, Type.Reference); + InternalTypeMap.put(Type.NodeSet, Type.Object); + + InternalTypeMap.put(Type.Node, Type.Node); + InternalTypeMap.put(Type.Node, Type.Boolean); + InternalTypeMap.put(Type.Node, Type.Real); + InternalTypeMap.put(Type.Node, Type.String); + InternalTypeMap.put(Type.Node, Type.NodeSet); + InternalTypeMap.put(Type.Node, Type.Reference); + InternalTypeMap.put(Type.Node, Type.Object); + + InternalTypeMap.put(Type.ResultTree, Type.ResultTree); + InternalTypeMap.put(Type.ResultTree, Type.Boolean); + InternalTypeMap.put(Type.ResultTree, Type.Real); + InternalTypeMap.put(Type.ResultTree, Type.String); + InternalTypeMap.put(Type.ResultTree, Type.NodeSet); + InternalTypeMap.put(Type.ResultTree, Type.Reference); + InternalTypeMap.put(Type.ResultTree, Type.Object); + + InternalTypeMap.put(Type.Reference, Type.Reference); + InternalTypeMap.put(Type.Reference, Type.Boolean); + InternalTypeMap.put(Type.Reference, Type.Int); + InternalTypeMap.put(Type.Reference, Type.Real); + InternalTypeMap.put(Type.Reference, Type.String); + InternalTypeMap.put(Type.Reference, Type.Node); + InternalTypeMap.put(Type.Reference, Type.NodeSet); + InternalTypeMap.put(Type.Reference, Type.ResultTree); + InternalTypeMap.put(Type.Reference, Type.Object); + + InternalTypeMap.put(Type.Object, Type.String); + + InternalTypeMap.put(Type.Void, Type.String); + + InternalTypeMap.makeUnmodifiable(); + } + + private final Expression _left; + private boolean _typeTest = false; + + /** + * Construct a cast expression and check that the conversion is + * valid by calling typeCheck(). + */ + public CastExpr(Expression left, Type type) throws TypeCheckError { + _left = left; + _type = type; // use inherited field + + if ((_left instanceof Step) && (_type == Type.Boolean)) { + Step step = (Step) _left; + if ((step.getAxis() == Axis.SELF) && (step.getNodeType() != -1)) + _typeTest = true; + } + + // check if conversion is valid + setParser(left.getParser()); + setParent(left.getParent()); + left.setParent(this); + typeCheck(left.getParser().getSymbolTable()); + } + + public Expression getExpr() { + return _left; + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + return (_left.hasPositionCall()); + } + + public boolean hasLastCall() { + return (_left.hasLastCall()); + } + + public String toString() { + return "cast(" + _left + ", " + _type + ")"; + } + + /** + * Type checking a cast expression amounts to verifying that the + * type conversion is legal. Cast expressions are created during + * type checking, but typeCheck() is usually not called on them. + * As a result, this method is called from the constructor. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + Type tleft = _left.getType(); + if (tleft == null) { + tleft = _left.typeCheck(stable); + } + if (tleft instanceof NodeType) { + tleft = Type.Node; // multiple instances + } else if (tleft instanceof ResultTreeType) { + tleft = Type.ResultTree; // multiple instances + } + if (InternalTypeMap.maps(tleft, _type) != null) { + return _type; + } + // throw new TypeCheckError(this); + throw new TypeCheckError(new ErrorMsg( + ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString())); + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + FlowList fl; + final Type ltype = _left.getType(); + + // This is a special case for the self:: axis. Instead of letting + // the Step object create and iterator that we cast back to a single + // node, we simply ask the DOM for the node type. + if (_typeTest) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final int idx = cpg.addInterfaceMethodref(DOM_INTF, + "getExpandedTypeID", + "(I)I"); + il.append(new SIPUSH((short) ((Step) _left).getNodeType())); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadContextNode()); + il.append(new INVOKEINTERFACE(idx, 2)); + _falseList.add(il.append(new IF_ICMPNE(null))); + } else { + + _left.translate(classGen, methodGen); + if (_type != ltype) { + _left.startIterator(classGen, methodGen); + if (_type instanceof BooleanType) { + fl = ltype.translateToDesynthesized(classGen, methodGen, + _type); + if (fl != null) { + _falseList.append(fl); + } + } else { + ltype.translateTo(classGen, methodGen, _type); + } + } + } + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final Type ltype = _left.getType(); + _left.translate(classGen, methodGen); + if (_type.identicalTo(ltype) == false) { + _left.startIterator(classGen, methodGen); + ltype.translateTo(classGen, methodGen, _type); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java new file mode 100644 index 0000000..69439f0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CeilingCall.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class CeilingCall extends FunctionCall { + public CeilingCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + argument(0).translate(classGen, methodGen); + il.append(new INVOKESTATIC(cpg.addMethodref(MATH_CLASS, + "ceil", "(D)D"))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java new file mode 100644 index 0000000..18308f4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Choose.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Choose.java,v 1.2.4.1 2005/09/01 12:00:14 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class Choose extends Instruction { + + /** + * Display the element contents (a lot of when's and an otherwise) + */ + public void display(int indent) { + indent(indent); + Util.println("Choose"); + indent(indent + IndentIncrement); + displayContents(indent + IndentIncrement); + } + + /** + * Translate this Choose element. Generate a test-chain for the various + * elements and default to the if present. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final List whenElements = new ArrayList<>(); + Otherwise otherwise = null; + Iterator elements = elements(); + + // These two are for reporting errors only + ErrorMsg error = null; + final int line = getLineNumber(); + + // Traverse all child nodes - must be either When or Otherwise + while (elements.hasNext()) { + SyntaxTreeNode element = elements.next(); + // Add a When child element + if (element instanceof When) { + whenElements.add(element); + } + // Add an Otherwise child element + else if (element instanceof Otherwise) { + if (otherwise == null) { + otherwise = (Otherwise) element; + } else { + error = new ErrorMsg(ErrorMsg.MULTIPLE_OTHERWISE_ERR, this); + getParser().reportError(Constants.ERROR, error); + } + } else if (element instanceof Text) { + ((Text) element).ignore(); + } + // It is an error if we find some other element here + else { + error = new ErrorMsg(ErrorMsg.WHEN_ELEMENT_ERR, this); + getParser().reportError(Constants.ERROR, error); + } + } + + // Make sure that there is at least one element + if (whenElements.size() == 0) { + error = new ErrorMsg(ErrorMsg.MISSING_WHEN_ERR, this); + getParser().reportError(Constants.ERROR, error); + return; + } + + InstructionList il = methodGen.getInstructionList(); + + // next element will hold a handle to the beginning of next + // When/Otherwise if test on current When fails + BranchHandle nextElement = null; + List exitHandles = new ArrayList<>(); + InstructionHandle exit = null; + + Enumeration whens = Collections.enumeration(whenElements); + while (whens.hasMoreElements()) { + final When when = (When) whens.nextElement(); + final Expression test = when.getTest(); + + InstructionHandle truec = il.getEnd(); + + if (nextElement != null) + nextElement.setTarget(il.append(NOP)); + test.translateDesynthesized(classGen, methodGen); + + if (test instanceof FunctionCall) { + FunctionCall call = (FunctionCall) test; + try { + Type type = call.typeCheck(getParser().getSymbolTable()); + if (type != Type.Boolean) { + test._falseList.add(il.append(new IFEQ(null))); + } + } catch (TypeCheckError e) { + // handled later! + } + } + // remember end of condition + truec = il.getEnd(); + + // The When object should be ignored completely in case it tests + // for the support of a non-available element + if (!when.ignore()) when.translateContents(classGen, methodGen); + + // goto exit after executing the body of when + exitHandles.add(il.append(new GOTO(null))); + if (whens.hasMoreElements() || otherwise != null) { + nextElement = il.append(new GOTO(null)); + test.backPatchFalseList(nextElement); + } else + test.backPatchFalseList(exit = il.append(NOP)); + test.backPatchTrueList(truec.getNext()); + } + + // Translate any element + if (otherwise != null) { + nextElement.setTarget(il.append(NOP)); + otherwise.translateContents(classGen, methodGen); + exit = il.append(NOP); + } + + // now that end is known set targets of exit gotos + Enumeration exitGotos = Collections.enumeration(exitHandles); + while (exitGotos.hasMoreElements()) { + BranchHandle gotoExit = (BranchHandle) exitGotos.nextElement(); + gotoExit.setTarget(exit); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java new file mode 100644 index 0000000..b89b9df --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Closure.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Santiago Pericas-Geertsen + */ +public interface Closure { + + /** + * Returns true if this closure is compiled in an inner class (i.e. + * if this is a real closure). + */ + public boolean inInnerClass(); + + /** + * Returns a reference to its parent closure or null if outermost. + */ + public Closure getParentClosure(); + + /** + * Returns the name of the auxiliary class or null if this predicate + * is compiled inside the Translet. + */ + public String getInnerClassName(); + + /** + * Add new variable to the closure. + */ + public void addVariable(VariableRefBase variableRef); +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java new file mode 100644 index 0000000..c56ff6c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Comment.java @@ -0,0 +1,116 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETFIELD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class Comment extends Instruction { + + public void parseContents(Parser parser) { + parseChildren(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); + return Type.String; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Shortcut for literal strings + Text rawText = null; + if (elementCount() == 1) { + Object content = elementAt(0); + if (content instanceof Text) { + rawText = (Text) content; + } + } + + // If the content is literal text, call comment(char[],int,int) or + // comment(String), as appropriate. Otherwise, use a + // StringValueHandler to gather the textual content of the xsl:comment + // and call comment(String) with the result. + if (rawText != null) { + il.append(methodGen.loadHandler()); + + if (rawText.canLoadAsArrayOffsetLength()) { + rawText.loadAsArrayOffsetLength(classGen, methodGen); + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "([CII)V"); + il.append(new INVOKEINTERFACE(comment, 4)); + } else { + il.append(new PUSH(cpg, rawText.getText())); + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "(" + STRING_SIG + ")V"); + il.append(new INVOKEINTERFACE(comment, 2)); + } + } else { + // Save the current handler base on the stack + il.append(methodGen.loadHandler()); + il.append(DUP); // first arg to "comment" call + + // Get the translet's StringValueHandler + il.append(classGen.loadTranslet()); + il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS, + "stringValueHandler", + STRING_VALUE_HANDLER_SIG))); + il.append(DUP); + il.append(methodGen.storeHandler()); + + // translate contents with substituted handler + translateContents(classGen, methodGen); + + // get String out of the handler + il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER, + "getValue", + "()" + STRING_SIG))); + // call "comment" + final int comment = + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "comment", + "(" + STRING_SIG + ")V"); + il.append(new INVOKEINTERFACE(comment, 2)); + // Restore old handler base from stack + il.append(methodGen.storeHandler()); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java new file mode 100644 index 0000000..485166d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CompilerException.java @@ -0,0 +1,54 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Morten Jorgensen + */ +public final class CompilerException extends Exception { + static final long serialVersionUID = 1732939618562742663L; + + private String _msg; + + public CompilerException() { + super(); + } + + public CompilerException(Exception e) { + super(e.toString()); + _msg = e.toString(); + } + + public CompilerException(String message) { + super(message); + _msg = message; + } + + public String getMessage() { + final int col = _msg.indexOf(':'); + + if (col > -1) + return (_msg.substring(col)); + else + return (_msg); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java new file mode 100644 index 0000000..cf8b930 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ConcatCall.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ConcatCall extends FunctionCall { + public ConcatCall(QName fname, List arguments) { + super(fname, arguments); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + for (int i = 0; i < argumentCount(); i++) { + final Expression exp = argument(i); + if (!exp.typeCheck(stable).identicalTo(Type.String)) { + setArgument(i, new CastExpr(exp, Type.String)); + } + } + return _type = Type.String; + } + + /** + * translate leaves a String on the stack + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int nArgs = argumentCount(); + + switch (nArgs) { + case 0: + il.append(new PUSH(cpg, EMPTYSTRING)); + break; + + case 1: + argument().translate(classGen, methodGen); + break; + + default: + final int initBuffer = cpg.addMethodref(STRING_BUFFER_CLASS, + "", "()V"); + final Instruction append = + new INVOKEVIRTUAL(cpg.addMethodref(STRING_BUFFER_CLASS, + "append", + "(" + STRING_SIG + ")" + + STRING_BUFFER_SIG)); + + final int toString = cpg.addMethodref(STRING_BUFFER_CLASS, + "toString", + "()" + STRING_SIG); + + il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); + il.append(DUP); + il.append(new INVOKESPECIAL(initBuffer)); + for (int i = 0; i < nArgs; i++) { + argument(i).translate(classGen, methodGen); + il.append(append); + } + il.append(new INVOKEVIRTUAL(toString)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java new file mode 100644 index 0000000..c008ba0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java @@ -0,0 +1,594 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Constants.java,v 1.7 2006/06/19 19:49:04 spericas Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ArithmeticInstruction; +import com.sun.org.apache.bcel.internal.generic.ArrayInstruction; +import com.sun.org.apache.bcel.internal.generic.ConversionInstruction; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction; +import com.sun.org.apache.bcel.internal.generic.ReturnInstruction; +import com.sun.org.apache.bcel.internal.generic.StackInstruction; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +public interface Constants { + public static final Instruction ACONST_NULL = InstructionConst.ACONST_NULL; + public static final Instruction ATHROW = InstructionConst.ATHROW; + public static final Instruction DCMPG = InstructionConst.DCMPG; + public static final Instruction DCONST_0 = InstructionConst.DCONST_0; + public static final Instruction ICONST_0 = InstructionConst.ICONST_0; + public static final Instruction ICONST_1 = InstructionConst.ICONST_1; + public static final Instruction NOP = InstructionConst.NOP; + + + public static final StackInstruction DUP = InstructionConst.DUP; + public static final StackInstruction DUP2 = InstructionConst.DUP2; + public static final StackInstruction DUP_X1 = InstructionConst.DUP_X1; + public static final StackInstruction DUP_X2 = InstructionConst.DUP_X2; + public static final StackInstruction POP = InstructionConst.POP; + public static final StackInstruction POP2 = InstructionConst.POP2; + public static final StackInstruction SWAP = InstructionConst.SWAP; + + public static final LocalVariableInstruction ALOAD_0 = InstructionConst.ALOAD_0; + public static final LocalVariableInstruction ALOAD_1 = InstructionConst.ALOAD_1; + public static final LocalVariableInstruction ALOAD_2 = InstructionConst.ALOAD_2; + public static final LocalVariableInstruction ILOAD_1 = InstructionConst.ILOAD_1; + public static final LocalVariableInstruction ILOAD_2 = InstructionConst.ILOAD_2; + + public static final ArithmeticInstruction DADD = InstructionConst.DADD; + public static final ArithmeticInstruction IXOR = InstructionConst.IXOR; + + public static final ArrayInstruction AASTORE = InstructionConst.AASTORE; + public static final ArrayInstruction IASTORE = InstructionConst.IASTORE; + + public static final ConversionInstruction D2F = InstructionConst.D2F; + public static final ConversionInstruction D2I = InstructionConst.D2I; + public static final ConversionInstruction D2L = InstructionConst.D2L; + public static final ConversionInstruction F2D = InstructionConst.F2D; + public static final ConversionInstruction I2B = InstructionConst.I2B; + public static final ConversionInstruction I2C = InstructionConst.I2C; + public static final ConversionInstruction I2D = InstructionConst.I2D; + public static final ConversionInstruction I2F = InstructionConst.I2F; + public static final ConversionInstruction I2L = InstructionConst.I2L; + public static final ConversionInstruction I2S = InstructionConst.I2S; + public static final ConversionInstruction L2D = InstructionConst.L2D; + public static final ConversionInstruction L2I = InstructionConst.L2I; + + + public static final ReturnInstruction ARETURN = InstructionConst.ARETURN; + public static final ReturnInstruction IRETURN = InstructionConst.IRETURN; + public static final ReturnInstruction RETURN = InstructionConst.RETURN; + + + // Error categories used to report errors to Parser.reportError() + + // Unexpected internal errors, such as null-ptr exceptions, etc. + // Immediately terminates compilation, no translet produced + public final int INTERNAL = 0; + // XSLT elements that are not implemented and unsupported ext. + // Immediately terminates compilation, no translet produced + public final int UNSUPPORTED = 1; + // Fatal error in the stylesheet input (parsing or content) + // Immediately terminates compilation, no translet produced + public final int FATAL = 2; + // Other error in the stylesheet input (parsing or content) + // Does not terminate compilation, no translet produced + public final int ERROR = 3; + // Other error in the stylesheet input (content errors only) + // Does not terminate compilation, a translet is produced + public final int WARNING = 4; + + public static final String EMPTYSTRING = ""; + + public static final String NAMESPACE_FEATURE = + "http://xml.org/sax/features/namespaces"; + + public static final String TRANSLET_INTF + = "com.sun.org.apache.xalan.internal.xsltc.Translet"; + public static final String TRANSLET_INTF_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/Translet;"; + + public static final String ATTRIBUTES_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/Attributes;"; + public static final String NODE_ITERATOR_SIG + = "Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;"; + public static final String DOM_INTF_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/DOM;"; + public static final String DOM_IMPL_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/DOM"; // xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl"; + public static final String SAX_IMPL_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/DOM/SAXImpl"; + public static final String DOM_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl;"; //xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl;"; + public static final String SAX_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl;"; + public static final String DOM_ADAPTER_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter"; + public static final String DOM_ADAPTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter;"; + public static final String MULTI_DOM_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM"; + public static final String MULTI_DOM_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM;"; + + public static final String STRING + = "java.lang.String"; + + public static final int ACC_PUBLIC + = com.sun.org.apache.bcel.internal.Const.ACC_PUBLIC; + public static final int ACC_SUPER + = com.sun.org.apache.bcel.internal.Const.ACC_SUPER; + public static final int ACC_FINAL + = com.sun.org.apache.bcel.internal.Const.ACC_FINAL; + public static final int ACC_PRIVATE + = com.sun.org.apache.bcel.internal.Const.ACC_PRIVATE; + public static final int ACC_PROTECTED + = com.sun.org.apache.bcel.internal.Const.ACC_PROTECTED; + public static final int ACC_STATIC + = com.sun.org.apache.bcel.internal.Const.ACC_STATIC; + + public static final String MODULE_SIG + = "Ljava/lang/Module;"; + public static final String CLASS_SIG + = "Ljava/lang/Class;"; + public static final String STRING_SIG + = "Ljava/lang/String;"; + public static final String STRING_BUFFER_SIG + = "Ljava/lang/StringBuffer;"; + public static final String OBJECT_SIG + = "Ljava/lang/Object;"; + public static final String DOUBLE_SIG + = "Ljava/lang/Double;"; + public static final String INTEGER_SIG + = "Ljava/lang/Integer;"; + public static final String COLLATOR_CLASS + = "java/text/Collator"; + public static final String COLLATOR_SIG + = "Ljava/text/Collator;"; + + public static final String NODE + = "int"; + public static final String NODE_ITERATOR + = "com.sun.org.apache.xml.internal.dtm.DTMAxisIterator"; + public static final String NODE_ITERATOR_BASE + = "com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase"; + public static final String SORT_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator"; + public static final String SORT_ITERATOR_SIG + = "Lcom.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator;"; + public static final String NODE_SORT_RECORD + = "com.sun.org.apache.xalan.internal.xsltc.dom.NodeSortRecord"; + public static final String NODE_SORT_FACTORY + = "com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory"; + public static final String NODE_SORT_RECORD_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord;"; + public static final String NODE_SORT_FACTORY_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory;"; + public static final String LOCALE_CLASS + = "java.util.Locale"; + public static final String LOCALE_SIG + = "Ljava/util/Locale;"; + public static final String STRING_VALUE_HANDLER + = "com.sun.org.apache.xalan.internal.xsltc.runtime.StringValueHandler"; + public static final String STRING_VALUE_HANDLER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler;"; + public static final String OUTPUT_HANDLER + = "com/sun/org/apache/xml/internal/serializer/SerializationHandler"; + public static final String OUTPUT_HANDLER_SIG + = "Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;"; + public static final String FILTER_INTERFACE + = "com.sun.org.apache.xalan.internal.xsltc.dom.Filter"; + public static final String FILTER_INTERFACE_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/Filter;"; + public static final String UNION_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.UnionIterator"; + public static final String STEP_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator"; + public static final String CACHED_NODE_LIST_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.CachedNodeListIterator"; + public static final String NTH_ITERATOR_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.NthIterator"; + public static final String ABSOLUTE_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator"; + public static final String DUP_FILTERED_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.DupFilterIterator"; + public static final String CURRENT_NODE_LIST_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.CurrentNodeListIterator"; + public static final String CURRENT_NODE_LIST_FILTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.CurrentNodeListFilter"; + public static final String CURRENT_NODE_LIST_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListIterator;"; + public static final String CURRENT_NODE_LIST_FILTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/CurrentNodeListFilter;"; + public static final String FILTER_STEP_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.FilteredStepIterator"; + public static final String FILTER_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.FilterIterator"; + public static final String SINGLETON_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator"; + public static final String MATCHING_ITERATOR + = "com.sun.org.apache.xalan.internal.xsltc.dom.MatchingIterator"; + public static final String NODE_SIG + = "I"; + public static final String GET_PARENT + = "getParent"; + public static final String GET_PARENT_SIG + = "(" + NODE_SIG + ")" + NODE_SIG; + public static final String NEXT_SIG + = "()" + NODE_SIG; + public static final String NEXT + = "next"; + public static final String NEXTID + = "nextNodeID"; + public static final String MAKE_NODE + = "makeNode"; + public static final String MAKE_NODE_LIST + = "makeNodeList"; + public static final String GET_UNPARSED_ENTITY_URI + = "getUnparsedEntityURI"; + public static final String STRING_TO_REAL + = "stringToReal"; + public static final String STRING_TO_REAL_SIG + = "(" + STRING_SIG + ")D"; + public static final String STRING_TO_INT + = "stringToInt"; + public static final String STRING_TO_INT_SIG + = "(" + STRING_SIG + ")I"; + + public static final String XSLT_PACKAGE + = "com.sun.org.apache.xalan.internal.xsltc"; + public static final String COMPILER_PACKAGE + = XSLT_PACKAGE + ".compiler"; + public static final String RUNTIME_PACKAGE + = XSLT_PACKAGE + ".runtime"; + public static final String TRANSLET_CLASS + = RUNTIME_PACKAGE + ".AbstractTranslet"; + + public static final String TRANSLET_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet;"; + public static final String UNION_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/UnionIterator;"; + public static final String TRANSLET_OUTPUT_SIG + = "Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;"; + public static final String MAKE_NODE_SIG + = "(I)Lorg/w3c/dom/Node;"; + public static final String MAKE_NODE_SIG2 + = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/Node;"; + public static final String MAKE_NODE_LIST_SIG + = "(I)Lorg/w3c/dom/NodeList;"; + public static final String MAKE_NODE_LIST_SIG2 + = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/NodeList;"; + + public static final String STREAM_XML_OUTPUT + = "com.sun.org.apache.xml.internal.serializer.ToXMLStream"; + + public static final String OUTPUT_BASE + = "com.sun.org.apache.xml.internal.serializer.SerializerBase"; + + public static final String LOAD_DOCUMENT_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument"; + + public static final String KEY_INDEX_CLASS + = "com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex"; + public static final String KEY_INDEX_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex;"; + + public static final String KEY_INDEX_ITERATOR_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex$KeyIndexIterator;"; + public static final String DOM_INTF + = "com.sun.org.apache.xalan.internal.xsltc.DOM"; + public static final String DOM_IMPL + = "com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl"; + public static final String SAX_IMPL + = "com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl"; + public static final String CLASS_CLASS + = "java.lang.Class"; + public static final String MODULE_CLASS + = "java.lang.Module"; + public static final String STRING_CLASS + = "java.lang.String"; + public static final String OBJECT_CLASS + = "java.lang.Object"; + public static final String BOOLEAN_CLASS + = "java.lang.Boolean"; + public static final String STRING_BUFFER_CLASS + = "java.lang.StringBuffer"; + public static final String STRING_WRITER + = "java.io.StringWriter"; + public static final String WRITER_SIG + = "Ljava/io/Writer;"; + + public static final String TRANSLET_OUTPUT_BASE + = "com.sun.org.apache.xalan.internal.xsltc.TransletOutputBase"; + // output interface + public static final String TRANSLET_OUTPUT_INTERFACE + = "com.sun.org.apache.xml.internal.serializer.SerializationHandler"; + public static final String BASIS_LIBRARY_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary"; + public static final String ATTRIBUTE_LIST_IMPL_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.AttributeListImpl"; + public static final String DOUBLE_CLASS + = "java.lang.Double"; + public static final String INTEGER_CLASS + = "java.lang.Integer"; + public static final String RUNTIME_NODE_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.runtime.Node"; + public static final String MATH_CLASS + = "java.lang.Math"; + + public static final String BOOLEAN_VALUE + = "booleanValue"; + public static final String BOOLEAN_VALUE_SIG + = "()Z"; + public static final String INT_VALUE + = "intValue"; + public static final String INT_VALUE_SIG + = "()I"; + public static final String DOUBLE_VALUE + = "doubleValue"; + public static final String DOUBLE_VALUE_SIG + = "()D"; + + public static final String DOM_PNAME + = "dom"; + public static final String NODE_PNAME + = "node"; + public static final String TRANSLET_OUTPUT_PNAME + = "handler"; + public static final String ITERATOR_PNAME + = "iterator"; + public static final String DOCUMENT_PNAME + = "document"; + public static final String TRANSLET_PNAME + = "translet"; + + public static final String INVOKE_METHOD + = "invokeMethod"; + public static final String GET_NODE_NAME + = "getNodeNameX"; + public static final String CHARACTERSW + = "characters"; + public static final String GET_CHILDREN + = "getChildren"; + public static final String GET_TYPED_CHILDREN + = "getTypedChildren"; + public static final String CHARACTERS + = "characters"; + public static final String APPLY_TEMPLATES + = "applyTemplates"; + public static final String GET_NODE_TYPE + = "getNodeType"; + public static final String GET_NODE_VALUE + = "getStringValueX"; + public static final String GET_ELEMENT_VALUE + = "getElementValue"; + public static final String GET_ATTRIBUTE_VALUE + = "getAttributeValue"; + public static final String HAS_ATTRIBUTE + = "hasAttribute"; + public static final String ADD_ITERATOR + = "addIterator"; + public static final String SET_START_NODE + = "setStartNode"; + public static final String RESET + = "reset"; + public static final String GET_MODULE + = "getModule"; + public static final String FOR_NAME + = "forName"; + public static final String ADD_READS + = "addReads"; + + public static final String GET_MODULE_SIG + = "()" + MODULE_SIG; + public static final String FOR_NAME_SIG + = "(" + STRING_SIG + ")" + CLASS_SIG; + public static final String ADD_READS_SIG + = "(" + MODULE_SIG + ")" + MODULE_SIG; + + public static final String ATTR_SET_SIG + = "(" + DOM_INTF_SIG + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + "I)V"; + + public static final String GET_NODE_NAME_SIG + = "(" + NODE_SIG + ")" + STRING_SIG; + public static final String CHARACTERSW_SIG + = "(" + STRING_SIG + TRANSLET_OUTPUT_SIG + ")V"; + public static final String CHARACTERS_SIG + = "(" + NODE_SIG + TRANSLET_OUTPUT_SIG + ")V"; + public static final String GET_CHILDREN_SIG + = "(" + NODE_SIG + ")" + NODE_ITERATOR_SIG; + public static final String GET_TYPED_CHILDREN_SIG + = "(I)" + NODE_ITERATOR_SIG; + public static final String GET_NODE_TYPE_SIG + = "()S"; + public static final String GET_NODE_VALUE_SIG + = "(I)" + STRING_SIG; + public static final String GET_ELEMENT_VALUE_SIG + = "(I)" + STRING_SIG; + public static final String GET_ATTRIBUTE_VALUE_SIG + = "(II)" + STRING_SIG; + public static final String HAS_ATTRIBUTE_SIG + = "(II)Z"; + public static final String GET_ITERATOR_SIG + = "()" + NODE_ITERATOR_SIG; + + public static final String NAMES_INDEX + = "namesArray"; + public static final String NAMES_INDEX_SIG + = "[" + STRING_SIG; + public static final String URIS_INDEX + = "urisArray"; + public static final String URIS_INDEX_SIG + = "[" + STRING_SIG; + public static final String TYPES_INDEX + = "typesArray"; + public static final String TYPES_INDEX_SIG + = "[I"; + public static final String NAMESPACE_INDEX + = "namespaceArray"; + public static final String NAMESPACE_INDEX_SIG + = "[" + STRING_SIG; + public static final String HASIDCALL_INDEX + = "_hasIdCall"; + public static final String HASIDCALL_INDEX_SIG + = "Z"; + public static final String TRANSLET_VERSION_INDEX + = "transletVersion"; + public static final String TRANSLET_VERSION_INDEX_SIG + = "I"; + + public static final String DOM_FIELD + = "_dom"; + public static final String STATIC_NAMES_ARRAY_FIELD + = "_sNamesArray"; + public static final String STATIC_URIS_ARRAY_FIELD + = "_sUrisArray"; + public static final String STATIC_TYPES_ARRAY_FIELD + = "_sTypesArray"; + public static final String STATIC_NAMESPACE_ARRAY_FIELD + = "_sNamespaceArray"; + public static final String STATIC_CHAR_DATA_FIELD + = "_scharData"; + public static final String STATIC_CHAR_DATA_FIELD_SIG + = "[C"; + public static final String FORMAT_SYMBOLS_FIELD + = "format_symbols"; + + public static final String ITERATOR_FIELD_SIG + = NODE_ITERATOR_SIG; + public static final String NODE_FIELD + = "node"; + public static final String NODE_FIELD_SIG + = "I"; + + public static final String EMPTYATTR_FIELD + = "EmptyAttributes"; + public static final String ATTRIBUTE_LIST_FIELD + = "attributeList"; + public static final String CLEAR_ATTRIBUTES + = "clear"; + public static final String ADD_ATTRIBUTE + = "addAttribute"; + public static final String ATTRIBUTE_LIST_IMPL_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/runtime/AttributeListImpl;"; + public static final String CLEAR_ATTRIBUTES_SIG + = "()" + ATTRIBUTE_LIST_IMPL_SIG; + public static final String ADD_ATTRIBUTE_SIG + = "(" + STRING_SIG + STRING_SIG + ")" + ATTRIBUTE_LIST_IMPL_SIG; + + public static final String ADD_ITERATOR_SIG + = "(" + NODE_ITERATOR_SIG + ")" + UNION_ITERATOR_SIG; + + public static final String ORDER_ITERATOR + = "orderNodes"; + public static final String ORDER_ITERATOR_SIG + = "(" + NODE_ITERATOR_SIG + "I)" + NODE_ITERATOR_SIG; + + public static final String SET_START_NODE_SIG + = "(" + NODE_SIG + ")" + NODE_ITERATOR_SIG; + + public static final String NODE_COUNTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.NodeCounter"; + public static final String NODE_COUNTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter;"; + public static final String DEFAULT_NODE_COUNTER + = "com.sun.org.apache.xalan.internal.xsltc.dom.DefaultNodeCounter"; + public static final String DEFAULT_NODE_COUNTER_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/DefaultNodeCounter;"; + public static final String TRANSLET_FIELD + = "translet"; + public static final String TRANSLET_FIELD_SIG + = TRANSLET_SIG; + + public static final String RESET_SIG + = "()" + NODE_ITERATOR_SIG; + public static final String GET_PARAMETER + = "getParameter"; + public static final String ADD_PARAMETER + = "addParameter"; + public static final String PUSH_PARAM_FRAME + = "pushParamFrame"; + public static final String PUSH_PARAM_FRAME_SIG + = "()V"; + public static final String POP_PARAM_FRAME + = "popParamFrame"; + public static final String POP_PARAM_FRAME_SIG + = "()V"; + public static final String GET_PARAMETER_SIG + = "(" + STRING_SIG + ")" + OBJECT_SIG; + public static final String ADD_PARAMETER_SIG + = "(" + STRING_SIG + OBJECT_SIG + "Z)" + OBJECT_SIG; + + public static final String STRIP_SPACE + = "stripSpace"; + public static final String STRIP_SPACE_INTF + = "com/sun/org/apache/xalan/internal/xsltc/StripFilter"; + public static final String STRIP_SPACE_SIG + = "Lcom/sun/org/apache/xalan/internal/xsltc/StripFilter;"; + public static final String STRIP_SPACE_PARAMS + = "(Lcom/sun/org/apache/xalan/internal/xsltc/DOM;II)Z"; + + public static final String GET_NODE_VALUE_ITERATOR + = "getNodeValueIterator"; + public static final String GET_NODE_VALUE_ITERATOR_SIG + = "(" + NODE_ITERATOR_SIG + "I" + STRING_SIG + "Z)" + NODE_ITERATOR_SIG; + + public static final String GET_UNPARSED_ENTITY_URI_SIG + = "(" + STRING_SIG + ")" + STRING_SIG; + + public static final int POSITION_INDEX = 2; + public static final int LAST_INDEX = 3; + + public static final String XMLNS_PREFIX = "xmlns"; + public static final String XMLNS_STRING = "xmlns:"; + public static final String XMLNS_URI + = "http://www.w3.org/2000/xmlns/"; + public static final String XSLT_URI + = "http://www.w3.org/1999/XSL/Transform"; + public static final String XHTML_URI + = "http://www.w3.org/1999/xhtml"; + public static final String TRANSLET_URI + = "http://xml.apache.org/xalan/xsltc"; + public static final String REDIRECT_URI + = "http://xml.apache.org/xalan/redirect"; + public static final String FALLBACK_CLASS + = "com.sun.org.apache.xalan.internal.xsltc.compiler.Fallback"; + + public static final int RTF_INITIAL_SIZE = 32; + + // the API packages used by generated translet classes + public static String[] PKGS_USED_BY_TRANSLET_CLASSES = { + "com.sun.org.apache.xalan.internal.lib", + "com.sun.org.apache.xalan.internal.xsltc", + "com.sun.org.apache.xalan.internal.xsltc.runtime", + "com.sun.org.apache.xalan.internal.xsltc.dom", + "com.sun.org.apache.xml.internal.serializer", + "com.sun.org.apache.xml.internal.dtm", + "com.sun.org.apache.xml.internal.dtm.ref", + }; +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java new file mode 100644 index 0000000..490e343 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ContainsCall.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class ContainsCall extends FunctionCall { + + private Expression _base = null; + private Expression _token = null; + + /** + * Create a contains() call - two arguments, both strings + */ + public ContainsCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * This XPath function returns true/false values + */ + public boolean isBoolean() { + return true; + } + + /** + * Type check the two parameters for this function + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + + // Check that the function was passed exactly two arguments + if (argumentCount() != 2) { + throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this); + } + + // The first argument must be a String, or cast to a String + _base = argument(0); + Type baseType = _base.typeCheck(stable); + if (baseType != Type.String) + _base = new CastExpr(_base, Type.String); + + // The second argument must also be a String, or cast to a String + _token = argument(1); + Type tokenType = _token.typeCheck(stable); + if (tokenType != Type.String) + _token = new CastExpr(_token, Type.String); + + return _type = Type.Boolean; + } + + /** + * Compile the expression - leave boolean expression on stack + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + } + + /** + * Compile expression and update true/false-lists + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + _base.translate(classGen, methodGen); + _token.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS, + "indexOf", + "(" + STRING_SIG + ")I"))); + _falseList.add(il.append(new IFLT(null))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java new file mode 100644 index 0000000..2d79af4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Copy.java @@ -0,0 +1,157 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFNULL; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class Copy extends Instruction { + private UseAttributeSets _useSets; + + public void parseContents(Parser parser) { + final String useSets = getAttribute("use-attribute-sets"); + if (useSets.length() > 0) { + if (!Util.isValidQNames(useSets)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this); + parser.reportError(Constants.ERROR, err); + } + _useSets = new UseAttributeSets(useSets, parser); + } + parseChildren(parser); + } + + public void display(int indent) { + indent(indent); + Util.println("Copy"); + indent(indent + IndentIncrement); + displayContents(indent + IndentIncrement); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_useSets != null) { + _useSets.typeCheck(stable); + } + typeCheckContents(stable); + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final LocalVariableGen name = + methodGen.addLocalVariable2("name", + Util.getJCRefType(STRING_SIG), + null); + final LocalVariableGen length = + methodGen.addLocalVariable2("length", + Util.getJCRefType("I"), + null); + + // Get the name of the node to copy and save for later + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadHandler()); + final int cpy = cpg.addInterfaceMethodref(DOM_INTF, + "shallowCopy", + "(" + + NODE_SIG + + TRANSLET_OUTPUT_SIG + + ")" + STRING_SIG); + il.append(new INVOKEINTERFACE(cpy, 3)); + il.append(DUP); + name.setStart(il.append(new ASTORE(name.getIndex()))); + final BranchHandle ifBlock1 = il.append(new IFNULL(null)); + + // Get the length of the node name and save for later + il.append(new ALOAD(name.getIndex())); + final int lengthMethod = cpg.addMethodref(STRING_CLASS, "length", "()I"); + il.append(new INVOKEVIRTUAL(lengthMethod)); + il.append(DUP); + length.setStart(il.append(new ISTORE(length.getIndex()))); + + // Ignore attribute sets if current node is ROOT. DOM.shallowCopy() + // returns "" for ROOT, so skip attribute sets if length == 0 + final BranchHandle ifBlock4 = il.append(new IFEQ(null)); + + // Copy in attribute sets if specified + if (_useSets != null) { + // If the parent of this element will result in an element being + // output then we know that it is safe to copy out the attributes + final SyntaxTreeNode parent = getParent(); + if ((parent instanceof LiteralElement) || + (parent instanceof LiteralElement)) { + _useSets.translate(classGen, methodGen); + } + // If not we have to check to see if the copy will result in an + // element being output. + else { + // check if element; if not skip to translate body + il.append(new ILOAD(length.getIndex())); + final BranchHandle ifBlock2 = il.append(new IFEQ(null)); + // length != 0 -> element -> do attribute sets + _useSets.translate(classGen, methodGen); + // not an element; root + ifBlock2.setTarget(il.append(NOP)); + } + } + + // Instantiate body of xsl:copy + ifBlock4.setTarget(il.append(NOP)); + translateContents(classGen, methodGen); + + // Call the output handler's endElement() if we copied an element + // (The DOM.shallowCopy() method calls startElement().) + length.setEnd(il.append(new ILOAD(length.getIndex()))); + final BranchHandle ifBlock3 = il.append(new IFEQ(null)); + il.append(methodGen.loadHandler()); + name.setEnd(il.append(new ALOAD(name.getIndex()))); + il.append(methodGen.endElement()); + + final InstructionHandle end = il.append(NOP); + ifBlock1.setTarget(end); + ifBlock3.setTarget(end); + methodGen.removeLocalVariable(name); + methodGen.removeLocalVariable(length); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java new file mode 100644 index 0000000..bf7b973 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CopyOf.java @@ -0,0 +1,136 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class CopyOf extends Instruction { + private Expression _select; + + public void display(int indent) { + indent(indent); + Util.println("CopyOf"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + } + + public void parseContents(Parser parser) { + _select = parser.parseExpression(this, "select", null); + // make sure required attribute(s) have been set + if (_select.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select"); + return; + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tselect = _select.typeCheck(stable); + if (tselect instanceof NodeType || + tselect instanceof NodeSetType || + tselect instanceof ReferenceType || + tselect instanceof ResultTreeType) { + // falls through + } else { + _select = new CastExpr(_select, Type.String); + } + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final Type tselect = _select.getType(); + + final String CPY1_SIG = "(" + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + ")V"; + final int cpy1 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY1_SIG); + + final String CPY2_SIG = "(" + NODE_SIG + TRANSLET_OUTPUT_SIG + ")V"; + final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG); + + final String getDoc_SIG = "()" + NODE_SIG; + final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument", getDoc_SIG); + + + if (tselect instanceof NodeSetType) { + il.append(methodGen.loadDOM()); + + // push NodeIterator + _select.translate(classGen, methodGen); + _select.startIterator(classGen, methodGen); + + // call copy from the DOM 'library' + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy1, 3)); + } else if (tselect instanceof NodeType) { + il.append(methodGen.loadDOM()); + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy2, 3)); + } else if (tselect instanceof ResultTreeType) { + _select.translate(classGen, methodGen); + // We want the whole tree, so we start with the root node + il.append(DUP); //need a pointer to the DOM ; + il.append(new INVOKEINTERFACE(getDoc, 1)); //ICONST_0); + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE(cpy2, 3)); + } else if (tselect instanceof ReferenceType) { + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadDOM()); + final int copy = cpg.addMethodref(BASIS_LIBRARY_CLASS, "copy", + "(" + + OBJECT_SIG + + TRANSLET_OUTPUT_SIG + + NODE_SIG + + DOM_INTF_SIG + + ")V"); + il.append(new INVOKESTATIC(copy)); + } else { + il.append(classGen.loadTranslet()); + _select.translate(classGen, methodGen); + il.append(methodGen.loadHandler()); + il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, + CHARACTERSW, + CHARACTERSW_SIG))); + } + + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java new file mode 100644 index 0000000..9cdae02 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/CurrentCall.java @@ -0,0 +1,39 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class CurrentCall extends FunctionCall { + public CurrentCall(QName fname) { + super(fname); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + methodGen.getInstructionList().append(methodGen.loadCurrentNode()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java new file mode 100644 index 0000000..6ba7fc7 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DecimalFormatting.java @@ -0,0 +1,245 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETSTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class DecimalFormatting extends TopLevelElement { + + private static final String DFS_CLASS = "java.text.DecimalFormatSymbols"; + private static final String DFS_SIG = "Ljava/text/DecimalFormatSymbols;"; + + private QName _name = null; + + /** + * Creates the default, nameless, DecimalFormat object in + * AbstractTranslet's format_symbols hashtable. + * This should be called for every stylesheet, and the entry + * may be overridden by later nameless xsl:decimal-format instructions. + */ + public static void translateDefaultDFS(ClassGenerator classGen, + MethodGenerator methodGen) { + + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + final int init = cpg.addMethodref(DFS_CLASS, "", + "(" + LOCALE_SIG + ")V"); + + // Push the format name, which is empty, on the stack + // for call to addDecimalFormat() + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, EMPTYSTRING)); + + // Manufacture a DecimalFormatSymbols on the stack for + // call to addDecimalFormat(). Use the US Locale as the + // default, as most of its settings are equivalent to + // the default settings required of xsl:decimal-format - + // except for the NaN and infinity attributes. + il.append(new NEW(cpg.addClass(DFS_CLASS))); + il.append(DUP); + il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", + LOCALE_SIG))); + il.append(new INVOKESPECIAL(init)); + + int nan = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "NaN")); + il.append(new INVOKEVIRTUAL(nan)); + + int inf = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "Infinity")); + il.append(new INVOKEVIRTUAL(inf)); + + final int put = cpg.addMethodref(TRANSLET_CLASS, + "addDecimalFormat", + "(" + STRING_SIG + DFS_SIG + ")V"); + il.append(new INVOKEVIRTUAL(put)); + } + + /** + * No type check needed for the element + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + /** + * Parse the name of the element + */ + public void parseContents(Parser parser) { + // Get the name of these decimal formatting symbols + final String name = getAttribute("name"); + if (name.length() > 0) { + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + } + _name = parser.getQNameIgnoreDefaultNs(name); + if (_name == null) { + _name = parser.getQNameIgnoreDefaultNs(EMPTYSTRING); + } + + // Check if a set of symbols has already been registered under this name + SymbolTable stable = parser.getSymbolTable(); + if (stable.getDecimalFormatting(_name) != null) { + reportWarning(this, parser, ErrorMsg.SYMBOLS_REDEF_ERR, + _name.toString()); + } else { + stable.addDecimalFormatting(_name, this); + } + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + + // DecimalFormatSymbols.(Locale); + // xsl:decimal-format - except for the NaN and infinity attributes. + final int init = cpg.addMethodref(DFS_CLASS, "", + "(" + LOCALE_SIG + ")V"); + + // Push the format name on the stack for call to addDecimalFormat() + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, _name.toString())); + + // Manufacture a DecimalFormatSymbols on the stack + // for call to addDecimalFormat() + // Use the US Locale as the default, as most of its settings + // are equivalent to the default settings required of + il.append(new NEW(cpg.addClass(DFS_CLASS))); + il.append(DUP); + il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US", + LOCALE_SIG))); + il.append(new INVOKESPECIAL(init)); + + String tmp = getAttribute("NaN"); + if ((tmp == null) || (tmp.equals(EMPTYSTRING))) { + int nan = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "NaN")); + il.append(new INVOKEVIRTUAL(nan)); + } + + tmp = getAttribute("infinity"); + if ((tmp == null) || (tmp.equals(EMPTYSTRING))) { + int inf = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, "Infinity")); + il.append(new INVOKEVIRTUAL(inf)); + } + + final int nAttributes = _attributes.getLength(); + for (int i = 0; i < nAttributes; i++) { + final String name = _attributes.getQName(i); + final String value = _attributes.getValue(i); + + boolean valid = true; + int method = 0; + + if (name.equals("decimal-separator")) { + // DecimalFormatSymbols.setDecimalSeparator(); + method = cpg.addMethodref(DFS_CLASS, + "setDecimalSeparator", "(C)V"); + } else if (name.equals("grouping-separator")) { + method = cpg.addMethodref(DFS_CLASS, + "setGroupingSeparator", "(C)V"); + } else if (name.equals("minus-sign")) { + method = cpg.addMethodref(DFS_CLASS, + "setMinusSign", "(C)V"); + } else if (name.equals("percent")) { + method = cpg.addMethodref(DFS_CLASS, + "setPercent", "(C)V"); + } else if (name.equals("per-mille")) { + method = cpg.addMethodref(DFS_CLASS, + "setPerMill", "(C)V"); + } else if (name.equals("zero-digit")) { + method = cpg.addMethodref(DFS_CLASS, + "setZeroDigit", "(C)V"); + } else if (name.equals("digit")) { + method = cpg.addMethodref(DFS_CLASS, + "setDigit", "(C)V"); + } else if (name.equals("pattern-separator")) { + method = cpg.addMethodref(DFS_CLASS, + "setPatternSeparator", "(C)V"); + } else if (name.equals("NaN")) { + method = cpg.addMethodref(DFS_CLASS, + "setNaN", "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, value)); + il.append(new INVOKEVIRTUAL(method)); + valid = false; + } else if (name.equals("infinity")) { + method = cpg.addMethodref(DFS_CLASS, + "setInfinity", + "(Ljava/lang/String;)V"); + il.append(DUP); + il.append(new PUSH(cpg, value)); + il.append(new INVOKEVIRTUAL(method)); + valid = false; + } else { + valid = false; + } + + if (valid) { + il.append(DUP); + il.append(new PUSH(cpg, value.charAt(0))); + il.append(new INVOKEVIRTUAL(method)); + } + + } + + final int put = cpg.addMethodref(TRANSLET_CLASS, + "addDecimalFormat", + "(" + STRING_SIG + DFS_SIG + ")V"); + il.append(new INVOKEVIRTUAL(put)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java new file mode 100644 index 0000000..0e001c1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GETFIELD; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class DocumentCall extends FunctionCall { + + private Expression _arg1 = null; + private Expression _arg2 = null; + private Type _arg1Type; + + /** + * Default function call constructor + */ + public DocumentCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Type checks the arguments passed to the document() function. The first + * argument can be any type (we must cast it to a string) and contains the + * URI of the document + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // At least one argument - two at most + final int ac = argumentCount(); + if ((ac < 1) || (ac > 2)) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this); + throw new TypeCheckError(msg); + } + if (getStylesheet() == null) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + // Parse the first argument + _arg1 = argument(0); + + if (_arg1 == null) {// should not happened + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + _arg1Type = _arg1.typeCheck(stable); + if ((_arg1Type != Type.NodeSet) && (_arg1Type != Type.String)) { + _arg1 = new CastExpr(_arg1, Type.String); + } + + // Parse the second argument + if (ac == 2) { + _arg2 = argument(1); + + if (_arg2 == null) {// should not happened + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + + final Type arg2Type = _arg2.typeCheck(stable); + + if (arg2Type.identicalTo(Type.Node)) { + _arg2 = new CastExpr(_arg2, Type.NodeSet); + } else if (arg2Type.identicalTo(Type.NodeSet)) { + // falls through + } else { + ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this); + throw new TypeCheckError(msg); + } + } + + return _type = Type.NodeSet; + } + + /** + * Translates the document() function call to a call to LoadDocument()'s + * static method document(). + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int ac = argumentCount(); + + final int domField = cpg.addFieldref(classGen.getClassName(), + DOM_FIELD, + DOM_INTF_SIG); + + String docParamList = null; + if (ac == 1) { + // documentF(Object,String,AbstractTranslet,DOM) + docParamList = "(" + OBJECT_SIG + STRING_SIG + TRANSLET_SIG + DOM_INTF_SIG + + ")" + NODE_ITERATOR_SIG; + } else { //ac == 2; ac < 1 or as >2 was tested in typeChec() + // documentF(Object,DTMAxisIterator,String,AbstractTranslet,DOM) + docParamList = "(" + OBJECT_SIG + NODE_ITERATOR_SIG + STRING_SIG + + TRANSLET_SIG + DOM_INTF_SIG + ")" + NODE_ITERATOR_SIG; + } + final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS, "documentF", + docParamList); + + + // The URI can be either a node-set or something else cast to a string + _arg1.translate(classGen, methodGen); + if (_arg1Type == Type.NodeSet) { + _arg1.startIterator(classGen, methodGen); + } + + if (ac == 2) { + //_arg2 == null was tested in typeChec() + _arg2.translate(classGen, methodGen); + _arg2.startIterator(classGen, methodGen); + } + + // Feck the rest of the parameters on the stack + il.append(new PUSH(cpg, getStylesheet().getSystemId())); + il.append(classGen.loadTranslet()); + il.append(DUP); + il.append(new GETFIELD(domField)); + il.append(new INVOKESTATIC(docIdx)); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java new file mode 100644 index 0000000..e99938d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ElementAvailableCall.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class ElementAvailableCall extends FunctionCall { + + public ElementAvailableCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * Force the argument to this function to be a literal string. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (argument() instanceof LiteralExpr) { + return _type = Type.Boolean; + } + ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + "element-available", this); + throw new TypeCheckError(err); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return getResult() ? Boolean.TRUE : Boolean.FALSE; + } + + /** + * Returns the result that this function will return + */ + public boolean getResult() { + try { + final LiteralExpr arg = (LiteralExpr) argument(); + final String qname = arg.getValue(); + final int index = qname.indexOf(':'); + final String localName = (index > 0) ? + qname.substring(index + 1) : qname; + return getParser().elementSupported(arg.getNamespace(), + localName); + } catch (ClassCastException e) { + return false; + } + } + + /** + * Calls to 'element-available' are resolved at compile time since + * the namespaces declared in the stylsheet are not available at run + * time. Consequently, arguments to this function must be literals. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final boolean result = getResult(); + methodGen.getInstructionList().append(new PUSH(cpg, result)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java new file mode 100644 index 0000000..13cd23a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/EqualityExpr.java @@ -0,0 +1,347 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.BranchInstruction; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFNE; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPEQ; +import com.sun.org.apache.bcel.internal.generic.IF_ICMPNE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NumberType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.runtime.Operators; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + */ +final class EqualityExpr extends Expression { + + private final int _op; + private Expression _left; + private Expression _right; + + public EqualityExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + public String toString() { + return Operators.getOpNames(_op) + '(' + _left + ", " + _right + ')'; + } + + public Expression getLeft() { + return _left; + } + + public Expression getRight() { + return _right; + } + + public boolean getOp() { + return (_op != Operators.NE); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + if (_left.hasPositionCall()) return true; + if (_right.hasPositionCall()) return true; + return false; + } + + public boolean hasLastCall() { + if (_left.hasLastCall()) return true; + if (_right.hasLastCall()) return true; + return false; + } + + private void swapArguments() { + final Expression temp = _left; + _left = _right; + _right = temp; + } + + /** + * Typing rules: see XSLT Reference by M. Kay page 345. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type tleft = _left.typeCheck(stable); + final Type tright = _right.typeCheck(stable); + + if (tleft.isSimple() && tright.isSimple()) { + if (tleft != tright) { + if (tleft instanceof BooleanType) { + _right = new CastExpr(_right, Type.Boolean); + } else if (tright instanceof BooleanType) { + _left = new CastExpr(_left, Type.Boolean); + } else if (tleft instanceof NumberType || + tright instanceof NumberType) { + _left = new CastExpr(_left, Type.Real); + _right = new CastExpr(_right, Type.Real); + } else { // both compared as strings + _left = new CastExpr(_left, Type.String); + _right = new CastExpr(_right, Type.String); + } + } + } else if (tleft instanceof ReferenceType) { + _right = new CastExpr(_right, Type.Reference); + } else if (tright instanceof ReferenceType) { + _left = new CastExpr(_left, Type.Reference); + } + // the following 2 cases optimize @attr|.|.. = 'string' + else if (tleft instanceof NodeType && tright == Type.String) { + _left = new CastExpr(_left, Type.String); + } else if (tleft == Type.String && tright instanceof NodeType) { + _right = new CastExpr(_right, Type.String); + } + // optimize node/node + else if (tleft instanceof NodeType && tright instanceof NodeType) { + _left = new CastExpr(_left, Type.String); + _right = new CastExpr(_right, Type.String); + } else if (tleft instanceof NodeType && tright instanceof NodeSetType) { + // compare(Node, NodeSet) will be invoked + } else if (tleft instanceof NodeSetType && tright instanceof NodeType) { + swapArguments(); // for compare(Node, NodeSet) + } else { + // At least one argument is of type node, node-set or result-tree + + // Promote an expression of type node to node-set + if (tleft instanceof NodeType) { + _left = new CastExpr(_left, Type.NodeSet); + } + if (tright instanceof NodeType) { + _right = new CastExpr(_right, Type.NodeSet); + } + + // If one arg is a node-set then make it the left one + if (tleft.isSimple() || + tleft instanceof ResultTreeType && + tright instanceof NodeSetType) { + swapArguments(); + } + + // Promote integers to doubles to have fewer compares + if (_right.getType() instanceof IntType) { + _right = new CastExpr(_right, Type.Real); + } + } + return _type = Type.Boolean; + } + + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + final Type tleft = _left.getType(); + final InstructionList il = methodGen.getInstructionList(); + + if (tleft instanceof BooleanType) { + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction) new IF_ICMPNE(null) : + (BranchInstruction) new IF_ICMPEQ(null))); + } else if (tleft instanceof NumberType) { + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + + if (tleft instanceof RealType) { + il.append(DCMPG); + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction) new IFNE(null) : + (BranchInstruction) new IFEQ(null))); + } else { + _falseList.add(il.append(_op == Operators.EQ ? + (BranchInstruction) new IF_ICMPNE(null) : + (BranchInstruction) new IF_ICMPEQ(null))); + } + } else { + translate(classGen, methodGen); + desynthesize(classGen, methodGen); + } + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final Type tleft = _left.getType(); + Type tright = _right.getType(); + + if (tleft instanceof BooleanType || tleft instanceof NumberType) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + return; + } + + if (tleft instanceof StringType) { + final int equals = cpg.addMethodref(STRING_CLASS, + "equals", + "(" + OBJECT_SIG + ")Z"); + _left.translate(classGen, methodGen); + _right.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(equals)); + + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + BranchHandle truec, falsec; + + if (tleft instanceof ResultTreeType) { + if (tright instanceof BooleanType) { + _right.translate(classGen, methodGen); + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tright instanceof RealType) { + _left.translate(classGen, methodGen); + tleft.translateTo(classGen, methodGen, Type.Real); + _right.translate(classGen, methodGen); + + il.append(DCMPG); + falsec = il.append(_op == Operators.EQ ? + (BranchInstruction) new IFNE(null) : + (BranchInstruction) new IFEQ(null)); + il.append(ICONST_1); + truec = il.append(new GOTO(null)); + falsec.setTarget(il.append(ICONST_0)); + truec.setTarget(il.append(NOP)); + return; + } + + // Next, result-tree/string and result-tree/result-tree comparisons + + _left.translate(classGen, methodGen); + tleft.translateTo(classGen, methodGen, Type.String); + _right.translate(classGen, methodGen); + + if (tright instanceof ResultTreeType) { + tright.translateTo(classGen, methodGen, Type.String); + } + + final int equals = cpg.addMethodref(STRING_CLASS, + "equals", + "(" + OBJECT_SIG + ")Z"); + il.append(new INVOKEVIRTUAL(equals)); + + if (_op == Operators.NE) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tleft instanceof NodeSetType && tright instanceof BooleanType) { + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); + Type.NodeSet.translateTo(classGen, methodGen, Type.Boolean); + _right.translate(classGen, methodGen); + + il.append(IXOR); // x != y <-> x xor y + if (_op == Operators.EQ) { + il.append(ICONST_1); + il.append(IXOR); // not x <-> x xor 1 + } + return; + } + + if (tleft instanceof NodeSetType && tright instanceof StringType) { + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); // needed ? + _right.translate(classGen, methodGen); + il.append(new PUSH(cpg, _op)); + il.append(methodGen.loadDOM()); + final int cmp = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "compare", + "(" + + tleft.toSignature() + + tright.toSignature() + + "I" + + DOM_INTF_SIG + + ")Z"); + il.append(new INVOKESTATIC(cmp)); + return; + } + + // Next, node-set/t for t in {real, string, node-set, result-tree} + _left.translate(classGen, methodGen); + _left.startIterator(classGen, methodGen); + _right.translate(classGen, methodGen); + _right.startIterator(classGen, methodGen); + + // Cast a result tree to a string to use an existing compare + if (tright instanceof ResultTreeType) { + tright.translateTo(classGen, methodGen, Type.String); + tright = Type.String; + } + + // Call the appropriate compare() from the BasisLibrary + il.append(new PUSH(cpg, _op)); + il.append(methodGen.loadDOM()); + + final int compare = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "compare", + "(" + + tleft.toSignature() + + tright.toSignature() + + "I" + + DOM_INTF_SIG + + ")Z"); + il.append(new INVOKESTATIC(compare)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java new file mode 100644 index 0000000..f69a1e3 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Expression.java @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @LastModified: Oct 2017 + */ +abstract class Expression extends SyntaxTreeNode { + /** + * The type of this expression. It is set after calling + * typeCheck(). + */ + protected Type _type; + + /** + * Instruction handles that comprise the true list. + */ + protected FlowList _trueList = new FlowList(); + + /** + * Instruction handles that comprise the false list. + */ + protected FlowList _falseList = new FlowList(); + + public Type getType() { + return _type; + } + + public abstract String toString(); + + public boolean hasPositionCall() { + return false; // default should be 'false' for StepPattern + } + + public boolean hasLastCall() { + return false; + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return null; + } + + /** + * Type check all the children of this node. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return typeCheckContents(stable); + } + + /** + * Translate this node into JVM bytecodes. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR, + getClass(), this); + getParser().reportError(FATAL, msg); + } + + /** + * Translate this node into a fresh instruction list. + * The original instruction list is saved and restored. + */ + public final InstructionList compile(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList result, save = methodGen.getInstructionList(); + methodGen.setInstructionList(result = new InstructionList()); + translate(classGen, methodGen); + methodGen.setInstructionList(save); + return result; + } + + /** + * Redefined by expressions of type boolean that use flow lists. + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + translate(classGen, methodGen); + if (_type instanceof BooleanType) { + desynthesize(classGen, methodGen); + } + } + + /** + * If this expression is of type node-set and it is not a variable + * reference, then call setStartNode() passing the context node. + */ + public void startIterator(ClassGenerator classGen, + MethodGenerator methodGen) { + // Ignore if type is not node-set + if (_type instanceof NodeSetType == false) { + return; + } + + // setStartNode() should not be called if expr is a variable ref + Expression expr = this; + if (expr instanceof CastExpr) { + expr = ((CastExpr) expr).getExpr(); + } + if (expr instanceof VariableRefBase == false) { + final InstructionList il = methodGen.getInstructionList(); + il.append(methodGen.loadContextNode()); + il.append(methodGen.setStartNode()); + } + } + + /** + * Synthesize a boolean expression, i.e., either push a 0 or 1 onto the + * operand stack for the next statement to succeed. Returns the handle + * of the instruction to be backpatched. + */ + public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + _trueList.backPatch(il.append(ICONST_1)); + final BranchHandle truec = il.append(new GOTO_W(null)); + _falseList.backPatch(il.append(ICONST_0)); + truec.setTarget(il.append(NOP)); + } + + public void desynthesize(ClassGenerator classGen, + MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + _falseList.add(il.append(new IFEQ(null))); + } + + public FlowList getFalseList() { + return _falseList; + } + + public FlowList getTrueList() { + return _trueList; + } + + public void backPatchFalseList(InstructionHandle ih) { + _falseList.backPatch(ih); + } + + public void backPatchTrueList(InstructionHandle ih) { + _trueList.backPatch(ih); + } + + /** + * Search for a primop in the symbol table that matches the method type + * ctype. Two methods match if they have the same arity. + * If a primop is overloaded then the "closest match" is returned. The + * first entry in the vector of primops that has the right arity is + * considered to be the default one. + */ + public MethodType lookupPrimop(SymbolTable stable, String op, + MethodType ctype) { + MethodType result = null; + final List primop = stable.lookupPrimop(op); + if (primop != null) { + final int n = primop.size(); + int minDistance = Integer.MAX_VALUE; + for (int i = 0; i < n; i++) { + final MethodType ptype = primop.get(i); + // Skip if different arity + if (ptype.argsCount() != ctype.argsCount()) { + continue; + } + + // The first method with the right arity is the default + if (result == null) { + result = ptype; // default method + } + + // Check if better than last one found + final int distance = ctype.distanceTo(ptype); + if (distance < minDistance) { + minDistance = distance; + result = ptype; + } + } + } + return result; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java new file mode 100644 index 0000000..154711c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Fallback.java @@ -0,0 +1,78 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Morten Jorgensen + */ +final class Fallback extends Instruction { + + private boolean _active = false; + + /** + * This element never produces any data on the stack + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_active) { + return (typeCheckContents(stable)); + } else { + return Type.Void; + } + } + + /** + * Activate this fallback element + */ + public void activate() { + _active = true; + } + + public String toString() { + return ("fallback"); + } + + /** + * Parse contents only if this fallback element is put in place of + * some unsupported element or non-XSLTC extension element + */ + public void parseContents(Parser parser) { + if (_active) parseChildren(parser); + } + + /** + * Translate contents only if this fallback element is put in place of + * some unsupported element or non-XSLTC extension element + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + if (_active) translateContents(classGen, methodGen); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java new file mode 100644 index 0000000..3d5e465 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +class FilterExpr extends Expression { + + /** + * Primary expression of this filter. I.e., 'e' in '(e)[p1]...[pn]'. + */ + private Expression _primary; + + /** + * Array of predicates in '(e)[p1]...[pn]'. + */ + private final List _predicates; + + public FilterExpr(Expression primary, List predicates) { + _primary = primary; + _predicates = predicates; + primary.setParent(this); + } + + protected Expression getExpr() { + if (_primary instanceof CastExpr) + return ((CastExpr) _primary).getExpr(); + else + return _primary; + } + + public void setParser(Parser parser) { + super.setParser(parser); + _primary.setParser(parser); + if (_predicates != null) { + final int n = _predicates.size(); + for (int i = 0; i < n; i++) { + final Expression exp = _predicates.get(i); + exp.setParser(parser); + exp.setParent(this); + } + } + } + + public String toString() { + return "filter-expr(" + _primary + ", " + _predicates + ")"; + } + + /** + * Type check a FilterParentPath. If the filter is not a node-set add a + * cast to node-set only if it is of reference type. This type coercion + * is needed for expressions like $x where $x is a parameter reference. + * All optimizations are turned off before type checking underlying + * predicates. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + Type ptype = _primary.typeCheck(stable); + boolean canOptimize = _primary instanceof KeyCall; + + if (ptype instanceof NodeSetType == false) { + if (ptype instanceof ReferenceType) { + _primary = new CastExpr(_primary, Type.NodeSet); + } else { + throw new TypeCheckError(this); + } + } + + // Type check predicates and turn all optimizations off if appropriate + int n = _predicates.size(); + for (int i = 0; i < n; i++) { + Predicate pred = (Predicate) _predicates.get(i); + + if (!canOptimize) { + pred.dontOptimize(); + } + pred.typeCheck(stable); + } + return _type = Type.NodeSet; + } + + /** + * Translate a filter expression by pushing the appropriate iterator + * onto the stack. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateFilterExpr(classGen, methodGen, _predicates == null ? -1 : _predicates.size() - 1); + } + + private void translateFilterExpr(ClassGenerator classGen, + MethodGenerator methodGen, + int predicateIndex) { + if (predicateIndex >= 0) { + translatePredicates(classGen, methodGen, predicateIndex); + } else { + _primary.translate(classGen, methodGen); + } + } + + /** + * Translate a sequence of predicates. Each predicate is translated + * by constructing an instance of CurrentNodeListIterator + * which is initialized from another iterator (recursive call), a + * filter and a closure (call to translate on the predicate) and "this". + */ + public void translatePredicates(ClassGenerator classGen, + MethodGenerator methodGen, + int predicateIndex) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // If not predicates left, translate primary expression + if (predicateIndex < 0) { + translateFilterExpr(classGen, methodGen, predicateIndex); + } else { + // Get the next predicate to be translated + Predicate predicate = (Predicate) _predicates.get(predicateIndex--); + + // Translate the rest of the predicates from right to left + translatePredicates(classGen, methodGen, predicateIndex); + + if (predicate.isNthPositionFilter()) { + int nthIteratorIdx = cpg.addMethodref(NTH_ITERATOR_CLASS, + "", + "(" + NODE_ITERATOR_SIG + "I)V"); + + // Backwards branches are prohibited if an uninitialized object + // is on the stack by section 4.9.4 of the JVM Specification, + // 2nd Ed. We don't know whether this code might contain + // backwards branches, so we mustn't create the new object unti + + // after we've created the suspect arguments to its constructor + + // Instead we calculate the values of the arguments to the + // constructor first, store them in temporary variables, create + // the object and reload the arguments from the temporaries to + // avoid the problem. + LocalVariableGen iteratorTemp + = methodGen.addLocalVariable("filter_expr_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + iteratorTemp.setStart( + il.append(new ASTORE(iteratorTemp.getIndex()))); + + predicate.translate(classGen, methodGen); + LocalVariableGen predicateValueTemp + = methodGen.addLocalVariable("filter_expr_tmp2", + Util.getJCRefType("I"), + null, null); + predicateValueTemp.setStart( + il.append(new ISTORE(predicateValueTemp.getIndex()))); + + il.append(new NEW(cpg.addClass(NTH_ITERATOR_CLASS))); + il.append(DUP); + iteratorTemp.setEnd( + il.append(new ALOAD(iteratorTemp.getIndex()))); + predicateValueTemp.setEnd( + il.append(new ILOAD(predicateValueTemp.getIndex()))); + il.append(new INVOKESPECIAL(nthIteratorIdx)); + } else { + // Translate predicates from right to left + final int initCNLI = cpg.addMethodref(CURRENT_NODE_LIST_ITERATOR, + "", + "(" + NODE_ITERATOR_SIG + "Z" + + CURRENT_NODE_LIST_FILTER_SIG + + NODE_SIG + TRANSLET_SIG + ")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + + LocalVariableGen nodeIteratorTemp = + methodGen.addLocalVariable("filter_expr_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + nodeIteratorTemp.setStart( + il.append(new ASTORE(nodeIteratorTemp.getIndex()))); + + predicate.translate(classGen, methodGen); + LocalVariableGen filterTemp = + methodGen.addLocalVariable("filter_expr_tmp2", + Util.getJCRefType(CURRENT_NODE_LIST_FILTER_SIG), + null, null); + filterTemp.setStart(il.append(new ASTORE(filterTemp.getIndex()))); + + // Create a CurrentNodeListIterator + il.append(new NEW(cpg.addClass(CURRENT_NODE_LIST_ITERATOR))); + il.append(DUP); + + // Initialize CurrentNodeListIterator + nodeIteratorTemp.setEnd( + il.append(new ALOAD(nodeIteratorTemp.getIndex()))); + il.append(ICONST_1); + filterTemp.setEnd(il.append(new ALOAD(filterTemp.getIndex()))); + il.append(methodGen.loadCurrentNode()); + il.append(classGen.loadTranslet()); + il.append(new INVOKESPECIAL(initCNLI)); + } + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java new file mode 100644 index 0000000..66c2bbe --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterParentPath.java @@ -0,0 +1,173 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class FilterParentPath extends Expression { + + private Expression _filterExpr; + private Expression _path; + private boolean _hasDescendantAxis = false; + + public FilterParentPath(Expression filterExpr, Expression path) { + (_path = path).setParent(this); + (_filterExpr = filterExpr).setParent(this); + } + + public void setParser(Parser parser) { + super.setParser(parser); + _filterExpr.setParser(parser); + _path.setParser(parser); + } + + public String toString() { + return "FilterParentPath(" + _filterExpr + ", " + _path + ')'; + } + + public void setDescendantAxis() { + _hasDescendantAxis = true; + } + + /** + * Type check a FilterParentPath. If the filter is not a node-set add a + * cast to node-set only if it is of reference type. This type coercion is + * needed for expressions like $x/LINE where $x is a parameter reference. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type ftype = _filterExpr.typeCheck(stable); + if (ftype instanceof NodeSetType == false) { + if (ftype instanceof ReferenceType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } + /* + else if (ftype instanceof ResultTreeType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } + */ + else if (ftype instanceof NodeType) { + _filterExpr = new CastExpr(_filterExpr, Type.NodeSet); + } else { + throw new TypeCheckError(this); + } + } + + // Wrap single node path in a node set + final Type ptype = _path.typeCheck(stable); + if (!(ptype instanceof NodeSetType)) { + _path = new CastExpr(_path, Type.NodeSet); + } + + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + // Create new StepIterator + final int initSI = cpg.addMethodref(STEP_ITERATOR_CLASS, + "", + "(" + + NODE_ITERATOR_SIG + + NODE_ITERATOR_SIG + + ")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + // Recursively compile 2 iterators + _filterExpr.translate(classGen, methodGen); + LocalVariableGen filterTemp = + methodGen.addLocalVariable("filter_parent_path_tmp1", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + filterTemp.setStart(il.append(new ASTORE(filterTemp.getIndex()))); + + _path.translate(classGen, methodGen); + LocalVariableGen pathTemp = + methodGen.addLocalVariable("filter_parent_path_tmp2", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex()))); + + il.append(new NEW(cpg.addClass(STEP_ITERATOR_CLASS))); + il.append(DUP); + filterTemp.setEnd(il.append(new ALOAD(filterTemp.getIndex()))); + pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex()))); + + // Initialize StepIterator with iterators from the stack + il.append(new INVOKESPECIAL(initSI)); + + // This is a special case for the //* path with or without predicates + if (_hasDescendantAxis) { + final int incl = cpg.addMethodref(NODE_ITERATOR_BASE, + "includeSelf", + "()" + NODE_ITERATOR_SIG); + il.append(new INVOKEVIRTUAL(incl)); + } + + SyntaxTreeNode parent = getParent(); + + boolean parentAlreadyOrdered = + (parent instanceof RelativeLocationPath) + || (parent instanceof FilterParentPath) + || (parent instanceof KeyCall) + || (parent instanceof CurrentCall) + || (parent instanceof DocumentCall); + + if (!parentAlreadyOrdered) { + final int order = cpg.addInterfaceMethodref(DOM_INTF, + ORDER_ITERATOR, + ORDER_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(SWAP); + il.append(methodGen.loadContextNode()); + il.append(new INVOKEINTERFACE(order, 3)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java new file mode 100644 index 0000000..878d207 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FilteredAbsoluteLocationPath.java @@ -0,0 +1,124 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ALOAD; +import com.sun.org.apache.bcel.internal.generic.ASTORE; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author G. Todd Miller + */ +final class FilteredAbsoluteLocationPath extends Expression { + private Expression _path; // may be null + + public FilteredAbsoluteLocationPath() { + _path = null; + } + + public FilteredAbsoluteLocationPath(Expression path) { + _path = path; + if (path != null) { + _path.setParent(this); + } + } + + public void setParser(Parser parser) { + super.setParser(parser); + if (_path != null) { + _path.setParser(parser); + } + } + + public Expression getPath() { + return (_path); + } + + public String toString() { + return "FilteredAbsoluteLocationPath(" + + (_path != null ? _path.toString() : "null") + ')'; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_path != null) { + final Type ptype = _path.typeCheck(stable); + if (ptype instanceof NodeType) { // promote to node-set + _path = new CastExpr(_path, Type.NodeSet); + } + } + return _type = Type.NodeSet; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + if (_path != null) { + final int initDFI = cpg.addMethodref(DUP_FILTERED_ITERATOR, + "", + "(" + + NODE_ITERATOR_SIG + + ")V"); + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches, + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + // Compile relative path iterator(s) + LocalVariableGen pathTemp = + methodGen.addLocalVariable("filtered_absolute_location_path_tmp", + Util.getJCRefType(NODE_ITERATOR_SIG), + null, null); + _path.translate(classGen, methodGen); + pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex()))); + + // Create new Dup Filter Iterator + il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR))); + il.append(DUP); + pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex()))); + + // Initialize Dup Filter Iterator with iterator from the stack + il.append(new INVOKESPECIAL(initDFI)); + } else { + final int git = cpg.addInterfaceMethodref(DOM_INTF, + "getIterator", + "()" + NODE_ITERATOR_SIG); + il.append(methodGen.loadDOM()); + il.append(new INVOKEINTERFACE(git, 1)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java new file mode 100644 index 0000000..30e44b0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FloorCall.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class FloorCall extends FunctionCall { + public FloorCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + argument().translate(classGen, methodGen); + methodGen.getInstructionList() + .append(new INVOKESTATIC(classGen.getConstantPool() + .addMethodref(MATH_CLASS, + "floor", "(D)D"))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java new file mode 100644 index 0000000..8b041f1 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FlowList.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +public final class FlowList { + private List _elements; + + public FlowList() { + _elements = null; + } + + public FlowList(InstructionHandle bh) { + _elements = new ArrayList<>(); + _elements.add(bh); + } + + public FlowList(FlowList list) { + _elements = list._elements; + } + + public FlowList add(InstructionHandle bh) { + if (_elements == null) { + _elements = new ArrayList<>(); + } + _elements.add(bh); + return this; + } + + public FlowList append(FlowList right) { + if (_elements == null) { + _elements = right._elements; + } else { + final List temp = right._elements; + if (temp != null) { + final int n = temp.size(); + for (int i = 0; i < n; i++) { + _elements.add(temp.get(i)); + } + } + } + return this; + } + + /** + * Back patch a flow list. All instruction handles must be branch handles. + */ + public void backPatch(InstructionHandle target) { + if (_elements != null) { + final int n = _elements.size(); + for (int i = 0; i < n; i++) { + BranchHandle bh = (BranchHandle) _elements.get(i); + bh.setTarget(target); + } + _elements.clear(); // avoid backpatching more than once + } + } + + /** + * Redirect the handles from oldList to newList. "This" flow list + * is assumed to be relative to oldList. + */ + public FlowList copyAndRedirect(InstructionList oldList, + InstructionList newList) { + final FlowList result = new FlowList(); + if (_elements == null) { + return result; + } + + final int n = _elements.size(); + final Iterator oldIter = oldList.iterator(); + final Iterator newIter = newList.iterator(); + + while (oldIter.hasNext()) { + final InstructionHandle oldIh = oldIter.next(); + final InstructionHandle newIh = newIter.next(); + + for (int i = 0; i < n; i++) { + if (_elements.get(i) == oldIh) { + result.add(newIh); + } + } + } + return result; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java new file mode 100644 index 0000000..0105c03 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/ForEach.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: ForEach.java,v 1.2.4.1 2005/09/01 15:23:46 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFGT; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class ForEach extends Instruction { + + private Expression _select; + private Type _type; + + public void display(int indent) { + indent(indent); + Util.println("ForEach"); + indent(indent + IndentIncrement); + Util.println("select " + _select.toString()); + displayContents(indent + IndentIncrement); + } + + public void parseContents(Parser parser) { + _select = parser.parseExpression(this, "select", null); + + parseChildren(parser); + + // make sure required attribute(s) have been set + if (_select.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select"); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _type = _select.typeCheck(stable); + + if (_type instanceof ReferenceType || _type instanceof NodeType) { + _select = new CastExpr(_select, Type.NodeSet); + typeCheckContents(stable); + return Type.Void; + } + if (_type instanceof NodeSetType || _type instanceof ResultTreeType) { + typeCheckContents(stable); + return Type.Void; + } + throw new TypeCheckError(this); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Save current node and current iterator on the stack + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Collect sort objects associated with this instruction + final List sortObjects = new ArrayList<>(); + Iterator children = elements(); + while (children.hasNext()) { + final SyntaxTreeNode child = children.next(); + if (child instanceof Sort) { + sortObjects.add((Sort) child); + } + } + + if ((_type != null) && (_type instanceof ResultTreeType)) { + // Store existing DOM on stack - must be restored when loop is done + il.append(methodGen.loadDOM()); + + // cannot be applied to a result tree - issue warning + if (sortObjects.size() > 0) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR, this); + getParser().reportError(WARNING, msg); + } + + // Put the result tree on the stack (DOM) + _select.translate(classGen, methodGen); + // Get an iterator for the whole DOM - excluding the root node + _type.translateTo(classGen, methodGen, Type.NodeSet); + // Store the result tree as the default DOM + il.append(SWAP); + il.append(methodGen.storeDOM()); + } else { + // Compile node iterator + if (sortObjects.size() > 0) { + Sort.translateSortIterator(classGen, methodGen, + _select, sortObjects); + } else { + _select.translate(classGen, methodGen); + } + + if (_type instanceof ReferenceType == false) { + il.append(methodGen.loadContextNode()); + il.append(methodGen.setStartNode()); + } + } + + + // Overwrite current iterator + il.append(methodGen.storeIterator()); + + // Give local variables (if any) default values before starting loop + initializeVariables(classGen, methodGen); + + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + translateContents(classGen, methodGen); + + nextNode.setTarget(il.append(methodGen.loadIterator())); + il.append(methodGen.nextNode()); + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGT(loop)); + + // Restore current DOM (if result tree was used instead for this loop) + if ((_type != null) && (_type instanceof ResultTreeType)) { + il.append(methodGen.storeDOM()); + } + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + } + + /** + * The code that is generated by nested for-each loops can appear to some + * JVMs as if it is accessing un-initialized variables. We must add some + * code that pushes the default variable value on the stack and pops it + * into the variable slot. This is done by the Variable.initialize() + * method. The code that we compile for this loop looks like this: + *

+ * initialize iterator + * initialize variables <-- HERE!!! + * goto Iterate + * Loop: : + * : (code for contents) + * : + * Iterate: node = iterator.next(); + * if (node != END) goto Loop + */ + public void initializeVariables(ClassGenerator classGen, + MethodGenerator methodGen) { + final int n = elementCount(); + for (int i = 0; i < n; i++) { + final Object child = getContents().get(i); + if (child instanceof Variable) { + Variable var = (Variable) child; + var.initialize(classGen, methodGen); + } + } + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java new file mode 100644 index 0000000..d9face4 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FormatNumberCall.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class FormatNumberCall extends FunctionCall { + private Expression _value; + private Expression _format; + private Expression _name; + private QName _resolvedQName = null; + + public FormatNumberCall(QName fname, List arguments) { + super(fname, arguments); + _value = argument(0); + _format = argument(1); + _name = argumentCount() == 3 ? argument(2) : null; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + + // Inform stylesheet to instantiate a DecimalFormat object + getStylesheet().numberFormattingUsed(); + + final Type tvalue = _value.typeCheck(stable); + if (tvalue instanceof RealType == false) { + _value = new CastExpr(_value, Type.Real); + } + final Type tformat = _format.typeCheck(stable); + if (tformat instanceof StringType == false) { + _format = new CastExpr(_format, Type.String); + } + if (argumentCount() == 3) { + final Type tname = _name.typeCheck(stable); + + if (_name instanceof LiteralExpr) { + final LiteralExpr literal = (LiteralExpr) _name; + _resolvedQName = + getParser().getQNameIgnoreDefaultNs(literal.getValue()); + } else if (tname instanceof StringType == false) { + _name = new CastExpr(_name, Type.String); + } + } + return _type = Type.String; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + _value.translate(classGen, methodGen); + _format.translate(classGen, methodGen); + + final int fn3arg = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "formatNumber", + "(DLjava/lang/String;" + + "Ljava/text/DecimalFormat;)" + + "Ljava/lang/String;"); + final int get = cpg.addMethodref(TRANSLET_CLASS, + "getDecimalFormat", + "(Ljava/lang/String;)" + + "Ljava/text/DecimalFormat;"); + + il.append(classGen.loadTranslet()); + if (_name == null) { + il.append(new PUSH(cpg, EMPTYSTRING)); + } else if (_resolvedQName != null) { + il.append(new PUSH(cpg, _resolvedQName.toString())); + } else { + _name.translate(classGen, methodGen); + } + il.append(new INVOKEVIRTUAL(get)); + il.append(new INVOKESTATIC(fn3arg)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java new file mode 100644 index 0000000..4bb0f0c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.List; + +/** + * @author G. Todd Miller + * @author Santiago Pericas-Geertsen + * @LastModified: Nov 2017 + */ +final class FunctionAvailableCall extends FunctionCall { + + private Expression _arg; + private String _nameOfFunct = null; + private String _namespaceOfFunct = null; + private boolean _isFunctionAvailable = false; + + /** + * Constructs a FunctionAvailableCall FunctionCall. Takes the + * function name qname, for example, 'function-available', and + * a list of arguments where the arguments must be instances of + * LiteralExpression. + */ + public FunctionAvailableCall(QName fname, List arguments) { + super(fname, arguments); + _arg = arguments.get(0); + _type = null; + + if (_arg instanceof LiteralExpr) { + LiteralExpr arg = (LiteralExpr) _arg; + _namespaceOfFunct = arg.getNamespace(); + _nameOfFunct = arg.getValue(); + + if (!isInternalNamespace()) { + _isFunctionAvailable = hasMethods(); + } + } + } + + /** + * Argument of function-available call must be literal, typecheck + * returns the type of function-available to be boolean. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + if (_type != null) { + return _type; + } + if (_arg instanceof LiteralExpr) { + return _type = Type.Boolean; + } + ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, + "function-available", this); + throw new TypeCheckError(err); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + return getResult() ? Boolean.TRUE : Boolean.FALSE; + } + + /** + * for external java functions only: reports on whether or not + * the specified method is found in the specifed class. + */ + private boolean hasMethods() { + + // Get the class name from the namespace uri + String className = getClassNameFromUri(_namespaceOfFunct); + + // Get the method name from the argument to function-available + String methodName = null; + int colonIndex = _nameOfFunct.indexOf(":"); + if (colonIndex > 0) { + String functionName = _nameOfFunct.substring(colonIndex + 1); + int lastDotIndex = functionName.lastIndexOf('.'); + if (lastDotIndex > 0) { + methodName = functionName.substring(lastDotIndex + 1); + if (className != null && className.length() != 0) + className = className + "." + functionName.substring(0, lastDotIndex); + else + className = functionName.substring(0, lastDotIndex); + } else + methodName = functionName; + } else + methodName = _nameOfFunct; + + if (className == null || methodName == null) { + return false; + } + + // Replace the '-' characters in the method name + if (methodName.indexOf('-') > 0) + methodName = replaceDash(methodName); + + try { + final Class clazz = ObjectFactory.findProviderClass(className, true); + + if (clazz == null) { + return false; + } + + final Method[] methods = clazz.getMethods(); + + for (int i = 0; i < methods.length; i++) { + final int mods = methods[i].getModifiers(); + + if (Modifier.isPublic(mods) && Modifier.isStatic(mods) + && methods[i].getName().equals(methodName)) { + return true; + } + } + } catch (ClassNotFoundException e) { + return false; + } + return false; + } + + /** + * Reports on whether the function specified in the argument to + * xslt function 'function-available' was found. + */ + public boolean getResult() { + if (_nameOfFunct == null) { + return false; + } + + if (isInternalNamespace()) { + final Parser parser = getParser(); + _isFunctionAvailable = + parser.functionSupported(Util.getLocalName(_nameOfFunct)); + } + return _isFunctionAvailable; + } + + /** + * Return true if the namespace uri is null or it is the XSLTC translet uri. + */ + private boolean isInternalNamespace() { + return (_namespaceOfFunct == null || + _namespaceOfFunct.equals(EMPTYSTRING) || + _namespaceOfFunct.equals(TRANSLET_URI)); + } + + /** + * Calls to 'function-available' are resolved at compile time since + * the namespaces declared in the stylsheet are not available at run + * time. Consequently, arguments to this function must be literals. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + methodGen.getInstructionList().append(new PUSH(cpg, getResult())); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java new file mode 100644 index 0000000..1228e9c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java @@ -0,0 +1,1150 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionConst; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.InvokeInstruction; +import com.sun.org.apache.bcel.internal.generic.LDC; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.utils.ObjectFactory; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jdk.xml.internal.JdkXmlFeatures; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Todd Miller + * @LastModified: Nov 2017 + */ +class FunctionCall extends Expression { + + // Name of this function call + private QName _fname; + // Arguments to this function call (might not be any) + private final List _arguments; + // Empty argument list, used for certain functions + private final static List EMPTY_ARG_LIST = new ArrayList<>(0); + + // Valid namespaces for Java function-call extension + protected final static String EXT_XSLTC = + TRANSLET_URI; + + protected final static String JAVA_EXT_XSLTC = + EXT_XSLTC + "/java"; + + protected final static String EXT_XALAN = + "http://xml.apache.org/xalan"; + + protected final static String JAVA_EXT_XALAN = + "http://xml.apache.org/xalan/java"; + + protected final static String JAVA_EXT_XALAN_OLD = + "http://xml.apache.org/xslt/java"; + + protected final static String EXSLT_COMMON = + "http://exslt.org/common"; + + protected final static String EXSLT_MATH = + "http://exslt.org/math"; + + protected final static String EXSLT_SETS = + "http://exslt.org/sets"; + + protected final static String EXSLT_DATETIME = + "http://exslt.org/dates-and-times"; + + protected final static String EXSLT_STRINGS = + "http://exslt.org/strings"; + + protected final static String XALAN_CLASSPACKAGE_NAMESPACE = + "xalan://"; + + // Namespace format constants + protected final static int NAMESPACE_FORMAT_JAVA = 0; + protected final static int NAMESPACE_FORMAT_CLASS = 1; + protected final static int NAMESPACE_FORMAT_PACKAGE = 2; + protected final static int NAMESPACE_FORMAT_CLASS_OR_PACKAGE = 3; + + // Namespace format + private int _namespace_format = NAMESPACE_FORMAT_JAVA; + + /** + * Stores reference to object for non-static Java calls + */ + Expression _thisArgument = null; + + // External Java function's class/method/signature + private String _className; + private Class _clazz; + private Method _chosenMethod; + private Constructor _chosenConstructor; + private MethodType _chosenMethodType; + + // Encapsulates all unsupported external function calls + private boolean unresolvedExternal; + + // If FunctionCall is a external java constructor + private boolean _isExtConstructor = false; + + // If the java method is static + private boolean _isStatic = false; + + // Legal conversions between internal and Java types. + private static final MultiHashtable _internal2Java = new MultiHashtable<>(); + + // Legal conversions between Java and internal types. + private static final Map, Type> JAVA2INTERNAL; + + // The mappings between EXSLT extension namespaces and implementation classes + private static final Map EXTENSIONNAMESPACE; + + // Extension functions that are implemented in BasisLibrary + private static final Map EXTENSIONFUNCTION; + + /** + * inner class to used in internal2Java mappings, contains + * the Java type and the distance between the internal type and + * the Java type. + */ + static class JavaType { + public Class type; + public int distance; + + public JavaType(Class type, int distance) { + this.type = type; + this.distance = distance; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.type); + } + + @Override + public boolean equals(Object query) { + if (query == null) { + return false; + } + if (query.getClass().isAssignableFrom(JavaType.class)) { + return ((JavaType) query).type.equals(type); + } else { + return query.equals(type); + } + } + } + + /** + * Defines 2 conversion tables: + * 1. From internal types to Java types and + * 2. From Java types to internal types. + * These two tables are used when calling external (Java) functions. + */ + static { + final Class nodeClass, nodeListClass; + try { + nodeClass = Class.forName("org.w3c.dom.Node"); + nodeListClass = Class.forName("org.w3c.dom.NodeList"); + } catch (ClassNotFoundException e) { + ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, "org.w3c.dom.Node or NodeList"); + throw new Error(err.toString()); + } + + // -- Internal to Java -------------------------------------------- + + // Type.Boolean -> { boolean(0), Boolean(1), Object(2) } + _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0)); + _internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1)); + _internal2Java.put(Type.Boolean, new JavaType(Object.class, 2)); + + // Type.Real -> { double(0), Double(1), float(2), long(3), int(4), + // short(5), byte(6), char(7), Object(8) } + _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0)); + _internal2Java.put(Type.Real, new JavaType(Double.class, 1)); + _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2)); + _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3)); + _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4)); + _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5)); + _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6)); + _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7)); + _internal2Java.put(Type.Real, new JavaType(Object.class, 8)); + + // Type.Int must be the same as Type.Real + _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0)); + _internal2Java.put(Type.Int, new JavaType(Double.class, 1)); + _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2)); + _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3)); + _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4)); + _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5)); + _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6)); + _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7)); + _internal2Java.put(Type.Int, new JavaType(Object.class, 8)); + + // Type.String -> { String(0), Object(1) } + _internal2Java.put(Type.String, new JavaType(String.class, 0)); + _internal2Java.put(Type.String, new JavaType(Object.class, 1)); + + // Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) } + _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2)); + _internal2Java.put(Type.NodeSet, new JavaType(String.class, 3)); + + // Type.Node -> { Node(0), NodeList(1), Object(2), String(3) } + _internal2Java.put(Type.Node, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.Node, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.Node, new JavaType(Object.class, 2)); + _internal2Java.put(Type.Node, new JavaType(String.class, 3)); + + // Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) } + _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0)); + _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1)); + _internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2)); + _internal2Java.put(Type.ResultTree, new JavaType(String.class, 3)); + + _internal2Java.put(Type.Reference, new JavaType(Object.class, 0)); + + _internal2Java.makeUnmodifiable(); + + Map, Type> java2Internal = new HashMap<>(); + Map extensionNamespaceTable = new HashMap<>(); + Map extensionFunctionTable = new HashMap<>(); + + // Possible conversions between Java and internal types + java2Internal.put(Boolean.TYPE, Type.Boolean); + java2Internal.put(Void.TYPE, Type.Void); + java2Internal.put(Character.TYPE, Type.Real); + java2Internal.put(Byte.TYPE, Type.Real); + java2Internal.put(Short.TYPE, Type.Real); + java2Internal.put(Integer.TYPE, Type.Real); + java2Internal.put(Long.TYPE, Type.Real); + java2Internal.put(Float.TYPE, Type.Real); + java2Internal.put(Double.TYPE, Type.Real); + + java2Internal.put(String.class, Type.String); + + java2Internal.put(Object.class, Type.Reference); + + // Conversions from org.w3c.dom.Node/NodeList to internal NodeSet + java2Internal.put(nodeListClass, Type.NodeSet); + java2Internal.put(nodeClass, Type.NodeSet); + + // Initialize the extension namespace table + extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions"); + extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon"); + extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath"); + extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets"); + extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime"); + extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings"); + + // Initialize the extension function table + extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset"); + extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType"); + extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset"); + + JAVA2INTERNAL = Collections.unmodifiableMap(java2Internal); + EXTENSIONNAMESPACE = Collections.unmodifiableMap(extensionNamespaceTable); + EXTENSIONFUNCTION = Collections.unmodifiableMap(extensionFunctionTable); + + } + + public FunctionCall(QName fname, List arguments) { + _fname = fname; + _arguments = arguments; + _type = null; + } + + public FunctionCall(QName fname) { + this(fname, EMPTY_ARG_LIST); + } + + public String getName() { + return (_fname.toString()); + } + + @Override + public void setParser(Parser parser) { + super.setParser(parser); + if (_arguments != null) { + final int n = _arguments.size(); + for (int i = 0; i < n; i++) { + final Expression exp = _arguments.get(i); + exp.setParser(parser); + exp.setParent(this); + } + } + } + + public String getClassNameFromUri(String uri) { + String className = EXTENSIONNAMESPACE.get(uri); + + if (className != null) + return className; + else { + if (uri.startsWith(JAVA_EXT_XSLTC)) { + int length = JAVA_EXT_XSLTC.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } else if (uri.startsWith(JAVA_EXT_XALAN)) { + int length = JAVA_EXT_XALAN.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } else if (uri.startsWith(JAVA_EXT_XALAN_OLD)) { + int length = JAVA_EXT_XALAN_OLD.length() + 1; + return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING; + } else { + int index = uri.lastIndexOf('/'); + return (index > 0) ? uri.substring(index + 1) : uri; + } + } + } + + /** + * Type check a function call. Since different type conversions apply, + * type checking is different for standard and external (Java) functions. + */ + @Override + public Type typeCheck(SymbolTable stable) + throws TypeCheckError { + if (_type != null) return _type; + + final String namespace = _fname.getNamespace(); + String local = _fname.getLocalPart(); + + if (isExtension()) { + _fname = new QName(null, null, local); + return typeCheckStandard(stable); + } else if (isStandard()) { + return typeCheckStandard(stable); + } + // Handle extension functions (they all have a namespace) + else { + try { + _className = getClassNameFromUri(namespace); + + final int pos = local.lastIndexOf('.'); + if (pos > 0) { + _isStatic = true; + if (_className != null && _className.length() > 0) { + _namespace_format = NAMESPACE_FORMAT_PACKAGE; + _className = _className + "." + local.substring(0, pos); + } else { + _namespace_format = NAMESPACE_FORMAT_JAVA; + _className = local.substring(0, pos); + } + + _fname = new QName(namespace, null, local.substring(pos + 1)); + } else { + if (_className != null && _className.length() > 0) { + try { + _clazz = ObjectFactory.findProviderClass(_className, true); + _namespace_format = NAMESPACE_FORMAT_CLASS; + } catch (ClassNotFoundException e) { + _namespace_format = NAMESPACE_FORMAT_PACKAGE; + } + } else + _namespace_format = NAMESPACE_FORMAT_JAVA; + + if (local.indexOf('-') > 0) { + local = replaceDash(local); + } + + String extFunction = EXTENSIONFUNCTION.get(namespace + ":" + local); + if (extFunction != null) { + _fname = new QName(null, null, extFunction); + return typeCheckStandard(stable); + } else + _fname = new QName(namespace, null, local); + } + + return typeCheckExternal(stable); + } catch (TypeCheckError e) { + ErrorMsg errorMsg = e.getErrorMsg(); + if (errorMsg == null) { + final String name = _fname.getLocalPart(); + errorMsg = new ErrorMsg(ErrorMsg.METHOD_NOT_FOUND_ERR, name); + } + getParser().reportError(ERROR, errorMsg); + return _type = Type.Void; + } + } + } + + /** + * Type check a call to a standard function. Insert CastExprs when needed. + * If as a result of the insertion of a CastExpr a type check error is + * thrown, then catch it and re-throw it with a new "this". + */ + public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError { + _fname.clearNamespace(); // HACK!!! + + final int n = _arguments.size(); + final List argsType = typeCheckArgs(stable); + final MethodType args = new MethodType(Type.Void, argsType); + final MethodType ptype = + lookupPrimop(stable, _fname.getLocalPart(), args); + + if (ptype != null) { + for (int i = 0; i < n; i++) { + final Type argType = ptype.argsType().get(i); + final Expression exp = _arguments.get(i); + if (!argType.identicalTo(exp.getType())) { + try { + _arguments.set(i, new CastExpr(exp, argType)); + } catch (TypeCheckError e) { + throw new TypeCheckError(this); // invalid conversion + } + } + } + _chosenMethodType = ptype; + return _type = ptype.resultType(); + } + throw new TypeCheckError(this); + } + + + public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError { + final List> constructors = findConstructors(); + if (constructors == null) { + // Constructor not found in this class + throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND, + _className); + + } + + final int nConstructors = constructors.size(); + final int nArgs = _arguments.size(); + final List argsType = typeCheckArgs(stable); + + // Try all constructors + int bestConstrDistance = Integer.MAX_VALUE; + _type = null; // reset + for (int j, i = 0; i < nConstructors; i++) { + // Check if all parameters to this constructor can be converted + final Constructor constructor = constructors.get(i); + final Class[] paramTypes = constructor.getParameterTypes(); + + Class extType; + int currConstrDistance = 0; + for (j = 0; j < nArgs; j++) { + // Convert from internal (translet) type to external (Java) type + extType = paramTypes[j]; + final Type intType = argsType.get(j); + JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0)); + if (match != null) { + currConstrDistance += match.distance; + } else if (intType instanceof ObjectType) { + ObjectType objectType = (ObjectType) intType; + if (objectType.getJavaClass() == extType) + continue; + else if (extType.isAssignableFrom(objectType.getJavaClass())) + currConstrDistance += 1; + else { + currConstrDistance = Integer.MAX_VALUE; + break; + } + } else { + // no mapping available + currConstrDistance = Integer.MAX_VALUE; + break; + } + } + + if (j == nArgs && currConstrDistance < bestConstrDistance) { + _chosenConstructor = constructor; + _isExtConstructor = true; + bestConstrDistance = currConstrDistance; + + _type = (_clazz != null) ? Type.newObjectType(_clazz) + : Type.newObjectType(_className); + } + } + + if (_type != null) { + return _type; + } + + throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType)); + } + + + /** + * Type check a call to an external (Java) method. + * The method must be static an public, and a legal type conversion + * must exist for all its arguments and its return type. + * Every method of name _fname is inspected + * as a possible candidate. + */ + public Type typeCheckExternal(SymbolTable stable) throws TypeCheckError { + int nArgs = _arguments.size(); + final String name = _fname.getLocalPart(); + + // check if function is a contructor 'new' + if (_fname.getLocalPart().equals("new")) { + return typeCheckConstructor(stable); + } + // check if we are calling an instance method + else { + boolean hasThisArgument = false; + + if (nArgs == 0) + _isStatic = true; + + if (!_isStatic) { + if (_namespace_format == NAMESPACE_FORMAT_JAVA + || _namespace_format == NAMESPACE_FORMAT_PACKAGE) + hasThisArgument = true; + + Expression firstArg = _arguments.get(0); + Type firstArgType = firstArg.typeCheck(stable); + + if (_namespace_format == NAMESPACE_FORMAT_CLASS + && firstArgType instanceof ObjectType + && _clazz != null + && _clazz.isAssignableFrom(((ObjectType) firstArgType).getJavaClass())) + hasThisArgument = true; + + if (hasThisArgument) { + _thisArgument = _arguments.get(0); + _arguments.remove(0); + nArgs--; + if (firstArgType instanceof ObjectType) { + _className = ((ObjectType) firstArgType).getJavaClassName(); + } else + throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name); + } + } else if (_className.length() == 0) { + /* + * Warn user if external function could not be resolved. + * Warning will _NOT_ be issued is the call is properly + * wrapped in an or element. For details + * see If.parserContents() and When.parserContents() + */ + final Parser parser = getParser(); + if (parser != null) { + reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR, + _fname.toString()); + } + unresolvedExternal = true; + return _type = Type.Int; // use "Int" as "unknown" + } + } + + final List methods = findMethods(); + + if (methods == null) { + // Method not found in this class + throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, _className + "." + name); + } + + Class extType = null; + final int nMethods = methods.size(); + final List argsType = typeCheckArgs(stable); + + // Try all methods to identify the best fit + int bestMethodDistance = Integer.MAX_VALUE; + _type = null; // reset internal type + for (int j, i = 0; i < nMethods; i++) { + // Check if all paramteters to this method can be converted + final Method method = methods.get(i); + final Class[] paramTypes = method.getParameterTypes(); + + int currMethodDistance = 0; + for (j = 0; j < nArgs; j++) { + // Convert from internal (translet) type to external (Java) type + extType = paramTypes[j]; + final Type intType = argsType.get(j); + JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0)); + if (match != null) { + currMethodDistance += match.distance; + } else { + // no mapping available + // + // Allow a Reference type to match any external (Java) type at + // the moment. The real type checking is performed at runtime. + if (intType instanceof ReferenceType) { + currMethodDistance += 1; + } else if (intType instanceof ObjectType) { + ObjectType object = (ObjectType) intType; + if (extType.getName().equals(object.getJavaClassName())) + currMethodDistance += 0; + else if (extType.isAssignableFrom(object.getJavaClass())) + currMethodDistance += 1; + else { + currMethodDistance = Integer.MAX_VALUE; + break; + } + } else { + currMethodDistance = Integer.MAX_VALUE; + break; + } + } + } + + if (j == nArgs) { + // Check if the return type can be converted + extType = method.getReturnType(); + + _type = JAVA2INTERNAL.get(extType); + if (_type == null) { + _type = Type.newObjectType(extType); + } + + // Use this method if all parameters & return type match + if (_type != null && currMethodDistance < bestMethodDistance) { + _chosenMethod = method; + bestMethodDistance = currMethodDistance; + } + } + } + + // It is an error if the chosen method is an instance menthod but we don't + // have a this argument. + if (_chosenMethod != null && _thisArgument == null && + !Modifier.isStatic(_chosenMethod.getModifiers())) { + throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, getMethodSignature(argsType)); + } + + if (_type != null) { + if (_type == Type.NodeSet) { + getXSLTC().setMultiDocument(true); + } + return _type; + } + + throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType)); + } + + /** + * Type check the actual arguments of this function call. + */ + public List typeCheckArgs(SymbolTable stable) throws TypeCheckError { + final List result = new ArrayList<>(); + for (Expression exp : _arguments) { + result.add(exp.typeCheck(stable)); + } + return result; + } + + protected final Expression argument(int i) { + return _arguments.get(i); + } + + protected final Expression argument() { + return argument(0); + } + + protected final int argumentCount() { + return _arguments.size(); + } + + protected final void setArgument(int i, Expression exp) { + _arguments.set(i, exp); + } + + /** + * Compile the function call and treat as an expression + * Update true/false-lists. + */ + @Override + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + Type type = Type.Boolean; + if (_chosenMethodType != null) + type = _chosenMethodType.resultType(); + + final InstructionList il = methodGen.getInstructionList(); + translate(classGen, methodGen); + + if ((type instanceof BooleanType) || (type instanceof IntType)) { + _falseList.add(il.append(new IFEQ(null))); + } + } + + + /** + * Translate a function call. The compiled code will leave the function's + * return value on the JVM's stack. + */ + @Override + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final int n = argumentCount(); + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing(); + final boolean isExtensionFunctionEnabled = classGen.getParser().getXSLTC() + .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); + int index; + + // Translate calls to methods in the BasisLibrary + if (isStandard() || isExtension()) { + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + exp.translate(classGen, methodGen); + exp.startIterator(classGen, methodGen); + } + + // append "F" to the function's name + final String name = _fname.toString().replace('-', '_') + "F"; + String args = Constants.EMPTYSTRING; + + // Special precautions for some method calls + if (name.equals("sumF")) { + args = DOM_INTF_SIG; + il.append(methodGen.loadDOM()); + } else if (name.equals("normalize_spaceF")) { + if (_chosenMethodType.toSignature(args). + equals("()Ljava/lang/String;")) { + args = "I" + DOM_INTF_SIG; + il.append(methodGen.loadContextNode()); + il.append(methodGen.loadDOM()); + } + } + + // Invoke the method in the basis library + index = cpg.addMethodref(BASIS_LIBRARY_CLASS, name, + _chosenMethodType.toSignature(args)); + il.append(new INVOKESTATIC(index)); + } + // Add call to BasisLibrary.unresolved_externalF() to generate + // run-time error message for unsupported external functions + else if (unresolvedExternal) { + index = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "unresolved_externalF", + "(Ljava/lang/String;)V"); + il.append(new PUSH(cpg, _fname.toString())); + il.append(new INVOKESTATIC(index)); + } else if (_isExtConstructor) { + if (isSecureProcessing && !isExtensionFunctionEnabled) + translateUnallowedExtension(cpg, il); + + final String clazz = + _chosenConstructor.getDeclaringClass().getName(); + + // Generate call to Module.addReads: + // .class.getModule().addReads( + generateAddReads(classGen, methodGen, clazz); + + Class[] paramTypes = _chosenConstructor.getParameterTypes(); + LocalVariableGen[] paramTemp = new LocalVariableGen[n]; + + // Backwards branches are prohibited if an uninitialized object is + // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. + // We don't know whether this code might contain backwards branches + // so we mustn't create the new object until after we've created + // the suspect arguments to its constructor. Instead we calculate + // the values of the arguments to the constructor first, store them + // in temporary variables, create the object and reload the + // arguments from the temporaries to avoid the problem. + + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + Type expType = exp.getType(); + exp.translate(classGen, methodGen); + // Convert the argument to its Java type + exp.startIterator(classGen, methodGen); + expType.translateTo(classGen, methodGen, paramTypes[i]); + paramTemp[i] = + methodGen.addLocalVariable("function_call_tmp" + i, + expType.toJCType(), + null, null); + paramTemp[i].setStart( + il.append(expType.STORE(paramTemp[i].getIndex()))); + + } + + il.append(new NEW(cpg.addClass(_className))); + il.append(InstructionConst.DUP); + + for (int i = 0; i < n; i++) { + final Expression arg = argument(i); + paramTemp[i].setEnd( + il.append(arg.getType().LOAD(paramTemp[i].getIndex()))); + } + + final StringBuffer buffer = new StringBuffer(); + buffer.append('('); + for (int i = 0; i < paramTypes.length; i++) { + buffer.append(getSignature(paramTypes[i])); + } + buffer.append(')'); + buffer.append("V"); + + index = cpg.addMethodref(clazz, + "", + buffer.toString()); + il.append(new INVOKESPECIAL(index)); + + // Convert the return type back to our internal type + (Type.Object).translateFrom(classGen, methodGen, + _chosenConstructor.getDeclaringClass()); + + } + // Invoke function calls that are handled in separate classes + else { + if (isSecureProcessing && !isExtensionFunctionEnabled) + translateUnallowedExtension(cpg, il); + + final String clazz = _chosenMethod.getDeclaringClass().getName(); + Class[] paramTypes = _chosenMethod.getParameterTypes(); + + + // Generate call to Module.addReads: + // .class.getModule().addReads( + // Class.forName().getModule()); + generateAddReads(classGen, methodGen, clazz); + + // Push "this" if it is an instance method + if (_thisArgument != null) { + _thisArgument.translate(classGen, methodGen); + } + + for (int i = 0; i < n; i++) { + final Expression exp = argument(i); + exp.translate(classGen, methodGen); + // Convert the argument to its Java type + exp.startIterator(classGen, methodGen); + exp.getType().translateTo(classGen, methodGen, paramTypes[i]); + } + + final StringBuffer buffer = new StringBuffer(); + buffer.append('('); + for (int i = 0; i < paramTypes.length; i++) { + buffer.append(getSignature(paramTypes[i])); + } + buffer.append(')'); + buffer.append(getSignature(_chosenMethod.getReturnType())); + + if (_thisArgument != null && _clazz.isInterface()) { + index = cpg.addInterfaceMethodref(clazz, + _fname.getLocalPart(), + buffer.toString()); + il.append(new INVOKEINTERFACE(index, n + 1)); + } else { + index = cpg.addMethodref(clazz, + _fname.getLocalPart(), + buffer.toString()); + il.append(_thisArgument != null ? (InvokeInstruction) new INVOKEVIRTUAL(index) : + (InvokeInstruction) new INVOKESTATIC(index)); + } + + // Convert the return type back to our internal type + _type.translateFrom(classGen, methodGen, + _chosenMethod.getReturnType()); + } + } + + private void generateAddReads(ClassGenerator classGen, MethodGenerator methodGen, + String clazz) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Generate call to Module.addReads: + // .class.getModule().addReads( + // Class.forName().getModule()); + // Class.forName may throw ClassNotFoundException. + // This is OK as it will caught higher up the stack in + // TransformerImpl.transform() and wrapped into a + // TransformerException. + methodGen.markChunkStart(); + + int index = cpg.addMethodref(CLASS_CLASS, + GET_MODULE, + GET_MODULE_SIG); + int index2 = cpg.addMethodref(CLASS_CLASS, + FOR_NAME, + FOR_NAME_SIG); + il.append(new LDC(cpg.addString(classGen.getClassName()))); + il.append(new INVOKESTATIC(index2)); + il.append(new INVOKEVIRTUAL(index)); + il.append(new LDC(cpg.addString(clazz))); + il.append(new INVOKESTATIC(index2)); + il.append(new INVOKEVIRTUAL(index)); + index = cpg.addMethodref(MODULE_CLASS, + ADD_READS, + ADD_READS_SIG); + il.append(new INVOKEVIRTUAL(index)); + il.append(InstructionConst.POP); + + methodGen.markChunkEnd(); + } + + @Override + public String toString() { + return "funcall(" + _fname + ", " + _arguments + ')'; + } + + public boolean isStandard() { + final String namespace = _fname.getNamespace(); + return (namespace == null) || (namespace.equals(Constants.EMPTYSTRING)); + } + + public boolean isExtension() { + final String namespace = _fname.getNamespace(); + return (namespace != null) && (namespace.equals(EXT_XSLTC)); + } + + /** + * Returns a vector with all methods named _fname + * after stripping its namespace or null + * if no such methods exist. + */ + private List findMethods() { + + List result = null; + final String namespace = _fname.getNamespace(); + + if (_className != null && _className.length() > 0) { + final int nArgs = _arguments.size(); + try { + if (_clazz == null) { + final boolean isSecureProcessing = getXSLTC().isSecureProcessing(); + final boolean isExtensionFunctionEnabled = getXSLTC() + .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); + + //Check if FSP and SM - only then process with loading + if (namespace != null && isSecureProcessing + && isExtensionFunctionEnabled + && (namespace.startsWith(JAVA_EXT_XALAN) + || namespace.startsWith(JAVA_EXT_XSLTC) + || namespace.startsWith(JAVA_EXT_XALAN_OLD) + || namespace.startsWith(XALAN_CLASSPACKAGE_NAMESPACE))) { + _clazz = getXSLTC().loadExternalFunction(_className); + } else { + _clazz = ObjectFactory.findProviderClass(_className, true); + } + + if (_clazz == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + + final String methodName = _fname.getLocalPart(); + final Method[] methods = _clazz.getMethods(); + + for (int i = 0; i < methods.length; i++) { + final int mods = methods[i].getModifiers(); + // Is it public and same number of args ? + if (Modifier.isPublic(mods) + && methods[i].getName().equals(methodName) + && methods[i].getParameterTypes().length == nArgs) { + if (result == null) { + result = new ArrayList<>(); + } + result.add(methods[i]); + } + } + } catch (ClassNotFoundException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + return result; + } + + /** + * Returns a vector with all constructors named _fname + * after stripping its namespace or null + * if no such methods exist. + */ + private List> findConstructors() { + List> result = null; + + final int nArgs = _arguments.size(); + try { + if (_clazz == null) { + _clazz = ObjectFactory.findProviderClass(_className, true); + + if (_clazz == null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + } + + final Constructor[] constructors = _clazz.getConstructors(); + + for (Constructor constructor : constructors) { + final int mods = constructor.getModifiers(); + // Is it public, static and same number of args ? + if (Modifier.isPublic(mods) && constructor.getParameterTypes().length == nArgs) { + if (result == null) { + result = new ArrayList<>(); + } + result.add(constructor); + } + } + } catch (ClassNotFoundException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + } + + return result; + } + + + /** + * Compute the JVM signature for the class. + */ + static final String getSignature(Class clazz) { + if (clazz.isArray()) { + final StringBuffer sb = new StringBuffer(); + Class cl = clazz; + while (cl.isArray()) { + sb.append("["); + cl = cl.getComponentType(); + } + sb.append(getSignature(cl)); + return sb.toString(); + } else if (clazz.isPrimitive()) { + if (clazz == Integer.TYPE) { + return "I"; + } else if (clazz == Byte.TYPE) { + return "B"; + } else if (clazz == Long.TYPE) { + return "J"; + } else if (clazz == Float.TYPE) { + return "F"; + } else if (clazz == Double.TYPE) { + return "D"; + } else if (clazz == Short.TYPE) { + return "S"; + } else if (clazz == Character.TYPE) { + return "C"; + } else if (clazz == Boolean.TYPE) { + return "Z"; + } else if (clazz == Void.TYPE) { + return "V"; + } else { + final String name = clazz.toString(); + ErrorMsg err = new ErrorMsg(ErrorMsg.UNKNOWN_SIG_TYPE_ERR, name); + throw new Error(err.toString()); + } + } else { + return "L" + clazz.getName().replace('.', '/') + ';'; + } + } + + /** + * Compute the JVM method descriptor for the method. + */ + static final String getSignature(Method meth) { + final StringBuffer sb = new StringBuffer(); + sb.append('('); + final Class[] params = meth.getParameterTypes(); // avoid clone + for (int j = 0; j < params.length; j++) { + sb.append(getSignature(params[j])); + } + return sb.append(')').append(getSignature(meth.getReturnType())) + .toString(); + } + + /** + * Compute the JVM constructor descriptor for the constructor. + */ + static final String getSignature(Constructor cons) { + final StringBuffer sb = new StringBuffer(); + sb.append('('); + final Class[] params = cons.getParameterTypes(); // avoid clone + for (int j = 0; j < params.length; j++) { + sb.append(getSignature(params[j])); + } + return sb.append(")V").toString(); + } + + /** + * Return the signature of the current method + */ + private String getMethodSignature(List argsType) { + final StringBuffer buf = new StringBuffer(_className); + buf.append('.').append(_fname.getLocalPart()).append('('); + + int nArgs = argsType.size(); + for (int i = 0; i < nArgs; i++) { + final Type intType = argsType.get(i); + buf.append(intType.toString()); + if (i < nArgs - 1) buf.append(", "); + } + + buf.append(')'); + return buf.toString(); + } + + /** + * To support EXSLT extensions, convert names with dash to allowable Java names: + * e.g., convert abc-xyz to abcXyz. + * Note: dashes only appear in middle of an EXSLT function or element name. + */ + protected static String replaceDash(String name) { + char dash = '-'; + final StringBuilder buff = new StringBuilder(""); + for (int i = 0; i < name.length(); i++) { + if (i > 0 && name.charAt(i - 1) == dash) + buff.append(Character.toUpperCase(name.charAt(i))); + else if (name.charAt(i) != dash) + buff.append(name.charAt(i)); + } + return buff.toString(); + } + + /** + * Translate code to call the BasisLibrary.unallowed_extensionF(String) + * method. + */ + private void translateUnallowedExtension(ConstantPoolGen cpg, + InstructionList il) { + int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "unallowed_extension_functionF", + "(Ljava/lang/String;)V"); + il.append(new PUSH(cpg, _fname.toString())); + il.append(new INVOKESTATIC(index)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java new file mode 100644 index 0000000..60282c5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/GenerateIdCall.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +import java.util.List; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class GenerateIdCall extends FunctionCall { + public GenerateIdCall(QName fname, List arguments) { + super(fname, arguments); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + if (argumentCount() == 0) { + il.append(methodGen.loadContextNode()); + } else { // one argument + argument().translate(classGen, methodGen); + } + final ConstantPoolGen cpg = classGen.getConstantPool(); + il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS, + "generate_idF", + // reuse signature + GET_NODE_NAME_SIG))); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java new file mode 100644 index 0000000..195616c --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdKeyPattern.java @@ -0,0 +1,127 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFNE; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class IdKeyPattern extends LocationPathPattern { + + protected RelativePathPattern _left = null; + ; + private String _index = null; + private String _value = null; + ; + + public IdKeyPattern(String index, String value) { + _index = index; + _value = value; + } + + public String getIndexName() { + return (_index); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.NodeSet; + } + + public boolean isWildcard() { + return false; + } + + public void setLeft(RelativePathPattern left) { + _left = left; + } + + public StepPattern getKernelPattern() { + return (null); + } + + public void reduceKernelPattern() { + } + + public String toString() { + return "id/keyPattern(" + _index + ", " + _value + ')'; + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the KeyIndex object of a given name + final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS, + "getKeyIndex", + "(Ljava/lang/String;)" + + KEY_INDEX_SIG); + + // Initialises a KeyIndex to return nodes with specific values + final int lookupId = cpg.addMethodref(KEY_INDEX_CLASS, + "containsID", + "(ILjava/lang/Object;)I"); + final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS, + "containsKey", + "(ILjava/lang/Object;)I"); + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)" + NODE_SIG); + + // Call getKeyIndex in AbstractTranslet with the name of the key + // to get the index for this key (which is also a node iterator). + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, _index)); + il.append(new INVOKEVIRTUAL(getKeyIndex)); + + // Now use the value in the second argument to determine what nodes + // the iterator should return. + il.append(SWAP); + il.append(new PUSH(cpg, _value)); + if (this instanceof IdPattern) { + il.append(new INVOKEVIRTUAL(lookupId)); + } else { + il.append(new INVOKEVIRTUAL(lookupKey)); + } + + _trueList.add(il.append(new IFNE(null))); + _falseList.add(il.append(new GOTO(null))); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java new file mode 100644 index 0000000..e85d59a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IdPattern.java @@ -0,0 +1,35 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class IdPattern extends IdKeyPattern { + + public IdPattern(String id) { + super("##id", id); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java new file mode 100644 index 0000000..5e4fd59 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/If.java @@ -0,0 +1,110 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class If extends Instruction { + + private Expression _test; + private boolean _ignore = false; + + /** + * Display the contents of this element + */ + public void display(int indent) { + indent(indent); + Util.println("If"); + indent(indent + IndentIncrement); + System.out.print("test "); + Util.println(_test.toString()); + displayContents(indent + IndentIncrement); + } + + /** + * Parse the "test" expression and contents of this element. + */ + public void parseContents(Parser parser) { + // Parse the "test" expression + _test = parser.parseExpression(this, "test", null); + + // Make sure required attribute(s) have been set + if (_test.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); + return; + } + + // Ignore xsl:if when test is false (function-available() and + // element-available()) + Object result = _test.evaluateAtCompileTime(); + if (result != null && result instanceof Boolean) { + _ignore = !((Boolean) result).booleanValue(); + } + + parseChildren(parser); + } + + /** + * Type-check the "test" expression and contents of this element. + * The contents will be ignored if we know the test will always fail. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type-check the "test" expression + if (_test.typeCheck(stable) instanceof BooleanType == false) { + _test = new CastExpr(_test, Type.Boolean); + } + // Type check the element contents + if (!_ignore) { + typeCheckContents(stable); + } + return Type.Void; + } + + /** + * Translate the "test" expression and contents of this element. + * The contents will be ignored if we know the test will always fail. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + _test.translateDesynthesized(classGen, methodGen); + // remember end of condition + final InstructionHandle truec = il.getEnd(); + if (!_ignore) { + translateContents(classGen, methodGen); + } + _test.backPatchFalseList(il.append(NOP)); + _test.backPatchTrueList(truec.getNext()); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java new file mode 100644 index 0000000..802420a --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IllegalCharException.java @@ -0,0 +1,34 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +class IllegalCharException extends Exception { + static final long serialVersionUID = -667236676706226266L; + + public IllegalCharException(String s) { + super(s); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java new file mode 100644 index 0000000..de7a1f2 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Import.java,v 1.8 2007/04/09 21:30:40 joehw Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.SystemIDResolver; + +import java.util.Iterator; + +import javax.xml.XMLConstants; + +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; + +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Gunnlaugur Briem + * @LastModified: May 2021 + */ +final class Import extends TopLevelElement { + + private Stylesheet _imported = null; + + public Stylesheet getImportedStylesheet() { + return _imported; + } + + public void parseContents(final Parser parser) { + final XSLTC xsltc = parser.getXSLTC(); + final Stylesheet context = parser.getCurrentStylesheet(); + + try { + String docToLoad = getAttribute("href"); + if (context.checkForLoop(docToLoad)) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CIRCULAR_INCLUDE_ERR, + docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + InputSource input = null; + XMLReader reader = null; + String currLoadedDoc = context.getSystemId(); + SourceLoader loader = context.getSourceLoader(); + + // Use SourceLoader if available + if (loader != null) { + input = loader.loadSource(docToLoad, currLoadedDoc, xsltc); + if (input != null) { + docToLoad = input.getSystemId(); + reader = xsltc.getXMLReader(); + } else if (parser.errorsFound()) { + return; + } + } + + // No SourceLoader or not resolved by SourceLoader + if (input == null) { + docToLoad = SystemIDResolver.getAbsoluteURI(docToLoad, currLoadedDoc); + String accessError = SecuritySupport.checkAccess(docToLoad, + (String) xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET), + JdkConstants.ACCESS_EXTERNAL_ALL); + + if (accessError != null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.ACCESSING_XSLT_TARGET_ERR, + SecuritySupport.sanitizePath(docToLoad), accessError, + this); + parser.reportError(Constants.FATAL, msg); + return; + } + input = new InputSource(docToLoad); + } + + // Return if we could not resolve the URL + if (input == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + final SyntaxTreeNode root; + if (reader != null) { + root = parser.parse(reader, input); + } else { + root = parser.parse(input); + } + + if (root == null) return; + _imported = parser.makeStylesheet(root); + if (_imported == null) return; + + _imported.setSourceLoader(loader); + _imported.setSystemId(docToLoad); + _imported.setParentStylesheet(context); + _imported.setImportingStylesheet(context); + _imported.setTemplateInlining(context.getTemplateInlining()); + + // precedence for the including stylesheet + final int currPrecedence = parser.getCurrentImportPrecedence(); + final int nextPrecedence = parser.getNextImportPrecedence(); + _imported.setImportPrecedence(currPrecedence); + context.setImportPrecedence(nextPrecedence); + parser.setCurrentStylesheet(_imported); + _imported.parseContents(parser); + + final Iterator elements = _imported.elements(); + final Stylesheet topStylesheet = parser.getTopLevelStylesheet(); + while (elements.hasNext()) { + final Object element = elements.next(); + if (element instanceof TopLevelElement) { + if (element instanceof Variable) { + topStylesheet.addVariable((Variable) element); + } else if (element instanceof Param) { + topStylesheet.addParam((Param) element); + } else { + topStylesheet.addElement((TopLevelElement) element); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + parser.setCurrentStylesheet(context); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // do nothing + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java new file mode 100644 index 0000000..0613870 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Include.java,v 1.8 2007/04/09 21:30:41 joehw Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.utils.SystemIDResolver; + +import java.util.Iterator; + +import javax.xml.XMLConstants; + +import jdk.xml.internal.JdkConstants; +import jdk.xml.internal.SecuritySupport; + +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +/** + * @author Jacek Ambroziak + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author Gunnlaugur Briem + * @LastModified: May 2021 + */ +final class Include extends TopLevelElement { + + private Stylesheet _included = null; + + public Stylesheet getIncludedStylesheet() { + return _included; + } + + public void parseContents(final Parser parser) { + XSLTC xsltc = parser.getXSLTC(); + Stylesheet context = parser.getCurrentStylesheet(); + + String docToLoad = getAttribute("href"); + try { + if (context.checkForLoop(docToLoad)) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CIRCULAR_INCLUDE_ERR, + docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + InputSource input = null; + XMLReader reader = null; + String currLoadedDoc = context.getSystemId(); + SourceLoader loader = context.getSourceLoader(); + + // Use SourceLoader if available + if (loader != null) { + input = loader.loadSource(docToLoad, currLoadedDoc, xsltc); + if (input != null) { + docToLoad = input.getSystemId(); + reader = xsltc.getXMLReader(); + } else if (parser.errorsFound()) { + return; + } + } + + // No SourceLoader or not resolved by SourceLoader + if (input == null) { + docToLoad = SystemIDResolver.getAbsoluteURI(docToLoad, currLoadedDoc); + String accessError = SecuritySupport.checkAccess(docToLoad, + (String) xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET), + JdkConstants.ACCESS_EXTERNAL_ALL); + + if (accessError != null) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.ACCESSING_XSLT_TARGET_ERR, + SecuritySupport.sanitizePath(docToLoad), accessError, + this); + parser.reportError(Constants.FATAL, msg); + return; + } + input = new InputSource(docToLoad); + } + + // Return if we could not resolve the URL + if (input == null) { + final ErrorMsg msg = + new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this); + parser.reportError(Constants.FATAL, msg); + return; + } + + final SyntaxTreeNode root; + if (reader != null) { + root = parser.parse(reader, input); + } else { + root = parser.parse(input); + } + + if (root == null) return; + _included = parser.makeStylesheet(root); + if (_included == null) return; + + _included.setSourceLoader(loader); + _included.setSystemId(docToLoad); + _included.setParentStylesheet(context); + _included.setIncludingStylesheet(context); + _included.setTemplateInlining(context.getTemplateInlining()); + + // An included stylesheet gets the same import precedence + // as the stylesheet that included it. + final int precedence = context.getImportPrecedence(); + _included.setImportPrecedence(precedence); + parser.setCurrentStylesheet(_included); + _included.parseContents(parser); + + final Iterator elements = _included.elements(); + final Stylesheet topStylesheet = parser.getTopLevelStylesheet(); + while (elements.hasNext()) { + final Object element = elements.next(); + if (element instanceof TopLevelElement) { + if (element instanceof Variable) { + topStylesheet.addVariable((Variable) element); + } else if (element instanceof Param) { + topStylesheet.addParam((Param) element); + } else { + topStylesheet.addElement((TopLevelElement) element); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + parser.setCurrentStylesheet(context); + } + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // do nothing + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java new file mode 100644 index 0000000..976b1ad --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Instruction.java @@ -0,0 +1,50 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +abstract class Instruction extends SyntaxTreeNode { + /** + * Type check all the children of this node. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return typeCheckContents(stable); + } + + /** + * Translate this node into JVM bytecodes. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR, + getClass(), this); + getParser().reportError(FATAL, msg); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java new file mode 100644 index 0000000..658d306 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/IntExpr.java @@ -0,0 +1,56 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class IntExpr extends Expression { + private final int _value; + + public IntExpr(int value) { + _value = value; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _type = Type.Int; + } + + public String toString() { + return "int-expr(" + _value + ')'; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + ConstantPoolGen cpg = classGen.getConstantPool(); + InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java new file mode 100644 index 0000000..bdea086 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Key.java @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Key.java,v 1.6 2006/04/25 02:25:08 jeffsuttor Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.IFEQ; +import com.sun.org.apache.bcel.internal.generic.IFGE; +import com.sun.org.apache.bcel.internal.generic.IFGT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.Axis; +import com.sun.org.apache.xml.internal.utils.XML11Char; + +/** + * @author Morten Jorgensen + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class Key extends TopLevelElement { + + /** + * The name of this key as defined in xsl:key. + */ + private QName _name; + + /** + * The pattern to match starting at the root node. + */ + private Pattern _match; + + /** + * The expression that generates the values for this key. + */ + private Expression _use; + + /** + * The type of the _use expression. + */ + private Type _useType; + + /** + * Parse the element and attributes + * + * @param parser A reference to the stylesheet parser + */ + public void parseContents(Parser parser) { + + // Get the required attributes and parser XPath expressions + final String name = getAttribute("name"); + if (!XML11Char.isXML11ValidQName(name)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); + parser.reportError(Constants.ERROR, err); + } + + // Parse key name and add to symbol table + _name = parser.getQNameIgnoreDefaultNs(name); + getSymbolTable().addKey(_name, this); + + _match = parser.parsePattern(this, "match", null); + _use = parser.parseExpression(this, "use", null); + + // Make sure required attribute(s) have been set + if (_name == null) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); + return; + } + if (_match.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "match"); + return; + } + if (_use.isDummy()) { + reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "use"); + return; + } + } + + /** + * Returns a String-representation of this key's name + * + * @return The key's name (from the elements 'name' attribute). + */ + public String getName() { + return _name.toString(); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type check match pattern + _match.typeCheck(stable); + + // Cast node values to string values (except for nodesets) + _useType = _use.typeCheck(stable); + if (_useType instanceof StringType == false && + _useType instanceof NodeSetType == false) { + _use = new CastExpr(_use, Type.String); + } + + return Type.Void; + } + + /** + * This method is called if the "use" attribute of the key contains a + * node set. In this case we must traverse all nodes in the set and + * create one entry in this key's index for each node in the set. + */ + public void traverseNodeSet(ClassGenerator classGen, + MethodGenerator methodGen, + int buildKeyIndex) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // DOM.getStringValueX(nodeIndex) => String + final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF, + GET_NODE_VALUE, + "(I)" + STRING_SIG); + + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)" + NODE_SIG); + + // AbstractTranslet.SetKeyIndexDom(name, Dom) => void + final int keyDom = cpg.addMethodref(TRANSLET_CLASS, + "setKeyIndexDom", + "(" + STRING_SIG + DOM_INTF_SIG + ")V"); + + + // This variable holds the id of the node we found with the "match" + // attribute of xsl:key. This is the id we store, with the value we + // get from the nodes we find here, in the index for this key. + final LocalVariableGen parentNode = + methodGen.addLocalVariable("parentNode", + Util.getJCRefType("I"), + null, null); + + // Get the 'parameter' from the stack and store it in a local var. + parentNode.setStart(il.append(new ISTORE(parentNode.getIndex()))); + + // Save current node and current iterator on the stack + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Overwrite current iterator with one that gives us only what we want + _use.translate(classGen, methodGen); + _use.startIterator(classGen, methodGen); + il.append(methodGen.storeIterator()); + + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + // Prepare to call buildKeyIndex(String name, int node, String value); + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, _name.toString())); + parentNode.setEnd(il.append(new ILOAD(parentNode.getIndex()))); + + // Now get the node value and push it on the parameter stack + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEINTERFACE(getNodeValue, 2)); + + // Finally do the call to add an entry in the index for this key. + il.append(new INVOKEVIRTUAL(buildKeyIndex)); + + il.append(classGen.loadTranslet()); + il.append(new PUSH(cpg, getName())); + il.append(methodGen.loadDOM()); + il.append(new INVOKEVIRTUAL(keyDom)); + + nextNode.setTarget(il.append(methodGen.loadIterator())); + il.append(methodGen.nextNode()); + + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGE(loop)); // Go on to next matching node.... + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + } + + /** + * Gather all nodes that match the expression in the attribute "match" + * and add one (or more) entries in this key's index. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + final int current = methodGen.getLocalIndex("current"); + + // AbstractTranslet.buildKeyIndex(name,node_id,value) => void + final int key = cpg.addMethodref(TRANSLET_CLASS, + "buildKeyIndex", + "(" + STRING_SIG + "I" + STRING_SIG + ")V"); + + // AbstractTranslet.SetKeyIndexDom(name, Dom) => void + final int keyDom = cpg.addMethodref(TRANSLET_CLASS, + "setKeyIndexDom", + "(" + STRING_SIG + DOM_INTF_SIG + ")V"); + + final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeIdent", + "(I)" + NODE_SIG); + + // DOM.getAxisIterator(root) => NodeIterator + final int git = cpg.addInterfaceMethodref(DOM_INTF, + "getAxisIterator", + "(I)" + NODE_ITERATOR_SIG); + + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.loadIterator()); + + // Get an iterator for all nodes in the DOM + il.append(methodGen.loadDOM()); + il.append(new PUSH(cpg, Axis.DESCENDANT)); + il.append(new INVOKEINTERFACE(git, 2)); + + // Reset the iterator to start with the root node + il.append(methodGen.loadCurrentNode()); + il.append(methodGen.setStartNode()); + il.append(methodGen.storeIterator()); + + // Loop for traversing all nodes in the DOM + final BranchHandle nextNode = il.append(new GOTO(null)); + final InstructionHandle loop = il.append(NOP); + + // Check if the current node matches the pattern in "match" + il.append(methodGen.loadCurrentNode()); + _match.translate(classGen, methodGen); + _match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack + final BranchHandle skipNode = il.append(new IFEQ(null)); + + // If this is a node-set we must go through each node in the set + if (_useType instanceof NodeSetType) { + // Pass current node as parameter (we're indexing on that node) + il.append(methodGen.loadCurrentNode()); + traverseNodeSet(classGen, methodGen, key); + } else { + il.append(classGen.loadTranslet()); + il.append(DUP); + il.append(new PUSH(cpg, _name.toString())); + il.append(DUP_X1); + il.append(methodGen.loadCurrentNode()); + _use.translate(classGen, methodGen); + il.append(new INVOKEVIRTUAL(key)); + + il.append(methodGen.loadDOM()); + il.append(new INVOKEVIRTUAL(keyDom)); + } + + // Get the next node from the iterator and do loop again... + final InstructionHandle skip = il.append(NOP); + + il.append(methodGen.loadIterator()); + il.append(methodGen.nextNode()); + il.append(DUP); + il.append(methodGen.storeCurrentNode()); + il.append(new IFGT(loop)); + + // Restore current node and current iterator from the stack + il.append(methodGen.storeIterator()); + il.append(methodGen.storeCurrentNode()); + + nextNode.setTarget(skip); + skipNode.setTarget(skip); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java new file mode 100644 index 0000000..5a9871e --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyCall.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Morten Jorgensen + * @author Santiago Pericas-Geertsen + * @LastModified: Oct 2017 + */ +final class KeyCall extends FunctionCall { + + /** + * The name of the key. + */ + private Expression _name; + + /** + * The value to look up in the key/index. + */ + private Expression _value; + + /** + * The value's data type. + */ + private Type _valueType; // The value's data type + + /** + * Expanded qname when name is literal. + */ + private QName _resolvedQName = null; + + /** + * Get the parameters passed to function: + * key(String name, String value) + * key(String name, NodeSet value) + * The 'arguments' vector should contain two parameters for key() calls, + * one holding the key name and one holding the value(s) to look up. The + * vector has only one parameter for id() calls (the key name is always + * "##id" for id() calls). + * + * @param fname The function name (should be 'key' or 'id') + * @param arguments A vector containing the arguments the the function + */ + public KeyCall(QName fname, List arguments) { + super(fname, arguments); + switch (argumentCount()) { + case 1: + _name = null; + _value = argument(0); + break; + case 2: + _name = argument(0); + _value = argument(1); + break; + default: + _name = _value = null; + break; + } + } + + /** + * If this call to key() is in a top-level element like another variable + * or param, add a dependency between that top-level element and the + * referenced key. For example, + *

+ * + * + *

+ * and assuming this class represents "key('x', 1)", add a reference + * between variable y and key x. Note that if 'x' is unknown statically + * in key('x', 1), there's nothing we can do at this point. + */ + public void addParentDependency() { + // If name unknown statically, there's nothing we can do + if (_resolvedQName == null) return; + + SyntaxTreeNode node = this; + while (node != null && node instanceof TopLevelElement == false) { + node = node.getParent(); + } + + TopLevelElement parent = (TopLevelElement) node; + if (parent != null) { + parent.addDependency(getSymbolTable().getKey(_resolvedQName)); + } + } + + /** + * Type check the parameters for the id() or key() function. + * The index name (for key() call only) must be a string or convertable + * to a string, and the lookup-value must be a string or a node-set. + * + * @param stable The parser's symbol table + * @throws TypeCheckError When the parameters have illegal type + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + final Type returnType = super.typeCheck(stable); + + // Run type check on the key name (first argument) - must be a string, + // and if it is not it must be converted to one using string() rules. + if (_name != null) { + final Type nameType = _name.typeCheck(stable); + + if (_name instanceof LiteralExpr) { + final LiteralExpr literal = (LiteralExpr) _name; + _resolvedQName = + getParser().getQNameIgnoreDefaultNs(literal.getValue()); + } else if (nameType instanceof StringType == false) { + _name = new CastExpr(_name, Type.String); + } + } + + // Run type check on the value for this key. This value can be of + // any data type, so this should never cause any type-check errors. + // If the value is a reference, then we have to defer the decision + // of how to process it until run-time. + // If the value is known not to be a node-set, then it should be + // converted to a string before the lookup is done. If the value is + // known to be a node-set then this process (convert to string, then + // do lookup) should be applied to every node in the set, and the + // result from all lookups should be added to the resulting node-set. + _valueType = _value.typeCheck(stable); + + if (_valueType != Type.NodeSet + && _valueType != Type.Reference + && _valueType != Type.String) { + _value = new CastExpr(_value, Type.String); + _valueType = _value.typeCheck(stable); + } + + // If in a top-level element, create dependency to the referenced key + addParentDependency(); + + return returnType; + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + *

This method will generate byte code that produces an iterator + * for the nodes in the node set for the key or id function call. + * + * @param classGen The Java class generator + * @param methodGen The method generator + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the KeyIndex object of a given name + final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS, + "getKeyIndex", + "(Ljava/lang/String;)" + + KEY_INDEX_SIG); + + // KeyIndex.setDom(Dom, node) => void + final int keyDom = cpg.addMethodref(KEY_INDEX_CLASS, + "setDom", + "(" + DOM_INTF_SIG + "I)V"); + + // Initialises a KeyIndex to return nodes with specific values + final int getKeyIterator = + cpg.addMethodref(KEY_INDEX_CLASS, + "getKeyIndexIterator", + "(" + _valueType.toSignature() + "Z)" + + KEY_INDEX_ITERATOR_SIG); + + // Initialise the index specified in the first parameter of key() + il.append(classGen.loadTranslet()); + if (_name == null) { + il.append(new PUSH(cpg, "##id")); + } else if (_resolvedQName != null) { + il.append(new PUSH(cpg, _resolvedQName.toString())); + } else { + _name.translate(classGen, methodGen); + } + + // Generate following byte code: + // + // KeyIndex ki = translet.getKeyIndex(_name) + // ki.setDom(translet.dom); + // ki.getKeyIndexIterator(_value, true) - for key() + // OR + // ki.getKeyIndexIterator(_value, false) - for id() + il.append(new INVOKEVIRTUAL(getKeyIndex)); + il.append(DUP); + il.append(methodGen.loadDOM()); + il.append(methodGen.loadCurrentNode()); + il.append(new INVOKEVIRTUAL(keyDom)); + + _value.translate(classGen, methodGen); + il.append((_name != null) ? ICONST_1 : ICONST_0); + il.append(new INVOKEVIRTUAL(getKeyIterator)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java new file mode 100644 index 0000000..1866151 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/KeyPattern.java @@ -0,0 +1,34 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class KeyPattern extends IdKeyPattern { + + public KeyPattern(String index, String value) { + super(index, value); + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java new file mode 100644 index 0000000..13ea3a8 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LangCall.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.FilterGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +import java.util.List; + +/** + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class LangCall extends FunctionCall { + private Expression _lang; + private Type _langType; + + /** + * Get the parameters passed to function: + * lang(string) + */ + public LangCall(QName fname, List arguments) { + super(fname, arguments); + _lang = argument(0); + } + + /** + * + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _langType = _lang.typeCheck(stable); + if (!(_langType instanceof StringType)) { + _lang = new CastExpr(_lang, Type.String); + } + return Type.Boolean; + } + + /** + * + */ + public Type getType() { + return (Type.Boolean); + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "testLanguage", + "(" + STRING_SIG + DOM_INTF_SIG + "I)Z"); + _lang.translate(classGen, methodGen); + il.append(methodGen.loadDOM()); + if (classGen instanceof FilterGenerator) + il.append(new ILOAD(1)); + else + il.append(methodGen.loadContextNode()); + il.append(new INVOKESTATIC(tst)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java new file mode 100644 index 0000000..3e022c5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LastCall.java @@ -0,0 +1,67 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.CompareGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class LastCall extends FunctionCall { + + public LastCall(QName fname) { + super(fname); + } + + public boolean hasPositionCall() { + return true; + } + + public boolean hasLastCall() { + return true; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final InstructionList il = methodGen.getInstructionList(); + + if (methodGen instanceof CompareGenerator) { + il.append(((CompareGenerator) methodGen).loadLastNode()); + } else if (methodGen instanceof TestGenerator) { + il.append(new ILOAD(LAST_INDEX)); + } else { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR, + "getLast", + "()I"); + il.append(methodGen.loadIterator()); + il.append(new INVOKEINTERFACE(getLast, 1)); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java new file mode 100644 index 0000000..d55cad5 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralAttribute.java @@ -0,0 +1,155 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; + +import com.sun.org.apache.xml.internal.serializer.ElemDesc; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +final class LiteralAttribute extends Instruction { + + private final String _name; // Attribute name (incl. prefix) + private final AttributeValue _value; // Attribute value + + /** + * Creates a new literal attribute (but does not insert it into the AST). + * + * @param name the attribute name (incl. prefix) as a String. + * @param value the attribute value. + * @param parser the XSLT parser (wraps XPath parser). + */ + public LiteralAttribute(String name, String value, Parser parser, + SyntaxTreeNode parent) { + _name = name; + setParent(parent); + _value = AttributeValue.create(this, value, parser); + } + + public void display(int indent) { + indent(indent); + Util.println("LiteralAttribute name=" + _name + " value=" + _value); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + _value.typeCheck(stable); + typeCheckContents(stable); + return Type.Void; + } + + protected boolean contextDependent() { + return _value.contextDependent(); + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // push handler + il.append(methodGen.loadHandler()); + // push attribute name - namespace prefix set by parent node + il.append(new PUSH(cpg, _name)); + // push attribute value + _value.translate(classGen, methodGen); + + // Generate code that calls SerializationHandler.addUniqueAttribute() + // if all attributes are unique. + SyntaxTreeNode parent = getParent(); + if (parent instanceof LiteralElement + && ((LiteralElement) parent).allAttributesUnique()) { + + int flags = 0; + boolean isHTMLAttrEmpty = false; + ElemDesc elemDesc = ((LiteralElement) parent).getElemDesc(); + + // Set the HTML flags + if (elemDesc != null) { + if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTREMPTY)) { + flags = flags | SerializationHandler.HTML_ATTREMPTY; + isHTMLAttrEmpty = true; + } else if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTRURL)) { + flags = flags | SerializationHandler.HTML_ATTRURL; + } + } + + if (_value instanceof SimpleAttributeValue) { + String attrValue = ((SimpleAttributeValue) _value).toString(); + + if (!hasBadChars(attrValue) && !isHTMLAttrEmpty) { + flags = flags | SerializationHandler.NO_BAD_CHARS; + } + } + + il.append(new PUSH(cpg, flags)); + il.append(methodGen.uniqueAttribute()); + } else { + // call attribute + il.append(methodGen.attribute()); + } + } + + /** + * Return true if at least one character in the String is considered to + * be a "bad" character. A bad character is one whose code is: + * less than 32 (a space), + * or greater than 126, + * or it is one of '<', '>', '&' or '\"'. + * This helps the serializer to decide whether the String needs to be escaped. + */ + private boolean hasBadChars(String value) { + char[] chars = value.toCharArray(); + int size = chars.length; + for (int i = 0; i < size; i++) { + char ch = chars[i]; + if (ch < 32 || 126 < ch || ch == '<' || ch == '>' || ch == '&' || ch == '\"') + return true; + } + return false; + } + + /** + * Return the name of the attribute + */ + public String getName() { + return _name; + } + + /** + * Return the value of the attribute + */ + public AttributeValue getValue() { + return _value; + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java new file mode 100644 index 0000000..fce3a78 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.serializer.ElemDesc; +import com.sun.org.apache.xml.internal.serializer.ToHTMLStream; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Sep 2021 + */ +final class LiteralElement extends Instruction { + + private String _name; + private LiteralElement _literalElemParent = null; + private List _attributeElements = null; + private Map _accessedPrefixes = null; + + // True if all attributes of this LRE are unique, i.e. they all have + // different names. This flag is set to false if some attribute + // names are not known at compile time. + private boolean _allAttributesUnique = false; + + /** + * Returns the QName for this literal element + */ + public QName getName() { + return _qname; + } + + /** + * Displays the contents of this literal element + */ + public void display(int indent) { + indent(indent); + Util.println("LiteralElement name = " + _name); + displayContents(indent + IndentIncrement); + } + + /** + * Returns the namespace URI for which a prefix is pointing to + */ + private String accessedNamespace(String prefix) { + if (_literalElemParent != null) { + String result = _literalElemParent.accessedNamespace(prefix); + if (result != null) { + return result; + } + } + return _accessedPrefixes != null ? _accessedPrefixes.get(prefix) : null; + } + + /** + * Method used to keep track of what namespaces that are references by + * this literal element and its attributes. The output must contain a + * definition for each namespace, so we stuff them in a map. + */ + public void registerNamespace(String prefix, String uri, + SymbolTable stable, boolean declared) { + + // Check if the parent has a declaration for this namespace + if (_literalElemParent != null) { + final String parentUri = _literalElemParent.accessedNamespace(prefix); + if (parentUri != null && parentUri.equals(uri)) { + return; + } + } + + // Check if we have any declared namespaces + if (_accessedPrefixes == null) { + // use Hashtable for behavior compatibility + _accessedPrefixes = new Hashtable<>(); + } else { + if (!declared) { + // Check if this node has a declaration for this namespace + final String old = _accessedPrefixes.get(prefix); + if (old != null) { + if (old.equals(uri)) + return; + else + prefix = stable.generateNamespacePrefix(); + } + } + } + + if (!prefix.equals("xml")) { + _accessedPrefixes.put(prefix, uri); + } + } + + /** + * Translates the prefix of a QName according to the rules set in + * the attributes of xsl:stylesheet. Also registers a QName to assure + * that the output element contains the necessary namespace declarations. + */ + private String translateQName(QName qname, SymbolTable stable) { + // Break up the QName and get prefix:localname strings + String localname = qname.getLocalPart(); + String prefix = qname.getPrefix(); + + // Treat default namespace as "" and not null + if (prefix == null) + prefix = Constants.EMPTYSTRING; + else if (prefix.equals(XMLNS_PREFIX)) + return (XMLNS_PREFIX); + + // Check if we must translate the prefix + final String alternative = stable.lookupPrefixAlias(prefix); + if (alternative != null) { + stable.excludeNamespaces(prefix); + prefix = alternative; + } + + // Get the namespace this prefix refers to + String uri = lookupNamespace(prefix); + if (uri == null) return (localname); + + // Register the namespace as accessed + registerNamespace(prefix, uri, stable, false); + + // Construct the new name for the element (may be unchanged) + if (prefix != Constants.EMPTYSTRING) + return (prefix + ":" + localname); + else + return (localname); + } + + /** + * Add an attribute to this element + */ + public void addAttribute(SyntaxTreeNode attribute) { + if (_attributeElements == null) { + _attributeElements = new ArrayList<>(2); + } + _attributeElements.add(attribute); + } + + /** + * Set the first attribute of this element + */ + public void setFirstAttribute(SyntaxTreeNode attribute) { + if (_attributeElements == null) { + _attributeElements = new ArrayList<>(2); + } + _attributeElements.add(0, attribute); + } + + /** + * Type-check the contents of this element. The element itself does not + * need any type checking as it leaves nothign on the JVM's stack. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Type-check all attributes + if (_attributeElements != null) { + for (SyntaxTreeNode node : _attributeElements) { + node.typeCheck(stable); + } + } + typeCheckContents(stable); + return Type.Void; + } + + /** + * This method starts at a given node, traverses all namespace mappings, + * and assembles a list of all prefixes that (for the given node) maps + * to _ANY_ namespace URI. Used by literal result elements to determine + */ + public Set> getNamespaceScope(SyntaxTreeNode node) { + Map all = new LinkedHashMap<>(); + + while (node != null) { + Map mapping = node.getPrefixMapping(); + if (mapping != null) { + mapping.entrySet().stream().forEach((entry) -> { + all.putIfAbsent(entry.getKey(), entry.getValue()); + }); + } + node = node.getParent(); + } + return all.entrySet(); + } + + /** + * Determines the final QName for the element and its attributes. + * Registers all namespaces that are used by the element/attributes + */ + public void parseContents(Parser parser) { + final SymbolTable stable = parser.getSymbolTable(); + stable.setCurrentNode(this); + + // Check if in a literal element context + SyntaxTreeNode parent = getParent(); + if (parent != null && parent instanceof LiteralElement) { + _literalElemParent = (LiteralElement) parent; + } + + _name = translateQName(_qname, stable); + + // Process all attributes and register all namespaces they use + final int count = _attributes.getLength(); + for (int i = 0; i < count; i++) { + final QName qname = parser.getQName(_attributes.getQName(i)); + final String uri = qname.getNamespace(); + final String val = _attributes.getValue(i); + + // Handle xsl:use-attribute-sets. Attribute sets are placed first + // in the vector or attributes to make sure that later local + // attributes can override an attributes in the set. + if (qname.equals(parser.getUseAttributeSets())) { + if (!Util.isValidQNames(val)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, val, this); + parser.reportError(Constants.ERROR, err); + } + setFirstAttribute(new UseAttributeSets(val, parser)); + } + // Handle xsl:extension-element-prefixes + else if (qname.equals(parser.getExtensionElementPrefixes())) { + stable.excludeNamespaces(val); + } + // Handle xsl:exclude-result-prefixes + else if (qname.equals(parser.getExcludeResultPrefixes())) { + stable.excludeNamespaces(val); + } else { + // Ignore special attributes (e.g. xmlns:prefix and xmlns) + final String prefix = qname.getPrefix(); + if (prefix != null && prefix.equals(XMLNS_PREFIX) || + prefix == null && qname.getLocalPart().equals(XMLNS_PREFIX) || + uri != null && uri.equals(XSLT_URI)) { + continue; + } + + // Handle all other literal attributes + final String name = translateQName(qname, stable); + LiteralAttribute attr = new LiteralAttribute(name, val, parser, this); + addAttribute(attr); + attr.setParent(this); + attr.parseContents(parser); + } + } + + // Register all namespaces that are in scope, except for those that + // are listed in the xsl:stylesheet element's *-prefixes attributes + Set> include = getNamespaceScope(this); + for (Map.Entry entry : include) { + final String prefix = entry.getKey(); + if (!prefix.equals("xml")) { + final String uri = lookupNamespace(prefix); + if (uri != null && !stable.isExcludedNamespace(uri)) { + registerNamespace(prefix, uri, stable, true); + } + } + } + + parseChildren(parser); + + // Process all attributes and register all namespaces they use + for (int i = 0; i < count; i++) { + final QName qname = parser.getQName(_attributes.getQName(i)); + final String val = _attributes.getValue(i); + + // Handle xsl:extension-element-prefixes + if (qname.equals(parser.getExtensionElementPrefixes())) { + stable.unExcludeNamespaces(val); + } + // Handle xsl:exclude-result-prefixes + else if (qname.equals(parser.getExcludeResultPrefixes())) { + stable.unExcludeNamespaces(val); + } + } + } + + protected boolean contextDependent() { + return dependentContents(); + } + + /** + * Compiles code that emits the literal element to the output handler, + * first the start tag, then namespace declaration, then attributes, + * then the element contents, and then the element end tag. Since the + * value of an attribute may depend on a variable, variables must be + * compiled first. + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Check whether all attributes are unique. + _allAttributesUnique = checkAttributesUnique(); + + // Compile code to emit element start tag + il.append(methodGen.loadHandler()); + + il.append(new PUSH(cpg, _name)); + il.append(DUP2); // duplicate these 2 args for endElement + il.append(methodGen.startElement()); + + // The value of an attribute may depend on a (sibling) variable + int j = 0; + while (j < elementCount()) { + final SyntaxTreeNode item = elementAt(j); + if (item instanceof Variable) { + item.translate(classGen, methodGen); + } + j++; + } + + // Compile code to emit namespace attributes + if (_accessedPrefixes != null) { + for (Map.Entry entry : _accessedPrefixes.entrySet()) { + final String prefix = entry.getKey(); + final String uri = entry.getValue(); + il.append(methodGen.loadHandler()); + il.append(new PUSH(cpg, prefix)); + il.append(new PUSH(cpg, uri)); + il.append(methodGen.namespace()); + } + } + + // Output all attributes + if (_attributeElements != null) { + for (SyntaxTreeNode node : _attributeElements) { + if (!(node instanceof XslAttribute)) { + node.translate(classGen, methodGen); + } + } + } + + // Compile code to emit attributes and child elements + translateContents(classGen, methodGen); + + // Compile code to emit element end tag + il.append(methodGen.endElement()); + } + + /** + * Return true if the output method is html. + */ + private boolean isHTMLOutput() { + return getStylesheet().getOutputMethod() == Stylesheet.HTML_OUTPUT; + } + + /** + * Return the ElemDesc object for an HTML element. + * Return null if the output method is not HTML or this is not a + * valid HTML element. + */ + public ElemDesc getElemDesc() { + if (isHTMLOutput()) { + return ToHTMLStream.getElemDesc(_name); + } else + return null; + } + + /** + * Return true if all attributes of this LRE have unique names. + */ + public boolean allAttributesUnique() { + return _allAttributesUnique; + } + + /** + * Check whether all attributes are unique. + */ + private boolean checkAttributesUnique() { + boolean hasHiddenXslAttribute = canProduceAttributeNodes(this, true); + if (hasHiddenXslAttribute) + return false; + + if (_attributeElements != null) { + int numAttrs = _attributeElements.size(); + Map attrsTable = null; + for (int i = 0; i < numAttrs; i++) { + SyntaxTreeNode node = _attributeElements.get(i); + + if (node instanceof UseAttributeSets) { + return false; + } else if (node instanceof XslAttribute) { + if (attrsTable == null) { + attrsTable = new HashMap<>(); + for (int k = 0; k < i; k++) { + SyntaxTreeNode n = _attributeElements.get(k); + if (n instanceof LiteralAttribute) { + LiteralAttribute literalAttr = (LiteralAttribute) n; + attrsTable.put(literalAttr.getName(), literalAttr); + } + } + } + + XslAttribute xslAttr = (XslAttribute) node; + AttributeValue attrName = xslAttr.getName(); + if (attrName instanceof AttributeValueTemplate) { + return false; + } else if (attrName instanceof SimpleAttributeValue) { + SimpleAttributeValue simpleAttr = (SimpleAttributeValue) attrName; + String name = simpleAttr.toString(); + if (name != null && attrsTable.get(name) != null) + return false; + else if (name != null) { + attrsTable.put(name, xslAttr); + } + } + } + } + } + return true; + } + + /** + * Return true if the instructions under the given SyntaxTreeNode can produce attribute nodes + * to an element. Only return false when we are sure that no attribute node is produced. + * Return true if we are not sure. If the flag ignoreXslAttribute is true, the direct + * children of the current node are not included in the check. + */ + private boolean canProduceAttributeNodes(SyntaxTreeNode node, boolean ignoreXslAttribute) { + List contents = node.getContents(); + for (SyntaxTreeNode child : contents) { + if (child instanceof Text) { + Text text = (Text) child; + if (text.isIgnore()) + continue; + else + return false; + } + // Cannot add an attribute to an element after children have been added to it. + // We can safely return false when the instruction can produce an output node. + else if (child instanceof LiteralElement + || child instanceof ValueOf + || child instanceof XslElement + || child instanceof Comment + || child instanceof Number + || child instanceof ProcessingInstruction) + return false; + else if (child instanceof XslAttribute) { + if (ignoreXslAttribute) + continue; + else + return true; + } + // In general, there is no way to check whether or + // can produce attribute nodes. and + // can also copy attribute nodes to an element. Return + // true in those cases to be safe. + else if (child instanceof CallTemplate + || child instanceof ApplyTemplates + || child instanceof Copy + || child instanceof CopyOf) + return true; + else if ((child instanceof If + || child instanceof ForEach) + && canProduceAttributeNodes(child, false)) { + return true; + } else if (child instanceof Choose) { + List chooseContents = child.getContents(); + for (SyntaxTreeNode chooseChild : chooseContents) { + if (chooseChild instanceof When || chooseChild instanceof Otherwise) { + if (canProduceAttributeNodes(chooseChild, false)) + return true; + } + } + } + } + return false; + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java new file mode 100644 index 0000000..0950cfc --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralExpr.java @@ -0,0 +1,87 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + */ +final class LiteralExpr extends Expression { + private final String _value; + private final String _namespace; + + /** + * Creates a new literal expression node. + * + * @param value the literal expression content/value. + */ + public LiteralExpr(String value) { + _value = value; + _namespace = null; + } + + /** + * Creates a new literal expression node. + * + * @param value the literal expression content/value. + * @param namespace the namespace in which the expression exists. + */ + public LiteralExpr(String value, String namespace) { + _value = value; + _namespace = namespace.equals(Constants.EMPTYSTRING) ? null : namespace; + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return _type = Type.String; + } + + public String toString() { + return "literal-expr(" + _value + ')'; + } + + protected boolean contextDependent() { + return false; + } + + protected String getValue() { + return _value; + } + + protected String getNamespace() { + return _namespace; + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + il.append(new PUSH(cpg, _value)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java new file mode 100644 index 0000000..21dcb9d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocalNameCall.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; + +import java.util.List; + +/** + * @author Morten Jorgensen + * @LastModified: Oct 2017 + */ +final class LocalNameCall extends NameBase { + + /** + * Handles calls with no parameter (current node is implicit parameter). + */ + public LocalNameCall(QName fname) { + super(fname); + } + + /** + * Handles calls with one parameter (either node or node-set). + */ + public LocalNameCall(QName fname, List arguments) { + super(fname, arguments); + } + + /** + * This method is called when the constructor is compiled in + * Stylesheet.compileConstructor() and not as the syntax tree is traversed. + */ + public void translate(ClassGenerator classGen, + MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Returns the name of a node in the DOM + final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF, + "getNodeName", + "(I)" + STRING_SIG); + + final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS, + "getLocalName", + "(Ljava/lang/String;)" + + "Ljava/lang/String;"); + super.translate(classGen, methodGen); + il.append(new INVOKEINTERFACE(getNodeName, 2)); + il.append(new INVOKESTATIC(getLocalName)); + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java new file mode 100644 index 0000000..52d77c0 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LocationPathPattern.java @@ -0,0 +1,105 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; +import com.sun.org.apache.xml.internal.dtm.Axis; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + */ +public abstract class LocationPathPattern extends Pattern { + private Template _template; + private int _importPrecedence; + private double _priority = Double.NaN; + private int _position = 0; + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + return Type.Void; // TODO + } + + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + // TODO: What does it mean to translate a Pattern ? + } + + public void setTemplate(final Template template) { + _template = template; + _priority = template.getPriority(); + _importPrecedence = template.getImportPrecedence(); + _position = template.getPosition(); + } + + public Template getTemplate() { + return _template; + } + + public final double getPriority() { + return Double.isNaN(_priority) ? getDefaultPriority() : _priority; + } + + public double getDefaultPriority() { + return 0.5; + } + + /** + * This method is used by the Mode class to prioritise patterns and + * template. This method is called for templates that are in the same + * mode and that match on the same core pattern. The rules used are: + * o) first check precedence - highest precedence wins + * o) then check priority - highest priority wins + * o) then check the position - the template that occured last wins + */ + public boolean noSmallerThan(LocationPathPattern other) { + if (_importPrecedence > other._importPrecedence) { + return true; + } else if (_importPrecedence == other._importPrecedence) { + if (_priority > other._priority) { + return true; + } else if (_priority == other._priority) { + if (_position > other._position) { + return true; + } + } + } + return false; + } + + public abstract StepPattern getKernelPattern(); + + public abstract void reduceKernelPattern(); + + public abstract boolean isWildcard(); + + public int getAxis() { + final StepPattern sp = getKernelPattern(); + return (sp != null) ? sp.getAxis() : Axis.CHILD; + } + + public String toString() { + return "root()"; + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java new file mode 100644 index 0000000..707a037 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.GOTO; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class LogicalExpr extends Expression { + + public static final int OR = 0; + public static final int AND = 1; + + private final int _op; // operator + private Expression _left; // first operand + private Expression _right; // second operand + + private static final String[] Ops = {"or", "and"}; + + /** + * Creates a new logical expression - either OR or AND. Note that the + * left- and right-hand side expressions can also be logical expressions, + * thus creating logical trees representing structures such as + * (a and (b or c) and d), etc... + */ + public LogicalExpr(int op, Expression left, Expression right) { + _op = op; + (_left = left).setParent(this); + (_right = right).setParent(this); + } + + /** + * Returns true if this expressions contains a call to position(). This is + * needed for context changes in node steps containing multiple predicates. + */ + public boolean hasPositionCall() { + return (_left.hasPositionCall() || _right.hasPositionCall()); + } + + /** + * Returns true if this expressions contains a call to last() + */ + public boolean hasLastCall() { + return (_left.hasLastCall() || _right.hasLastCall()); + } + + /** + * Returns an object representing the compile-time evaluation + * of an expression. We are only using this for function-available + * and element-available at this time. + */ + public Object evaluateAtCompileTime() { + final Object leftb = _left.evaluateAtCompileTime(); + final Object rightb = _right.evaluateAtCompileTime(); + + // Return null if we can't evaluate at compile time + if (leftb == null || rightb == null) { + return null; + } + + if (_op == AND) { + return (leftb == Boolean.TRUE && rightb == Boolean.TRUE) ? + Boolean.TRUE : Boolean.FALSE; + } else { + return (leftb == Boolean.TRUE || rightb == Boolean.TRUE) ? + Boolean.TRUE : Boolean.FALSE; + } + } + + /** + * Returns this logical expression's operator - OR or AND represented + * by 0 and 1 respectively. + */ + public int getOp() { + return (_op); + } + + /** + * Override the SyntaxTreeNode.setParser() method to make sure that the + * parser is set for sub-expressions + */ + public void setParser(Parser parser) { + super.setParser(parser); + _left.setParser(parser); + _right.setParser(parser); + } + + /** + * Returns a string describing this expression + */ + public String toString() { + return Ops[_op] + '(' + _left + ", " + _right + ')'; + } + + /** + * Type-check this expression, and possibly child expressions. + */ + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + // Get the left and right operand types + Type tleft = _left.typeCheck(stable); + Type tright = _right.typeCheck(stable); + + // Check if the operator supports the two operand types + MethodType wantType = new MethodType(Type.Void, tleft, tright); + MethodType haveType = lookupPrimop(stable, Ops[_op], wantType); + + // Yes, the operation is supported + if (haveType != null) { + // Check if left-hand side operand must be type casted + Type arg1 = haveType.argsType().get(0); + if (!arg1.identicalTo(tleft)) + _left = new CastExpr(_left, arg1); + // Check if right-hand side operand must be type casted + Type arg2 = haveType.argsType().get(1); + if (!arg2.identicalTo(tright)) + _right = new CastExpr(_right, arg1); + // Return the result type for the operator we will use + return _type = haveType.resultType(); + } + throw new TypeCheckError(this); + } + + /** + * Compile the expression - leave boolean expression on stack + */ + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + translateDesynthesized(classGen, methodGen); + synthesize(classGen, methodGen); + } + + /** + * Compile expression and update true/false-lists + */ + public void translateDesynthesized(ClassGenerator classGen, + MethodGenerator methodGen) { + + final InstructionList il = methodGen.getInstructionList(); + final SyntaxTreeNode parent = getParent(); + + // Compile AND-expression + if (_op == AND) { + + // Translate left hand side - must be true + _left.translateDesynthesized(classGen, methodGen); + + // Need this for chaining any OR-expression children + InstructionHandle middle = il.append(NOP); + + // Translate left right side - must be true + _right.translateDesynthesized(classGen, methodGen); + + // Need this for chaining any OR-expression children + InstructionHandle after = il.append(NOP); + + // Append child expression false-lists to our false-list + _falseList.append(_right._falseList.append(_left._falseList)); + + // Special case for OR-expression as a left child of AND. + // The true-list of OR must point to second clause of AND. + if ((_left instanceof LogicalExpr) && + (((LogicalExpr) _left).getOp() == OR)) { + _left.backPatchTrueList(middle); + } else if (_left instanceof NotCall) { + _left.backPatchTrueList(middle); + } else { + _trueList.append(_left._trueList); + } + + // Special case for OR-expression as a right child of AND + // The true-list of OR must point to true-list of AND. + if ((_right instanceof LogicalExpr) && + (((LogicalExpr) _right).getOp() == OR)) { + _right.backPatchTrueList(after); + } else if (_right instanceof NotCall) { + _right.backPatchTrueList(after); + } else { + _trueList.append(_right._trueList); + } + } + // Compile OR-expression + else { + // Translate left-hand side expression and produce true/false list + _left.translateDesynthesized(classGen, methodGen); + + // This GOTO is used to skip over the code for the last test + // in the case where the the first test succeeds + InstructionHandle ih = il.append(new GOTO(null)); + + // Translate right-hand side expression and produce true/false list + _right.translateDesynthesized(classGen, methodGen); + + _left._trueList.backPatch(ih); + _left._falseList.backPatch(ih.getNext()); + + _falseList.append(_right._falseList); + _trueList.add(ih).append(_right._trueList); + } + } +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java new file mode 100644 index 0000000..f10376d --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; +import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; + +/** + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @LastModified: Nov 2017 + */ +final class Message extends Instruction { + private boolean _terminate = false; + + public void parseContents(Parser parser) { + String termstr = getAttribute("terminate"); + if (termstr != null) { + _terminate = termstr.equals("yes"); + } + parseChildren(parser); + } + + public Type typeCheck(SymbolTable stable) throws TypeCheckError { + typeCheckContents(stable); + return Type.Void; + } + + @SuppressWarnings("fallthrough") // at default + public void translate(ClassGenerator classGen, MethodGenerator methodGen) { + final ConstantPoolGen cpg = classGen.getConstantPool(); + final InstructionList il = methodGen.getInstructionList(); + + // Load the translet (for call to displayMessage() function) + il.append(classGen.loadTranslet()); + + switch (elementCount()) { + case 0: + il.append(new PUSH(cpg, "")); + break; + case 1: + SyntaxTreeNode child = elementAt(0); + if (child instanceof Text) { + il.append(new PUSH(cpg, ((Text) child).getText())); + break; + } + // falls through + default: + // Push current output handler onto the stack + il.append(methodGen.loadHandler()); + + // Replace the current output handler by a ToXMLStream + il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT))); + il.append(methodGen.storeHandler()); + + // Push a reference to a StringWriter + il.append(new NEW(cpg.addClass(STRING_WRITER))); + il.append(DUP); + il.append(DUP); + il.append(new INVOKESPECIAL( + cpg.addMethodref(STRING_WRITER, "", "()V"))); + + // Load ToXMLStream + il.append(methodGen.loadHandler()); + il.append(new INVOKESPECIAL( + cpg.addMethodref(STREAM_XML_OUTPUT, "", + "()V"))); + + // Invoke output.setWriter(STRING_WRITER) + il.append(methodGen.loadHandler()); + il.append(SWAP); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setWriter", + "(" + WRITER_SIG + ")V"), 2)); + + // Invoke output.setEncoding("UTF-8") + il.append(methodGen.loadHandler()); + il.append(new PUSH(cpg, "UTF-8")); // other encodings? + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setEncoding", + "(" + STRING_SIG + ")V"), 2)); + + // Invoke output.setOmitXMLDeclaration(true) + il.append(methodGen.loadHandler()); + il.append(ICONST_1); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "setOmitXMLDeclaration", + "(Z)V"), 2)); + + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "startDocument", + "()V"), 1)); + + // Inline translation of contents + translateContents(classGen, methodGen); + + il.append(methodGen.loadHandler()); + il.append(new INVOKEINTERFACE( + cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, + "endDocument", + "()V"), 1)); + + // Call toString() on StringWriter + il.append(new INVOKEVIRTUAL( + cpg.addMethodref(STRING_WRITER, "toString", + "()" + STRING_SIG))); + + // Restore old output handler + il.append(SWAP); + il.append(methodGen.storeHandler()); + break; + } + + // Send the resulting string to the message handling method + il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, + "displayMessage", + "(" + STRING_SIG + ")V"))); + + // If 'terminate' attribute is set to 'yes': Instanciate a + // RunTimeException, but it on the stack and throw an exception + if (_terminate == true) { + // Create a new instance of RunTimeException + final int einit = cpg.addMethodref("java.lang.RuntimeException", + "", + "(Ljava/lang/String;)V"); + il.append(new NEW(cpg.addClass("java.lang.RuntimeException"))); + il.append(DUP); + il.append(new PUSH(cpg, "Termination forced by an " + + "xsl:message instruction")); + il.append(new INVOKESPECIAL(einit)); + il.append(ATHROW); + } + } + +} diff --git a/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java new file mode 100644 index 0000000..0101b66 --- /dev/null +++ b/jaxp/src/main/java/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java @@ -0,0 +1,1473 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: Mode.java,v 1.2.4.1 2005/09/19 05:18:11 pvedula Exp $ + */ + +package com.sun.org.apache.xalan.internal.xsltc.compiler; + +import com.sun.org.apache.bcel.internal.generic.BranchHandle; +import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.DUP; +import com.sun.org.apache.bcel.internal.generic.GOTO_W; +import com.sun.org.apache.bcel.internal.generic.IFLT; +import com.sun.org.apache.bcel.internal.generic.ILOAD; +import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; +import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; +import com.sun.org.apache.bcel.internal.generic.ISTORE; +import com.sun.org.apache.bcel.internal.generic.Instruction; +import com.sun.org.apache.bcel.internal.generic.InstructionHandle; +import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; +import com.sun.org.apache.bcel.internal.generic.SWITCH; +import com.sun.org.apache.bcel.internal.generic.TargetLostException; +import com.sun.org.apache.bcel.internal.util.InstructionFinder; +import com.sun.org.apache.xalan.internal.xsltc.DOM; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerator; +import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import com.sun.org.apache.xml.internal.dtm.Axis; +import com.sun.org.apache.xml.internal.dtm.DTM; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Mode gathers all the templates belonging to a given mode; + * it is responsible for generating an appropriate + * applyTemplates + (mode name) method in the translet. + * + * @author Jacek Ambroziak + * @author Santiago Pericas-Geertsen + * @author Morten Jorgensen + * @author Erwin Bolwidt + * @author G. Todd Miller + * @LastModified: Sep 2021 + */ +final class Mode implements Constants { + + /** + * The name of this mode as defined in the stylesheet. + */ + private final QName _name; + + /** + * A reference to the stylesheet object that owns this mode. + */ + private final Stylesheet _stylesheet; + + /** + * The name of the method in which this mode is compiled. + */ + private final String _methodName; + + /** + * A vector of all the templates in this mode. + */ + private List