diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk
index 20a58f81f1c..9332649cca4 100644
--- a/make/CompileJavaModules.gmk
+++ b/make/CompileJavaModules.gmk
@@ -351,11 +351,6 @@ jdk.scripting.nashorn.shell_COPY += .js .properties
################################################################################
-jdk.rmic_DISABLED_WARNINGS += deprecation
-jdk.rmic_CLEAN += .properties
-
-################################################################################
-
# No SCTP implementation on Mac OS X or AIX. These classes should be excluded.
SCTP_IMPL_CLASSES = \
$(TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/AssociationChange.java \
diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk
index ee225d99e8c..05e2238f1ab 100644
--- a/make/common/Modules.gmk
+++ b/make/common/Modules.gmk
@@ -172,7 +172,6 @@ DOCS_MODULES += \
jdk.naming.rmi \
jdk.net \
jdk.nio.mapmode \
- jdk.rmic \
jdk.scripting.nashorn \
jdk.sctp \
jdk.security.auth \
diff --git a/make/launcher/Launcher-jdk.rmic.gmk b/make/launcher/Launcher-jdk.rmic.gmk
deleted file mode 100644
index d60c3d9b60b..00000000000
--- a/make/launcher/Launcher-jdk.rmic.gmk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 2011, 2015, 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.
-#
-
-include LauncherCommon.gmk
-
-$(eval $(call SetupBuildLauncher, rmic, \
- MAIN_CLASS := sun.rmi.rmic.Main, \
- CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
-))
diff --git a/make/nashorn/element-list b/make/nashorn/element-list
index 4405748b41e..db8915cd08e 100644
--- a/make/nashorn/element-list
+++ b/make/nashorn/element-list
@@ -260,7 +260,6 @@ module:jdk.naming.rmi
module:jdk.net
jdk.net
jdk.nio
-module:jdk.rmic
module:jdk.scripting.nashorn
jdk.nashorn.api.scripting
jdk.nashorn.api.tree
diff --git a/src/java.rmi/share/classes/java/rmi/server/Operation.java b/src/java.rmi/share/classes/java/rmi/server/Operation.java
index 4a6377d749d..76817eabf00 100644
--- a/src/java.rmi/share/classes/java/rmi/server/Operation.java
+++ b/src/java.rmi/share/classes/java/rmi/server/Operation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, 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
@@ -29,8 +29,7 @@ package java.rmi.server;
* An Operation contains a description of a Java method.
* Operation objects were used in JDK1.1 version stubs and
* skeletons. The Operation class is not needed for 1.2 style
- * stubs (stubs generated with rmic -v1.2); hence, this class
- * is deprecated.
+ * stubs; hence, this class is deprecated.
*
* @since 1.1
* @deprecated no replacement
diff --git a/src/java.rmi/share/classes/java/rmi/server/Skeleton.java b/src/java.rmi/share/classes/java/rmi/server/Skeleton.java
index b4a2ac449c9..9f2daafb864 100644
--- a/src/java.rmi/share/classes/java/rmi/server/Skeleton.java
+++ b/src/java.rmi/share/classes/java/rmi/server/Skeleton.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, 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
@@ -30,11 +30,9 @@ import java.rmi.Remote;
* The Skeleton interface is used solely by the RMI
* implementation.
*
- *
Every version 1.1 (and version 1.1 compatible skeletons generated in
- * 1.2 using rmic -vcompat) skeleton class generated by the rmic
- * stub compiler implements this interface. A skeleton for a remote object is
- * a server-side entity that dispatches calls to the actual remote object
- * implementation.
+ *
Every version 1.1 compatible skeleton implements this interface.
+ * A skeleton for a remote object is a server-side entity that dispatches calls
+ * to the actual remote object implementation.
*
* @author Ann Wollrath
* @since 1.1
diff --git a/src/java.rmi/share/classes/java/rmi/server/SkeletonMismatchException.java b/src/java.rmi/share/classes/java/rmi/server/SkeletonMismatchException.java
index 901c27d3a37..e532034b351 100644
--- a/src/java.rmi/share/classes/java/rmi/server/SkeletonMismatchException.java
+++ b/src/java.rmi/share/classes/java/rmi/server/SkeletonMismatchException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, 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
@@ -33,7 +33,7 @@ import java.rmi.RemoteException;
* remote method names or signatures in this interface have changed or
* that the stub class used to make the call and the skeleton
* receiving the call were not generated by the same version of
- * the stub compiler (rmic).
+ * the stub protocol.
*
* @author Roger Riggs
* @since 1.1
diff --git a/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java b/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
index 3f982c02e0d..8ec91fdb251 100644
--- a/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
+++ b/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, 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
@@ -32,17 +32,14 @@ import sun.rmi.transport.LiveRef;
/**
* Used for exporting a remote object with JRMP and obtaining a stub
- * that communicates to the remote object. Stubs are either generated
- * at runtime using dynamic proxy objects, or they are generated statically
- * at build time, typically using the {@code rmic} tool.
+ * that communicates to the remote object. Stubs are generated
+ * at runtime using dynamic proxy objects.
*
*
There are eight ways to export remote objects:
*
@@ -90,10 +87,8 @@ import sun.rmi.transport.LiveRef;
*
The default value of the
* {@code java.rmi.server.ignoreStubClasses} property is {@code false}.
*
- *
Statically generated stubs are typically pregenerated from the
- * remote object's class using the {@code rmic} tool. A static stub is
- * loaded and an instance of that stub class is constructed as described
- * below.
+ *
Statically generated stubs are typically pregenerated from the remote object's class.
+ * A static stub is loaded and an instance of that stub class is constructed as described below.
*
*
*
diff --git a/src/java.rmi/share/classes/java/rmi/server/package-info.java b/src/java.rmi/share/classes/java/rmi/server/package-info.java
index 01a8b9aa9d4..b309ecaa19a 100644
--- a/src/java.rmi/share/classes/java/rmi/server/package-info.java
+++ b/src/java.rmi/share/classes/java/rmi/server/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2020, 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
@@ -24,31 +24,22 @@
*/
/**
- * Provides classes and interfaces for supporting the server
- * side of RMI. A group of classes are used by the stubs and skeletons
- * generated by the rmic stub compiler. Another group of classes
- * implements the RMI Transport protocol and HTTP tunneling.
- *
- * Deprecated: HTTP Tunneling. The HTTP tunneling
- * mechanism has been deprecated. See {@link java.rmi.server.RMISocketFactory} for
- * further information.
+ * Provides classes and interfaces for supporting the server side of RMI.
+ * One group of classes are used by the static stubs and skeletons.
+ * Another group of classes implements the RMI Transport protocol.
*
*
Deprecated: Skeletons and Static Stubs.
*
* Skeletons and statically generated stubs are deprecated. This
* includes the APIs in this package that require the use of skeletons
- * or static stubs, the runtime support for them, and the use of the
- * {@code rmic} stub compiler to generate them. Support for skeletons
+ * or static stubs and the runtime support for them. Support for skeletons
* and static stubs may be removed in a future release of the
* platform. Skeletons are unnecessary, as server-side method dispatching
* is handled directly by the RMI runtime. Statically generated stubs are
* unnecessary, as stubs are generated dynamically using {@link
* java.lang.reflect.Proxy Proxy} objects. See {@link
* java.rmi.server.UnicastRemoteObject UnicastRemoteObject} for
- * information about dynamic stub generation. Generation of skeletons and
- * static stubs was typically performed as part of an application's build
- * process by calling the {@code rmic} tool. This is unnecessary, and
- * calls to {@code rmic} can simply be omitted.
+ * information about dynamic stub generation.
*
* @since 1.1
*/
diff --git a/src/jdk.rmic/share/classes/module-info.java b/src/jdk.rmic/share/classes/module-info.java
deleted file mode 100644
index 02f8edf943c..00000000000
--- a/src/jdk.rmic/share/classes/module-info.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2014, 2019, 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.
- */
-
-/**
- * Defines the {@index rmic rmic} compiler for generating stubs and
- * skeletons using the Java Remote Method Protocol (JRMP) for remote objects.
- *
- * @toolGuide rmic
- *
- * @moduleGraph
- * @since 9
- */
-module jdk.rmic {
- requires jdk.compiler;
- requires jdk.javadoc;
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/BatchEnvironment.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/BatchEnvironment.java
deleted file mode 100644
index c9304b762ea..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/BatchEnvironment.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (c) 1996, 2015, 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.
- */
-
-/*****************************************************************************/
-/* Copyright (c) IBM Corporation 1998 */
-/* */
-/* (C) Copyright IBM Corp. 1998 */
-/* */
-/*****************************************************************************/
-
-package sun.rmi.rmic;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes;
-import sun.tools.java.ClassPath;
-
-/**
- * BatchEnvironment for rmic extends javac's version in four ways:
- * 1. It overrides errorString() to handle looking for rmic-specific
- * error messages in rmic's resource bundle
- * 2. It provides a mechanism for recording intermediate generated
- * files so that they can be deleted later.
- * 3. It holds a reference to the Main instance so that generators
- * can refer to it.
- * 4. It provides access to the ClassPath passed to the constructor.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-@SuppressWarnings("deprecation")
-public class BatchEnvironment extends sun.tools.javac.BatchEnvironment {
-
- /** instance of Main which created this environment */
- private Main main;
-
- /**
- * Create a ClassPath object for rmic from a class path string.
- */
- public static ClassPath createClassPath(String classPathString) {
- ClassPath[] paths = classPaths(null, classPathString, null);
- return paths[1];
- }
-
- /**
- * Create a ClassPath object for rmic from the relevant command line
- * options for class path and boot class path.
- */
- public static ClassPath createClassPath(String classPathString,
- String sysClassPathString)
- {
- /**
- * Previously, this method delegated to the
- * sun.tools.javac.BatchEnvironment.classPaths method in order
- * to supply default values for paths not specified on the
- * command line, expand extensions directories into specific
- * JAR files, and construct the ClassPath object-- but as part
- * of the fix for 6473331, which adds support for Class-Path
- * manifest entries in JAR files, those steps are now handled
- * here directly, with the help of a Path utility class copied
- * from the new javac implementation (see below).
- */
- Path path = new Path();
-
- if (sysClassPathString == null) {
- sysClassPathString = System.getProperty("sun.boot.class.path");
- }
- if (sysClassPathString != null) {
- path.addFiles(sysClassPathString);
- }
-
- /*
- * Class-Path manifest entries are supported for JAR files
- * everywhere except in the boot class path.
- */
- path.expandJarClassPaths(true);
-
- /*
- * In the application class path, an empty element means
- * the current working directory.
- */
- path.emptyPathDefault(".");
-
- if (classPathString == null) {
- // The env.class.path property is the user's CLASSPATH
- // environment variable, and it set by the wrapper (ie,
- // javac.exe).
- classPathString = System.getProperty("env.class.path");
- if (classPathString == null) {
- classPathString = ".";
- }
- }
- path.addFiles(classPathString);
-
- return new ClassPath(path.toArray(new String[path.size()]));
- }
-
- /**
- * Create a BatchEnvironment for rmic with the given class path,
- * stream for messages and Main.
- */
- public BatchEnvironment(OutputStream out, ClassPath path, Main main) {
- super(out, new ClassPath(""), path);
- // use empty "sourcePath" (see 4666958)
- this.main = main;
- }
-
- /**
- * Get the instance of Main which created this environment.
- */
- public Main getMain() {
- return main;
- }
-
- /**
- * Get the ClassPath.
- */
- public ClassPath getClassPath() {
- return binaryPath;
- }
-
- /** list of generated source files created in this environment */
- private Vector generatedFiles = new Vector<>();
-
- /**
- * Remember a generated source file generated so that it
- * can be removed later, if appropriate.
- */
- public void addGeneratedFile(File file) {
- generatedFiles.addElement(file);
- }
-
- /**
- * Delete all the generated source files made during the execution
- * of this environment (those that have been registered with the
- * "addGeneratedFile" method).
- */
- public void deleteGeneratedFiles() {
- synchronized(generatedFiles) {
- Enumeration enumeration = generatedFiles.elements();
- while (enumeration.hasMoreElements()) {
- File file = enumeration.nextElement();
- file.delete();
- }
- generatedFiles.removeAllElements();
- }
- }
-
- /**
- * Release resources, if any.
- */
- public void shutdown() {
- main = null;
- generatedFiles = null;
- super.shutdown();
- }
-
- /**
- * Return the formatted, localized string for a named error message
- * and supplied arguments. For rmic error messages, with names that
- * being with "rmic.", look up the error message in rmic's resource
- * bundle; otherwise, defer to java's superclass method.
- */
- public String errorString(String err,
- Object arg0, Object arg1, Object arg2)
- {
- if (err.startsWith("rmic.") || err.startsWith("warn.rmic.")) {
- String result = Main.getText(err,
- (arg0 != null ? arg0.toString() : null),
- (arg1 != null ? arg1.toString() : null),
- (arg2 != null ? arg2.toString() : null));
-
- if (err.startsWith("warn.")) {
- result = "warning: " + result;
- }
- return result;
- } else {
- return super.errorString(err, arg0, arg1, arg2);
- }
- }
- public void reset() {
- }
-
- /**
- * Utility for building paths of directories and JAR files. This
- * class was copied from com.sun.tools.javac.util.Paths as part of
- * the fix for 6473331, which adds support for Class-Path manifest
- * entries in JAR files. Diagnostic code is simply commented out
- * because rmic silently ignored these conditions historically.
- */
- private static class Path extends LinkedHashSet {
- private static final long serialVersionUID = 0;
- private static final boolean warn = false;
-
- private static class PathIterator implements Collection {
- private int pos = 0;
- private final String path;
- private final String emptyPathDefault;
-
- public PathIterator(String path, String emptyPathDefault) {
- this.path = path;
- this.emptyPathDefault = emptyPathDefault;
- }
- public PathIterator(String path) { this(path, null); }
- public Iterator iterator() {
- return new Iterator() {
- public boolean hasNext() {
- return pos <= path.length();
- }
- public String next() {
- int beg = pos;
- int end = path.indexOf(File.pathSeparator, beg);
- if (end == -1)
- end = path.length();
- pos = end + 1;
-
- if (beg == end && emptyPathDefault != null)
- return emptyPathDefault;
- else
- return path.substring(beg, end);
- }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- // required for Collection.
- public int size() {
- throw new UnsupportedOperationException();
- }
- public boolean isEmpty() {
- throw new UnsupportedOperationException();
- }
- public boolean contains(Object o) {
- throw new UnsupportedOperationException();
- }
- public Object[] toArray() {
- throw new UnsupportedOperationException();
- }
- public T[] toArray(T[] a) {
- throw new UnsupportedOperationException();
- }
- public boolean add(String o) {
- throw new UnsupportedOperationException();
- }
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
- public boolean containsAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
- public boolean addAll(Collection extends String> c) {
- throw new UnsupportedOperationException();
- }
- public boolean removeAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
- public boolean retainAll(Collection> c) {
- throw new UnsupportedOperationException();
- }
- public void clear() {
- throw new UnsupportedOperationException();
- }
- public boolean equals(Object o) {
- throw new UnsupportedOperationException();
- }
- public int hashCode() {
- throw new UnsupportedOperationException();
- }
- }
-
- /** Is this the name of a zip file? */
- private static boolean isZip(String name) {
- return new File(name).isFile();
- }
-
- private boolean expandJarClassPaths = false;
-
- public Path expandJarClassPaths(boolean x) {
- expandJarClassPaths = x;
- return this;
- }
-
- /** What to use when path element is the empty string */
- private String emptyPathDefault = null;
-
- public Path emptyPathDefault(String x) {
- emptyPathDefault = x;
- return this;
- }
-
- public Path() { super(); }
-
- public Path addDirectories(String dirs, boolean warn) {
- if (dirs != null)
- for (String dir : new PathIterator(dirs))
- addDirectory(dir, warn);
- return this;
- }
-
- public Path addDirectories(String dirs) {
- return addDirectories(dirs, warn);
- }
-
- private void addDirectory(String dir, boolean warn) {
- if (! new File(dir).isDirectory()) {
-// if (warn)
-// log.warning(Position.NOPOS,
-// "dir.path.element.not.found", dir);
- return;
- }
-
- for (String direntry : new File(dir).list()) {
- String canonicalized = direntry.toLowerCase();
- if (canonicalized.endsWith(".jar") ||
- canonicalized.endsWith(".zip"))
- addFile(dir + File.separator + direntry, warn);
- }
- }
-
- public Path addFiles(String files, boolean warn) {
- if (files != null)
- for (String file : new PathIterator(files, emptyPathDefault))
- addFile(file, warn);
- return this;
- }
-
- public Path addFiles(String files) {
- return addFiles(files, warn);
- }
-
- private void addFile(String file, boolean warn) {
- if (contains(file)) {
- /* Discard duplicates and avoid infinite recursion */
- return;
- }
-
- File ele = new File(file);
- if (! ele.exists()) {
- /* No such file or directory exist */
- if (warn)
-// log.warning(Position.NOPOS,
-// "path.element.not.found", file);
- return;
- }
-
- if (ele.isFile()) {
- /* File is an ordinay file */
- String arcname = file.toLowerCase();
- if (! (arcname.endsWith(".zip") ||
- arcname.endsWith(".jar"))) {
- /* File name don't have right extension */
-// if (warn)
-// log.warning(Position.NOPOS,
-// "invalid.archive.file", file);
- return;
- }
- }
-
- /* Now what we have left is either a directory or a file name
- confirming to archive naming convention */
-
- super.add(file);
- if (expandJarClassPaths && isZip(file))
- addJarClassPath(file, warn);
- }
-
- // Adds referenced classpath elements from a jar's Class-Path
- // Manifest entry. In some future release, we may want to
- // update this code to recognize URLs rather than simple
- // filenames, but if we do, we should redo all path-related code.
- private void addJarClassPath(String jarFileName, boolean warn) {
- try {
- String jarParent = new File(jarFileName).getParent();
- JarFile jar = new JarFile(jarFileName);
-
- try {
- Manifest man = jar.getManifest();
- if (man == null) return;
-
- Attributes attr = man.getMainAttributes();
- if (attr == null) return;
-
- String path = attr.getValue(Attributes.Name.CLASS_PATH);
- if (path == null) return;
-
- for (StringTokenizer st = new StringTokenizer(path);
- st.hasMoreTokens();) {
- String elt = st.nextToken();
- if (jarParent != null)
- elt = new File(jarParent, elt).getCanonicalPath();
- addFile(elt, warn);
- }
- } finally {
- jar.close();
- }
- } catch (IOException e) {
-// log.error(Position.NOPOS,
-// "error.reading.file", jarFileName,
-// e.getLocalizedMessage());
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/Constants.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/Constants.java
deleted file mode 100644
index 3d958ffedbc..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/Constants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1997, 2003, 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 sun.rmi.rmic;
-
-import sun.tools.java.Identifier;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public interface Constants extends sun.tools.java.Constants {
-
- /*
- * Identifiers potentially useful for all Generators
- */
- public static final Identifier idRemote =
- Identifier.lookup("java.rmi.Remote");
- public static final Identifier idRemoteException =
- Identifier.lookup("java.rmi.RemoteException");
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/Generator.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/Generator.java
deleted file mode 100644
index 6a9dc893dd9..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/Generator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1998, 2007, 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.
- */
-
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999 All Rights Reserved
- *
- */
-
-package sun.rmi.rmic;
-
-import java.io.File;
-import sun.tools.java.ClassDefinition;
-
-/**
- * Generator defines the protocol for back-end implementations to be added
- * to rmic. See the rmic.properties file for a description of the format for
- * adding new Generators to rmic.
- *
- * Classes implementing this interface must have a public default constructor
- * which should set any required arguments to their defaults. When Main
- * encounters a command line argument which maps to a specific Generator
- * subclass, it will instantiate one and call parseArgs(...). At some later
- * point, Main will invoke the generate(...) method once for _each_ class passed
- * on the command line.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Bryan Atsatt
- */
-public interface Generator {
-
- /**
- * Examine and consume command line arguments.
- * @param argv The command line arguments. Ignore null
- * and unknown arguments. Set each consumed argument to null.
- * @param main Report any errors using the main.error() methods.
- * @return true if no errors, false otherwise.
- */
- public boolean parseArgs(String argv[], Main main);
-
- /**
- * Generate output. Any source files created which need compilation should
- * be added to the compiler environment using the addGeneratedFile(File)
- * method.
- *
- * @param env The compiler environment
- * @param cdef The definition for the implementation class or interface from
- * which to generate output
- * @param destDir The directory for the root of the package hierarchy
- * for generated files. May be null.
- */
- public void generate(BatchEnvironment env, ClassDefinition cdef, File destDir);
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/IndentingWriter.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/IndentingWriter.java
deleted file mode 100644
index adbbd360c30..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/IndentingWriter.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, 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.
- */
-
-/*****************************************************************************/
-/* Copyright (c) IBM Corporation 1998 */
-/* */
-/* (C) Copyright IBM Corp. 1998 */
-/* */
-/*****************************************************************************/
-
-package sun.rmi.rmic;
-
-import java.io.Writer;
-import java.io.BufferedWriter;
-import java.io.IOException;
-
-/**
- * IndentingWriter is a BufferedWriter subclass that supports automatic
- * indentation of lines of text written to the underlying Writer.
- *
- * Methods are provided for compact, convenient indenting, writing text,
- * and writing lines in various combinations.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public class IndentingWriter extends BufferedWriter {
-
- /** true if the next character written is the first on a line */
- private boolean beginningOfLine = true;
-
- /** current number of spaces to prepend to lines */
- private int currentIndent = 0;
-
- /** number of spaces to change indent when indenting in or out */
- private int indentStep = 4;
-
- /** number of spaces to convert into tabs. Use MAX_VALUE to disable */
- private int tabSize = 8;
-
- /**
- * Create a new IndentingWriter that writes indented text to the
- * given Writer. Use the default indent step of four spaces.
- */
- public IndentingWriter(Writer out) {
- super(out);
- }
-
- /**
- * Create a new IndentingWriter that writes indented text to the
- * given Writer and uses the supplied indent step.
- */
- public IndentingWriter(Writer out, int step) {
- this(out);
-
- if (indentStep < 0)
- throw new IllegalArgumentException("negative indent step");
-
- indentStep = step;
- }
-
- /**
- * Create a new IndentingWriter that writes indented text to the
- * given Writer and uses the supplied indent step and tab size.
- */
- public IndentingWriter(Writer out, int step, int tabSize) {
- this(out);
-
- if (indentStep < 0)
- throw new IllegalArgumentException("negative indent step");
-
- indentStep = step;
- this.tabSize = tabSize;
- }
-
- /**
- * Write a single character.
- */
- public void write(int c) throws IOException {
- checkWrite();
- super.write(c);
- }
-
- /**
- * Write a portion of an array of characters.
- */
- public void write(char[] cbuf, int off, int len) throws IOException {
- if (len > 0) {
- checkWrite();
- }
- super.write(cbuf, off, len);
- }
-
- /**
- * Write a portion of a String.
- */
- public void write(String s, int off, int len) throws IOException {
- if (len > 0) {
- checkWrite();
- }
- super.write(s, off, len);
- }
-
- /**
- * Write a line separator. The next character written will be
- * preceded by an indent.
- */
- public void newLine() throws IOException {
- super.newLine();
- beginningOfLine = true;
- }
-
- /**
- * Check if an indent needs to be written before writing the next
- * character.
- *
- * The indent generation is optimized (and made consistent with
- * certain coding conventions) by condensing groups of eight spaces
- * into tab characters.
- */
- protected void checkWrite() throws IOException {
- if (beginningOfLine) {
- beginningOfLine = false;
- int i = currentIndent;
- while (i >= tabSize) {
- super.write('\t');
- i -= tabSize;
- }
- while (i > 0) {
- super.write(' ');
- -- i;
- }
- }
- }
-
- /**
- * Increase the current indent by the indent step.
- */
- protected void indentIn() {
- currentIndent += indentStep;
- }
-
- /**
- * Decrease the current indent by the indent step.
- */
- protected void indentOut() {
- currentIndent -= indentStep;
- if (currentIndent < 0)
- currentIndent = 0;
- }
-
- /**
- * Indent in.
- */
- public void pI() {
- indentIn();
- }
-
- /**
- * Indent out.
- */
- public void pO() {
- indentOut();
- }
-
- /**
- * Write string.
- */
- public void p(String s) throws IOException {
- write(s);
- }
-
- /**
- * End current line.
- */
- public void pln() throws IOException {
- newLine();
- }
-
- /**
- * Write string; end current line.
- */
- public void pln(String s) throws IOException {
- p(s);
- pln();
- }
-
- /**
- * Write string; end current line; indent in.
- */
- public void plnI(String s) throws IOException {
- p(s);
- pln();
- pI();
- }
-
- /**
- * Indent out; write string.
- */
- public void pO(String s) throws IOException {
- pO();
- p(s);
- }
-
- /**
- * Indent out; write string; end current line.
- */
- public void pOln(String s) throws IOException {
- pO(s);
- pln();
- }
-
- /**
- * Indent out; write string; end current line; indent in.
- *
- * This method is useful for generating lines of code that both
- * end and begin nested blocks, like "} else {".
- */
- public void pOlnI(String s) throws IOException {
- pO(s);
- pln();
- pI();
- }
-
- /**
- * Write Object.
- */
- public void p(Object o) throws IOException {
- write(o.toString());
- }
- /**
- * Write Object; end current line.
- */
- public void pln(Object o) throws IOException {
- p(o.toString());
- pln();
- }
-
- /**
- * Write Object; end current line; indent in.
- */
- public void plnI(Object o) throws IOException {
- p(o.toString());
- pln();
- pI();
- }
-
- /**
- * Indent out; write Object.
- */
- public void pO(Object o) throws IOException {
- pO();
- p(o.toString());
- }
-
- /**
- * Indent out; write Object; end current line.
- */
- public void pOln(Object o) throws IOException {
- pO(o.toString());
- pln();
- }
-
- /**
- * Indent out; write Object; end current line; indent in.
- *
- * This method is useful for generating lines of code that both
- * end and begin nested blocks, like "} else {".
- */
- public void pOlnI(Object o) throws IOException {
- pO(o.toString());
- pln();
- pI();
- }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/Main.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/Main.java
deleted file mode 100644
index 2495b6712c8..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/Main.java
+++ /dev/null
@@ -1,857 +0,0 @@
-/*
- * Copyright (c) 1996, 2018, 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.
- */
-
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999 All Rights Reserved
- *
- */
-
-package sun.rmi.rmic;
-
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-import java.util.MissingResourceException;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.ByteArrayOutputStream;
-
-import sun.tools.java.ClassFile;
-import sun.tools.java.ClassDefinition;
-import sun.tools.java.ClassDeclaration;
-import sun.tools.java.ClassNotFound;
-import sun.tools.java.Identifier;
-import sun.tools.java.ClassPath;
-
-import sun.tools.javac.SourceClass;
-import sun.tools.util.CommandLine;
-import java.lang.reflect.Constructor;
-import java.util.Properties;
-
-/**
- * Main "rmic" program.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public class Main implements sun.rmi.rmic.Constants {
- String sourcePathArg;
- String sysClassPathArg;
- String classPathString;
- File destDir;
- int flags;
- long tm;
- Vector classes;
- boolean nowrite;
- boolean nocompile;
- boolean keepGenerated;
- boolean status;
- String[] generatorArgs;
- Vector generators;
- Class extends BatchEnvironment> environmentClass =
- BatchEnvironment.class;
- /**
- * Name of the program.
- */
- String program;
-
- /**
- * The stream where error message are printed.
- */
- OutputStream out;
-
- /**
- * Constructor.
- */
- public Main(OutputStream out, String program) {
- this.out = out;
- this.program = program;
- }
-
- /**
- * Output a message.
- */
- public void output(String msg) {
- PrintStream out =
- this.out instanceof PrintStream ? (PrintStream)this.out
- : new PrintStream(this.out, true);
- out.println(msg);
- }
-
- /**
- * Top level error message. This method is called when the
- * environment could not be set up yet.
- */
- public void error(String msg) {
- output(getText(msg));
- }
-
- public void error(String msg, String arg1) {
- output(getText(msg, arg1));
- }
-
- public void error(String msg, String arg1, String arg2) {
- output(getText(msg, arg1, arg2));
- }
-
- /**
- * Usage
- */
- public void usage() {
- error("rmic.usage", program);
- }
-
- /**
- * Run the compiler
- */
- public synchronized boolean compile(String argv[]) {
-
- if (!parseArgs(argv)) {
- return false;
- }
-
- if (classes.size() == 0) {
- usage();
- return false;
- }
-
- if ((flags & F_WARNINGS) != 0) {
- for (Generator g : generators) {
- if (g instanceof RMIGenerator) {
- output(getText("rmic.jrmp.stubs.deprecated", program));
- break;
- }
- }
- }
-
- return doCompile();
- }
-
- /**
- * Get the destination directory.
- */
- public File getDestinationDir() {
- return destDir;
- }
-
- /**
- * Parse the arguments for compile.
- */
- public boolean parseArgs(String argv[]) {
- sourcePathArg = null;
- sysClassPathArg = null;
-
- classPathString = null;
- destDir = null;
- flags = F_WARNINGS;
- tm = System.currentTimeMillis();
- classes = new Vector<>();
- nowrite = false;
- nocompile = false;
- keepGenerated = false;
- generatorArgs = getArray("generator.args",true);
- if (generatorArgs == null) {
- return false;
- }
- generators = new Vector<>();
-
- // Pre-process command line for @file arguments
- try {
- argv = CommandLine.parse(argv);
- } catch (FileNotFoundException e) {
- error("rmic.cant.read", e.getMessage());
- return false;
- } catch (IOException e) {
- e.printStackTrace(out instanceof PrintStream ?
- (PrintStream) out :
- new PrintStream(out, true));
- return false;
- }
-
- // Parse arguments
- for (int i = 0 ; i < argv.length ; i++) {
- if (argv[i] != null) {
- if (argv[i].equals("-g")) {
- flags &= ~F_OPT;
- flags |= F_DEBUG_LINES | F_DEBUG_VARS;
- argv[i] = null;
- } else if (argv[i].equals("-O")) {
- flags &= ~F_DEBUG_LINES;
- flags &= ~F_DEBUG_VARS;
- flags |= F_OPT | F_DEPENDENCIES;
- argv[i] = null;
- } else if (argv[i].equals("-nowarn")) {
- flags &= ~F_WARNINGS;
- argv[i] = null;
- } else if (argv[i].equals("-debug")) {
- flags |= F_DUMP;
- argv[i] = null;
- } else if (argv[i].equals("-depend")) {
- flags |= F_DEPENDENCIES;
- argv[i] = null;
- } else if (argv[i].equals("-verbose")) {
- flags |= F_VERBOSE;
- argv[i] = null;
- } else if (argv[i].equals("-nowrite")) {
- nowrite = true;
- argv[i] = null;
- } else if (argv[i].equals("-Xnocompile")) {
- nocompile = true;
- keepGenerated = true;
- argv[i] = null;
- } else if (argv[i].equals("-keep") ||
- argv[i].equals("-keepgenerated")) {
- keepGenerated = true;
- argv[i] = null;
- } else if (argv[i].equals("-show")) {
- error("rmic.option.unsupported", "-show");
- usage();
- return false;
- } else if (argv[i].equals("-classpath")) {
- if ((i + 1) < argv.length) {
- if (classPathString != null) {
- error("rmic.option.already.seen", "-classpath");
- usage();
- return false;
- }
- argv[i] = null;
- classPathString = argv[++i];
- argv[i] = null;
- } else {
- error("rmic.option.requires.argument", "-classpath");
- usage();
- return false;
- }
- } else if (argv[i].equals("-sourcepath")) {
- if ((i + 1) < argv.length) {
- if (sourcePathArg != null) {
- error("rmic.option.already.seen", "-sourcepath");
- usage();
- return false;
- }
- argv[i] = null;
- sourcePathArg = argv[++i];
- argv[i] = null;
- } else {
- error("rmic.option.requires.argument", "-sourcepath");
- usage();
- return false;
- }
- } else if (argv[i].equals("-bootclasspath")) {
- if ((i + 1) < argv.length) {
- if (sysClassPathArg != null) {
- error("rmic.option.already.seen", "-bootclasspath");
- usage();
- return false;
- }
- argv[i] = null;
- sysClassPathArg = argv[++i];
- argv[i] = null;
- } else {
- error("rmic.option.requires.argument", "-bootclasspath");
- usage();
- return false;
- }
- } else if (argv[i].equals("-d")) {
- if ((i + 1) < argv.length) {
- if (destDir != null) {
- error("rmic.option.already.seen", "-d");
- usage();
- return false;
- }
- argv[i] = null;
- destDir = new File(argv[++i]);
- argv[i] = null;
- if (!destDir.exists()) {
- error("rmic.no.such.directory", destDir.getPath());
- usage();
- return false;
- }
- } else {
- error("rmic.option.requires.argument", "-d");
- usage();
- return false;
- }
- } else {
- if (!checkGeneratorArg(argv,i)) {
- usage();
- return false;
- }
- }
- }
- }
-
-
- // Now that all generators have had a chance at the args,
- // scan what's left for classes and illegal args...
-
- for (int i = 0; i < argv.length; i++) {
- if (argv[i] != null) {
- if (argv[i].startsWith("-")) {
- error("rmic.no.such.option", argv[i]);
- usage();
- return false;
- } else {
- classes.addElement(argv[i]);
- }
- }
- }
-
-
- // If the generators vector is empty, add the default generator...
-
- if (generators.size() == 0) {
- addGenerator("default");
- }
-
- return true;
- }
-
- /**
- * If this argument is for a generator, instantiate it, call
- * parseArgs(...) and add generator to generators vector.
- * Returns false on error.
- */
- protected boolean checkGeneratorArg(String[] argv, int currentIndex) {
- boolean result = true;
- if (argv[currentIndex].startsWith("-")) {
- String arg = argv[currentIndex].substring(1).toLowerCase(); // Remove '-'
- for (int i = 0; i < generatorArgs.length; i++) {
- if (arg.equalsIgnoreCase(generatorArgs[i])) {
- // Got a match, add Generator and call parseArgs...
- Generator gen = addGenerator(arg);
- if (gen == null) {
- return false;
- }
- result = gen.parseArgs(argv,this);
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Instantiate and add a generator to the generators array.
- */
- protected Generator addGenerator(String arg) {
-
- Generator gen;
-
- // Create an instance of the generator and add it to
- // the array...
-
- String className = getString("generator.class." + arg);
- if (className == null) {
- error("rmic.missing.property",arg);
- return null;
- }
-
- try {
- gen = (Generator) Class.forName(className).newInstance();
- } catch (Exception e) {
- error("rmic.cannot.instantiate",className);
- return null;
- }
-
- generators.addElement(gen);
-
- // Get the environment required by this generator...
-
- Class> envClass = BatchEnvironment.class;
- String env = getString("generator.env." + arg);
- if (env != null) {
- try {
- envClass = Class.forName(env);
-
- // Is the new class a subclass of the current one?
-
- if (environmentClass.isAssignableFrom(envClass)) {
-
- // Yes, so switch to the new one...
-
- environmentClass = envClass.asSubclass(BatchEnvironment.class);
-
- } else {
-
- // No. Is the current class a subclass of the
- // new one?
-
- if (!envClass.isAssignableFrom(environmentClass)) {
-
- // No, so it's a conflict...
-
- error("rmic.cannot.use.both",environmentClass.getName(),envClass.getName());
- return null;
- }
- }
- } catch (ClassNotFoundException e) {
- error("rmic.class.not.found",env);
- return null;
- }
- }
-
- return gen;
- }
-
- /**
- * Grab a resource string and parse it into an array of strings. Assumes
- * comma separated list.
- * @param name The resource name.
- * @param mustExist If true, throws error if resource does not exist. If
- * false and resource does not exist, returns zero element array.
- */
- protected String[] getArray(String name, boolean mustExist) {
- String[] result = null;
- String value = getString(name);
- if (value == null) {
- if (mustExist) {
- error("rmic.resource.not.found",name);
- return null;
- } else {
- return new String[0];
- }
- }
-
- StringTokenizer parser = new StringTokenizer(value,", \t\n\r", false);
- int count = parser.countTokens();
- result = new String[count];
- for (int i = 0; i < count; i++) {
- result[i] = parser.nextToken();
- }
-
- return result;
- }
-
- /**
- * Get the correct type of BatchEnvironment
- */
- public BatchEnvironment getEnv() {
-
- ClassPath classPath =
- BatchEnvironment.createClassPath(classPathString,
- sysClassPathArg);
- BatchEnvironment result = null;
- try {
- Class>[] ctorArgTypes = {OutputStream.class,ClassPath.class,Main.class};
- Object[] ctorArgs = {out,classPath,this};
- Constructor extends BatchEnvironment> constructor =
- environmentClass.getConstructor(ctorArgTypes);
- result = constructor.newInstance(ctorArgs);
- result.reset();
- }
- catch (Exception e) {
- error("rmic.cannot.instantiate",environmentClass.getName());
- }
- return result;
- }
-
-
- /**
- * Do the compile with the switches and files already supplied
- */
- public boolean doCompile() {
- // Create batch environment
- BatchEnvironment env = getEnv();
- env.flags |= flags;
-
- // Set the classfile version numbers
- // Compat and 1.1 stubs must retain the old version number.
- env.majorVersion = 45;
- env.minorVersion = 3;
-
- // Preload the "out of memory" error string just in case we run
- // out of memory during the compile.
- String noMemoryErrorString = getText("rmic.no.memory");
- String stackOverflowErrorString = getText("rmic.stack.overflow");
-
- try {
- /** Load the classes on the command line
- * Replace the entries in classes with the ClassDefinition for the class
- */
- for (int i = classes.size()-1; i >= 0; i-- ) {
- Identifier implClassName =
- Identifier.lookup(classes.elementAt(i));
-
- /*
- * Fix bugid 4049354: support using '.' as an inner class
- * qualifier on the command line (previously, only mangled
- * inner class names were understood, like "pkg.Outer$Inner").
- *
- * The following method, also used by "javap", resolves the
- * given unmangled inner class name to the appropriate
- * internal identifier. For example, it translates
- * "pkg.Outer.Inner" to "pkg.Outer. Inner".
- */
- implClassName = env.resolvePackageQualifiedName(implClassName);
- /*
- * But if we use such an internal inner class name identifier
- * to load the class definition, the Java compiler will notice
- * if the impl class is a "private" inner class and then deny
- * skeletons (needed unless "-v1.2" is used) the ability to
- * cast to it. To work around this problem, we mangle inner
- * class name identifiers to their binary "outer" class name:
- * "pkg.Outer. Inner" becomes "pkg.Outer$Inner".
- */
- implClassName = Names.mangleClass(implClassName);
-
- ClassDeclaration decl = env.getClassDeclaration(implClassName);
- try {
- ClassDefinition def = decl.getClassDefinition(env);
- for (int j = 0; j < generators.size(); j++) {
- Generator gen = generators.elementAt(j);
- gen.generate(env, def, destDir);
- }
- } catch (ClassNotFound ex) {
- env.error(0, "rmic.class.not.found", implClassName);
- }
-
- }
-
- // compile all classes that need compilation
- if (!nocompile) {
- compileAllClasses(env);
- }
- } catch (OutOfMemoryError ee) {
- // The compiler has run out of memory. Use the error string
- // which we preloaded.
- env.output(noMemoryErrorString);
- return false;
- } catch (StackOverflowError ee) {
- env.output(stackOverflowErrorString);
- return false;
- } catch (Error ee) {
- // We allow the compiler to take an exception silently if a program
- // error has previously been detected. Presumably, this makes the
- // compiler more robust in the face of bad error recovery.
- if (env.nerrors == 0 || env.dump()) {
- env.error(0, "fatal.error");
- ee.printStackTrace(out instanceof PrintStream ?
- (PrintStream) out :
- new PrintStream(out, true));
- }
- } catch (Exception ee) {
- if (env.nerrors == 0 || env.dump()) {
- env.error(0, "fatal.exception");
- ee.printStackTrace(out instanceof PrintStream ?
- (PrintStream) out :
- new PrintStream(out, true));
- }
- }
-
- env.flushErrors();
-
- boolean status = true;
- if (env.nerrors > 0) {
- String msg = "";
- if (env.nerrors > 1) {
- msg = getText("rmic.errors", env.nerrors);
- } else {
- msg = getText("rmic.1error");
- }
- if (env.nwarnings > 0) {
- if (env.nwarnings > 1) {
- msg += ", " + getText("rmic.warnings", env.nwarnings);
- } else {
- msg += ", " + getText("rmic.1warning");
- }
- }
- output(msg);
- status = false;
- } else {
- if (env.nwarnings > 0) {
- if (env.nwarnings > 1) {
- output(getText("rmic.warnings", env.nwarnings));
- } else {
- output(getText("rmic.1warning"));
- }
- }
- }
-
- // last step is to delete generated source files
- if (!keepGenerated) {
- env.deleteGeneratedFiles();
- }
-
- // We're done
- if (env.verbose()) {
- tm = System.currentTimeMillis() - tm;
- output(getText("rmic.done_in", Long.toString(tm)));
- }
-
- // Shutdown the environment object and release our resources.
- // Note that while this is unneccessary when rmic is invoked
- // the command line, there are environments in which rmic
- // from is invoked within a server process, so resource
- // reclamation is important...
-
- env.shutdown();
-
- sourcePathArg = null;
- sysClassPathArg = null;
- classPathString = null;
- destDir = null;
- classes = null;
- generatorArgs = null;
- generators = null;
- environmentClass = null;
- program = null;
- out = null;
-
- return status;
- }
-
- /*
- * Compile all classes that need to be compiled.
- */
- public void compileAllClasses (BatchEnvironment env)
- throws ClassNotFound,
- IOException,
- InterruptedException {
- ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
- boolean done;
-
- do {
- done = true;
- for (Enumeration> e = env.getClasses() ; e.hasMoreElements() ; ) {
- ClassDeclaration c = (ClassDeclaration)e.nextElement();
- done = compileClass(c,buf,env);
- }
- } while (!done);
- }
-
- /*
- * Compile a single class.
- * Fallthrough is intentional
- */
- @SuppressWarnings({"fallthrough", "deprecation"})
- public boolean compileClass (ClassDeclaration c,
- ByteArrayOutputStream buf,
- BatchEnvironment env)
- throws ClassNotFound,
- IOException,
- InterruptedException {
- boolean done = true;
- env.flushErrors();
- SourceClass src;
-
- switch (c.getStatus()) {
- case CS_UNDEFINED:
- {
- if (!env.dependencies()) {
- break;
- }
- // fall through
- }
-
- case CS_SOURCE:
- {
- done = false;
- env.loadDefinition(c);
- if (c.getStatus() != CS_PARSED) {
- break;
- }
- // fall through
- }
-
- case CS_PARSED:
- {
- if (c.getClassDefinition().isInsideLocal()) {
- break;
- }
- // If we get to here, then compilation is going
- // to occur. If the -Xnocompile switch is set
- // then fail. Note that this check is required
- // here because this method is called from
- // generators, not just from within this class...
-
- if (nocompile) {
- throw new IOException("Compilation required, but -Xnocompile option in effect");
- }
-
- done = false;
-
- src = (SourceClass)c.getClassDefinition(env);
- src.check(env);
- c.setDefinition(src, CS_CHECKED);
- // fall through
- }
-
- case CS_CHECKED:
- {
- src = (SourceClass)c.getClassDefinition(env);
- // bail out if there were any errors
- if (src.getError()) {
- c.setDefinition(src, CS_COMPILED);
- break;
- }
- done = false;
- buf.reset();
- src.compile(buf);
- c.setDefinition(src, CS_COMPILED);
- src.cleanup(env);
-
- if (src.getError() || nowrite) {
- break;
- }
-
- String pkgName = c.getName().getQualifier().toString().replace('.', File.separatorChar);
- String className = c.getName().getFlatName().toString().replace('.', SIGC_INNERCLASS) + ".class";
-
- File file;
- if (destDir != null) {
- if (pkgName.length() > 0) {
- file = new File(destDir, pkgName);
- if (!file.exists()) {
- file.mkdirs();
- }
- file = new File(file, className);
- } else {
- file = new File(destDir, className);
- }
- } else {
- ClassFile classfile = (ClassFile)src.getSource();
- if (classfile.isZipped()) {
- env.error(0, "cant.write", classfile.getPath());
- break;
- }
- file = new File(classfile.getPath());
- file = new File(file.getParent(), className);
- }
-
- // Create the file
- try {
- FileOutputStream out = new FileOutputStream(file.getPath());
- buf.writeTo(out);
- out.close();
- if (env.verbose()) {
- output(getText("rmic.wrote", file.getPath()));
- }
- } catch (IOException ee) {
- env.error(0, "cant.write", file.getPath());
- }
- }
- }
- return done;
- }
-
- /**
- * Main program
- */
- public static void main(String argv[]) {
- Main compiler = new Main(System.out, "rmic");
- System.exit(compiler.compile(argv) ? 0 : 1);
- }
-
- /**
- * Return the string value of a named resource in the rmic.properties
- * resource bundle. If the resource is not found, null is returned.
- */
- public static String getString(String key) {
- if (!resourcesInitialized) {
- initResources();
- }
-
- // To enable extensions, search the 'resourcesExt'
- // bundle first, followed by the 'resources' bundle...
-
- if (resourcesExt != null) {
- try {
- return resourcesExt.getString(key);
- } catch (MissingResourceException e) {}
- }
-
- try {
- return resources.getString(key);
- } catch (MissingResourceException ignore) {
- }
- return null;
- }
-
- private static boolean resourcesInitialized = false;
- private static ResourceBundle resources;
- private static ResourceBundle resourcesExt = null;
-
- private static void initResources() {
- try {
- resources =
- ResourceBundle.getBundle("sun.rmi.rmic.resources.rmic");
- resourcesInitialized = true;
- try {
- resourcesExt =
- ResourceBundle.getBundle("sun.rmi.rmic.resources.rmicext");
- } catch (MissingResourceException e) {}
- } catch (MissingResourceException e) {
- throw new Error("fatal: missing resource bundle: " +
- e.getClassName());
- }
- }
-
- public static String getText(String key) {
- String message = getString(key);
- if (message == null) {
- message = "no text found: \"" + key + "\"";
- }
- return message;
- }
-
- public static String getText(String key, int num) {
- return getText(key, Integer.toString(num), null, null);
- }
-
- public static String getText(String key, String arg0) {
- return getText(key, arg0, null, null);
- }
-
- public static String getText(String key, String arg0, String arg1) {
- return getText(key, arg0, arg1, null);
- }
-
- public static String getText(String key,
- String arg0, String arg1, String arg2)
- {
- String format = getString(key);
- if (format == null) {
- format = "no text found: key = \"" + key + "\", " +
- "arguments = \"{0}\", \"{1}\", \"{2}\"";
- }
-
- String[] args = new String[3];
- args[0] = (arg0 != null ? arg0 : "null");
- args[1] = (arg1 != null ? arg1 : "null");
- args[2] = (arg2 != null ? arg2 : "null");
-
- return java.text.MessageFormat.format(format, (Object[]) args);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/Names.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/Names.java
deleted file mode 100644
index 797dad26ae9..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/Names.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, 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 sun.rmi.rmic;
-
-import sun.tools.java.Identifier;
-
-/**
- * Names provides static utility methods used by other rmic classes
- * for dealing with identifiers.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public class Names {
-
- /**
- * Return stub class name for impl class name.
- */
- static final public Identifier stubFor(Identifier name) {
- return Identifier.lookup(name + "_Stub");
- }
-
- /**
- * Return skeleton class name for impl class name.
- */
- static final public Identifier skeletonFor(Identifier name) {
- return Identifier.lookup(name + "_Skel");
- }
-
- /**
- * If necessary, convert a class name to its mangled form, i.e. the
- * non-inner class name used in the binary representation of
- * inner classes. This is necessary to be able to name inner
- * classes in the generated source code in places where the language
- * does not permit it, such as when synthetically defining an inner
- * class outside of its outer class, and for generating file names
- * corresponding to inner classes.
- *
- * Currently this mangling involves modifying the internal names of
- * inner classes by converting occurrences of ". " into "$".
- *
- * This code is taken from the "mangleInnerType" method of
- * the "sun.tools.java.Type" class; this method cannot be accessed
- * itself because it is package protected.
- */
- static final public Identifier mangleClass(Identifier className) {
- if (!className.isInner())
- return className;
-
- /*
- * Get '.' qualified inner class name (with outer class
- * qualification and no package qualification) and replace
- * each '.' with '$'.
- */
- Identifier mangled = Identifier.lookup(
- className.getFlatName().toString()
- .replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));
- if (mangled.isInner())
- throw new Error("failed to mangle inner class name");
-
- // prepend package qualifier back for returned identifier
- return Identifier.lookup(className.getQualifier(), mangled);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIConstants.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIConstants.java
deleted file mode 100644
index fb12347b896..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIConstants.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1998, 2007, 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.
- */
-
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999 All Rights Reserved
- *
- */
-
-package sun.rmi.rmic;
-
-import sun.tools.java.Identifier;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public interface RMIConstants extends sun.rmi.rmic.Constants {
-
- /*
- * identifiers for RMI classes referenced by rmic
- */
- public static final Identifier idRemoteObject =
- Identifier.lookup("java.rmi.server.RemoteObject");
- public static final Identifier idRemoteStub =
- Identifier.lookup("java.rmi.server.RemoteStub");
- public static final Identifier idRemoteRef =
- Identifier.lookup("java.rmi.server.RemoteRef");
- public static final Identifier idOperation =
- Identifier.lookup("java.rmi.server.Operation");
- public static final Identifier idSkeleton =
- Identifier.lookup("java.rmi.server.Skeleton");
- public static final Identifier idSkeletonMismatchException =
- Identifier.lookup("java.rmi.server.SkeletonMismatchException");
- public static final Identifier idRemoteCall =
- Identifier.lookup("java.rmi.server.RemoteCall");
- public static final Identifier idMarshalException =
- Identifier.lookup("java.rmi.MarshalException");
- public static final Identifier idUnmarshalException =
- Identifier.lookup("java.rmi.UnmarshalException");
- public static final Identifier idUnexpectedException =
- Identifier.lookup("java.rmi.UnexpectedException");
-
- /*
- * stub protocol versions
- */
- public static final int STUB_VERSION_1_1 = 1;
- public static final int STUB_VERSION_FAT = 2;
- public static final int STUB_VERSION_1_2 = 3;
-
- /** serialVersionUID for all stubs that can use 1.2 protocol */
- public static final long STUB_SERIAL_VERSION_UID = 2;
-
- /** version number used to seed interface hash computation */
- public static final int INTERFACE_HASH_STUB_VERSION = 1;
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIGenerator.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIGenerator.java
deleted file mode 100644
index e4ad4d50cbc..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/RMIGenerator.java
+++ /dev/null
@@ -1,1279 +0,0 @@
-/*
- * Copyright (c) 1997, 2018, 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.
- */
-
-/*****************************************************************************/
-/* Copyright (c) IBM Corporation 1998 */
-/* */
-/* (C) Copyright IBM Corp. 1998 */
-/* */
-/*****************************************************************************/
-
-package sun.rmi.rmic;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-import sun.tools.java.Type;
-import sun.tools.java.Identifier;
-import sun.tools.java.ClassDefinition;
-import sun.tools.java.ClassDeclaration;
-import sun.tools.java.ClassNotFound;
-import sun.tools.java.ClassFile;
-import sun.tools.java.MemberDefinition;
-
-/**
- * A Generator object will generate the Java source code of the stub
- * and skeleton classes for an RMI remote implementation class, using
- * a particular stub protocol version.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Peter Jones, Bryan Atsatt
- */
-public class RMIGenerator implements RMIConstants, Generator {
-
- private static final Hashtable versionOptions = new Hashtable<>();
- static {
- versionOptions.put("-v1.1", STUB_VERSION_1_1);
- versionOptions.put("-vcompat", STUB_VERSION_FAT);
- versionOptions.put("-v1.2", STUB_VERSION_1_2);
- }
-
- /**
- * Default constructor for Main to use.
- */
- public RMIGenerator() {
- version = STUB_VERSION_1_2; // default is -v1.2 (see 4638155)
- }
-
- /**
- * Examine and consume command line arguments.
- * @param argv The command line arguments. Ignore null
- * and unknown arguments. Set each consumed argument to null.
- * @param main Report any errors using the main.error() methods.
- * @return true if no errors, false otherwise.
- */
- public boolean parseArgs(String argv[], Main main) {
- String explicitVersion = null;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i] != null) {
- String arg = argv[i].toLowerCase();
- if (versionOptions.containsKey(arg)) {
- if (explicitVersion != null &&
- !explicitVersion.equals(arg))
- {
- main.error("rmic.cannot.use.both",
- explicitVersion, arg);
- return false;
- }
- explicitVersion = arg;
- version = versionOptions.get(arg);
- argv[i] = null;
- }
- }
- }
- return true;
- }
-
- /**
- * Generate the source files for the stub and/or skeleton classes
- * needed by RMI for the given remote implementation class.
- *
- * @param env compiler environment
- * @param cdef definition of remote implementation class
- * to generate stubs and/or skeletons for
- * @param destDir directory for the root of the package hierarchy
- * for generated files
- */
- public void generate(BatchEnvironment env, ClassDefinition cdef, File destDir) {
- RemoteClass remoteClass = RemoteClass.forClass(env, cdef);
- if (remoteClass == null) // exit if an error occurred
- return;
-
- RMIGenerator gen;
- try {
- gen = new RMIGenerator(env, cdef, destDir, remoteClass, version);
- } catch (ClassNotFound e) {
- env.error(0, "rmic.class.not.found", e.name);
- return;
- }
- gen.generate();
- }
-
- private void generate() {
- env.addGeneratedFile(stubFile);
-
- try {
- IndentingWriter out = new IndentingWriter(
- new OutputStreamWriter(new FileOutputStream(stubFile)));
- writeStub(out);
- out.close();
- if (env.verbose()) {
- env.output(Main.getText("rmic.wrote", stubFile.getPath()));
- }
- env.parseFile(ClassFile.newClassFile(stubFile));
- } catch (IOException e) {
- env.error(0, "cant.write", stubFile.toString());
- return;
- }
-
- if (version == STUB_VERSION_1_1 ||
- version == STUB_VERSION_FAT)
- {
- env.addGeneratedFile(skeletonFile);
-
- try {
- IndentingWriter out = new IndentingWriter(
- new OutputStreamWriter(
- new FileOutputStream(skeletonFile)));
- writeSkeleton(out);
- out.close();
- if (env.verbose()) {
- env.output(Main.getText("rmic.wrote",
- skeletonFile.getPath()));
- }
- env.parseFile(ClassFile.newClassFile(skeletonFile));
- } catch (IOException e) {
- env.error(0, "cant.write", stubFile.toString());
- return;
- }
- } else {
- /*
- * For bugid 4135136: if skeleton files are not being generated
- * for this compilation run, delete old skeleton source or class
- * files for this remote implementation class that were
- * (presumably) left over from previous runs, to avoid user
- * confusion from extraneous or inconsistent generated files.
- */
-
- File outputDir = Util.getOutputDirectoryFor(remoteClassName,destDir,env);
- File skeletonClassFile = new File(outputDir,skeletonClassName.getName().toString() + ".class");
-
- skeletonFile.delete(); // ignore failures (no big deal)
- skeletonClassFile.delete();
- }
- }
-
- /**
- * Return the File object that should be used as the source file
- * for the given Java class, using the supplied destination
- * directory for the top of the package hierarchy.
- */
- protected static File sourceFileForClass(Identifier className,
- Identifier outputClassName,
- File destDir,
- BatchEnvironment env)
- {
- File packageDir = Util.getOutputDirectoryFor(className,destDir,env);
- String outputName = Names.mangleClass(outputClassName).getName().toString();
-
- String outputFileName = outputName + ".java";
- return new File(packageDir, outputFileName);
- }
-
-
- /** rmic environment for this object */
- private BatchEnvironment env;
-
- /** the remote class that this instance is generating code for */
- private RemoteClass remoteClass;
-
- /** version of the stub protocol to use in code generation */
- private int version;
-
- /** remote methods for remote class, indexed by operation number */
- private RemoteClass.Method[] remoteMethods;
-
- /**
- * Names for the remote class and the stub and skeleton classes
- * to be generated for it.
- */
- private Identifier remoteClassName;
- private Identifier stubClassName;
- private Identifier skeletonClassName;
-
- private ClassDefinition cdef;
- private File destDir;
- private File stubFile;
- private File skeletonFile;
-
- /**
- * Names to use for the java.lang.reflect.Method static fields
- * corresponding to each remote method.
- */
- private String[] methodFieldNames;
-
- /** cached definition for certain exception classes in this environment */
- private ClassDefinition defException;
- private ClassDefinition defRemoteException;
- private ClassDefinition defRuntimeException;
-
- /**
- * Create a new stub/skeleton Generator object for the given
- * remote implementation class to generate code according to
- * the given stub protocol version.
- */
- private RMIGenerator(BatchEnvironment env, ClassDefinition cdef,
- File destDir, RemoteClass remoteClass, int version)
- throws ClassNotFound
- {
- this.destDir = destDir;
- this.cdef = cdef;
- this.env = env;
- this.remoteClass = remoteClass;
- this.version = version;
-
- remoteMethods = remoteClass.getRemoteMethods();
-
- remoteClassName = remoteClass.getName();
- stubClassName = Names.stubFor(remoteClassName);
- skeletonClassName = Names.skeletonFor(remoteClassName);
-
- methodFieldNames = nameMethodFields(remoteMethods);
-
- stubFile = sourceFileForClass(remoteClassName,stubClassName, destDir , env);
- skeletonFile = sourceFileForClass(remoteClassName,skeletonClassName, destDir, env);
-
- /*
- * Initialize cached definitions for exception classes used
- * in the generation process.
- */
- defException =
- env.getClassDeclaration(idJavaLangException).
- getClassDefinition(env);
- defRemoteException =
- env.getClassDeclaration(idRemoteException).
- getClassDefinition(env);
- defRuntimeException =
- env.getClassDeclaration(idJavaLangRuntimeException).
- getClassDefinition(env);
- }
-
- /**
- * Write the stub for the remote class to a stream.
- */
- private void writeStub(IndentingWriter p) throws IOException {
-
- /*
- * Write boiler plate comment.
- */
- p.pln("// Stub class generated by rmic, do not edit.");
- p.pln("// Contents subject to change without notice.");
- p.pln();
-
- /*
- * If remote implementation class was in a particular package,
- * declare the stub class to be in the same package.
- */
- if (remoteClassName.isQualified()) {
- p.pln("package " + remoteClassName.getQualifier() + ";");
- p.pln();
- }
-
- /*
- * Declare the stub class; implement all remote interfaces.
- */
- p.plnI("public final class " +
- Names.mangleClass(stubClassName.getName()));
- p.pln("extends " + idRemoteStub);
- ClassDefinition[] remoteInterfaces = remoteClass.getRemoteInterfaces();
- if (remoteInterfaces.length > 0) {
- p.p("implements ");
- for (int i = 0; i < remoteInterfaces.length; i++) {
- if (i > 0)
- p.p(", ");
- p.p(remoteInterfaces[i].getName().toString());
- }
- p.pln();
- }
- p.pOlnI("{");
-
- if (version == STUB_VERSION_1_1 ||
- version == STUB_VERSION_FAT)
- {
- writeOperationsArray(p);
- p.pln();
- writeInterfaceHash(p);
- p.pln();
- }
-
- if (version == STUB_VERSION_FAT ||
- version == STUB_VERSION_1_2)
- {
- p.pln("private static final long serialVersionUID = " +
- STUB_SERIAL_VERSION_UID + ";");
- p.pln();
-
- /*
- * We only need to declare and initialize the static fields of
- * Method objects for each remote method if there are any remote
- * methods; otherwise, skip this code entirely, to avoid generating
- * a try/catch block for a checked exception that cannot occur
- * (see bugid 4125181).
- */
- if (methodFieldNames.length > 0) {
- if (version == STUB_VERSION_FAT) {
- p.pln("private static boolean useNewInvoke;");
- }
- writeMethodFieldDeclarations(p);
- p.pln();
-
- /*
- * Initialize java.lang.reflect.Method fields for each remote
- * method in a static initializer.
- */
- p.plnI("static {");
- p.plnI("try {");
- if (version == STUB_VERSION_FAT) {
- /*
- * Fat stubs must determine whether the API required for
- * the JDK 1.2 stub protocol is supported in the current
- * runtime, so that it can use it if supported. This is
- * determined by using the Reflection API to test if the
- * new invoke method on RemoteRef exists, and setting the
- * static boolean "useNewInvoke" to true if it does, or
- * to false if a NoSuchMethodException is thrown.
- */
- p.plnI(idRemoteRef + ".class.getMethod(\"invoke\",");
- p.plnI("new java.lang.Class[] {");
- p.pln(idRemote + ".class,");
- p.pln("java.lang.reflect.Method.class,");
- p.pln("java.lang.Object[].class,");
- p.pln("long.class");
- p.pOln("});");
- p.pO();
- p.pln("useNewInvoke = true;");
- }
- writeMethodFieldInitializers(p);
- p.pOlnI("} catch (java.lang.NoSuchMethodException e) {");
- if (version == STUB_VERSION_FAT) {
- p.pln("useNewInvoke = false;");
- } else {
- /*
- * REMIND: By throwing an Error here, the application will
- * get the NoSuchMethodError directly when the stub class
- * is initialized. If we throw a RuntimeException
- * instead, the application would get an
- * ExceptionInInitializerError. Would that be more
- * appropriate, and if so, which RuntimeException should
- * be thrown?
- */
- p.plnI("throw new java.lang.NoSuchMethodError(");
- p.pln("\"stub class initialization failed\");");
- p.pO();
- }
- p.pOln("}"); // end try/catch block
- p.pOln("}"); // end static initializer
- p.pln();
- }
- }
-
- writeStubConstructors(p);
- p.pln();
-
- /*
- * Write each stub method.
- */
- if (remoteMethods.length > 0) {
- p.pln("// methods from remote interfaces");
- for (int i = 0; i < remoteMethods.length; ++i) {
- p.pln();
- writeStubMethod(p, i);
- }
- }
-
- p.pOln("}"); // end stub class
- }
-
- /**
- * Write the constructors for the stub class.
- */
- private void writeStubConstructors(IndentingWriter p)
- throws IOException
- {
- p.pln("// constructors");
-
- /*
- * Only stubs compatible with the JDK 1.1 stub protocol need
- * a no-arg constructor; later versions use reflection to find
- * the constructor that directly takes a RemoteRef argument.
- */
- if (version == STUB_VERSION_1_1 ||
- version == STUB_VERSION_FAT)
- {
- p.plnI("public " + Names.mangleClass(stubClassName.getName()) +
- "() {");
- p.pln("super();");
- p.pOln("}");
- }
-
- p.plnI("public " + Names.mangleClass(stubClassName.getName()) +
- "(" + idRemoteRef + " ref) {");
- p.pln("super(ref);");
- p.pOln("}");
- }
-
- /**
- * Write the stub method for the remote method with the given "opnum".
- */
- private void writeStubMethod(IndentingWriter p, int opnum)
- throws IOException
- {
- RemoteClass.Method method = remoteMethods[opnum];
- Identifier methodName = method.getName();
- Type methodType = method.getType();
- Type paramTypes[] = methodType.getArgumentTypes();
- String paramNames[] = nameParameters(paramTypes);
- Type returnType = methodType.getReturnType();
- ClassDeclaration[] exceptions = method.getExceptions();
-
- /*
- * Declare stub method; throw exceptions declared in remote
- * interface(s).
- */
- p.pln("// implementation of " +
- methodType.typeString(methodName.toString(), true, false));
- p.p("public " + returnType + " " + methodName + "(");
- for (int i = 0; i < paramTypes.length; i++) {
- if (i > 0)
- p.p(", ");
- p.p(paramTypes[i] + " " + paramNames[i]);
- }
- p.plnI(")");
- if (exceptions.length > 0) {
- p.p("throws ");
- for (int i = 0; i < exceptions.length; i++) {
- if (i > 0)
- p.p(", ");
- p.p(exceptions[i].getName().toString());
- }
- p.pln();
- }
- p.pOlnI("{");
-
- /*
- * The RemoteRef.invoke methods throw Exception, but unless this
- * stub method throws Exception as well, we must catch Exceptions
- * thrown from the invocation. So we must catch Exception and
- * rethrow something we can throw: UnexpectedException, which is a
- * subclass of RemoteException. But for any subclasses of Exception
- * that we can throw, like RemoteException, RuntimeException, and
- * any of the exceptions declared by this stub method, we want them
- * to pass through unharmed, so first we must catch any such
- * exceptions and rethrow it directly.
- *
- * We have to be careful generating the rethrowing catch blocks
- * here, because javac will flag an error if there are any
- * unreachable catch blocks, i.e. if the catch of an exception class
- * follows a previous catch of it or of one of its superclasses.
- * The following method invocation takes care of these details.
- */
- Vector catchList = computeUniqueCatchList(exceptions);
-
- /*
- * If we need to catch any particular exceptions (i.e. this method
- * does not declare java.lang.Exception), put the entire stub
- * method in a try block.
- */
- if (catchList.size() > 0) {
- p.plnI("try {");
- }
-
- if (version == STUB_VERSION_FAT) {
- p.plnI("if (useNewInvoke) {");
- }
- if (version == STUB_VERSION_FAT ||
- version == STUB_VERSION_1_2)
- {
- if (!returnType.isType(TC_VOID)) {
- p.p("Object $result = "); // REMIND: why $?
- }
- p.p("ref.invoke(this, " + methodFieldNames[opnum] + ", ");
- if (paramTypes.length > 0) {
- p.p("new java.lang.Object[] {");
- for (int i = 0; i < paramTypes.length; i++) {
- if (i > 0)
- p.p(", ");
- p.p(wrapArgumentCode(paramTypes[i], paramNames[i]));
- }
- p.p("}");
- } else {
- p.p("null");
- }
- p.pln(", " + method.getMethodHash() + "L);");
- if (!returnType.isType(TC_VOID)) {
- p.pln("return " +
- unwrapArgumentCode(returnType, "$result") + ";");
- }
- }
- if (version == STUB_VERSION_FAT) {
- p.pOlnI("} else {");
- }
- if (version == STUB_VERSION_1_1 ||
- version == STUB_VERSION_FAT)
- {
- p.pln(idRemoteCall + " call = ref.newCall((" + idRemoteObject +
- ") this, operations, " + opnum + ", interfaceHash);");
-
- if (paramTypes.length > 0) {
- p.plnI("try {");
- p.pln("java.io.ObjectOutput out = call.getOutputStream();");
- writeMarshalArguments(p, "out", paramTypes, paramNames);
- p.pOlnI("} catch (java.io.IOException e) {");
- p.pln("throw new " + idMarshalException +
- "(\"error marshalling arguments\", e);");
- p.pOln("}");
- }
-
- p.pln("ref.invoke(call);");
-
- if (returnType.isType(TC_VOID)) {
- p.pln("ref.done(call);");
- } else {
- p.pln(returnType + " $result;"); // REMIND: why $?
- p.plnI("try {");
- p.pln("java.io.ObjectInput in = call.getInputStream();");
- boolean objectRead =
- writeUnmarshalArgument(p, "in", returnType, "$result");
- p.pln(";");
- p.pOlnI("} catch (java.io.IOException e) {");
- p.pln("throw new " + idUnmarshalException +
- "(\"error unmarshalling return\", e);");
- /*
- * If any only if readObject has been invoked, we must catch
- * ClassNotFoundException as well as IOException.
- */
- if (objectRead) {
- p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
- p.pln("throw new " + idUnmarshalException +
- "(\"error unmarshalling return\", e);");
- }
- p.pOlnI("} finally {");
- p.pln("ref.done(call);");
- p.pOln("}");
- p.pln("return $result;");
- }
- }
- if (version == STUB_VERSION_FAT) {
- p.pOln("}"); // end if/else (useNewInvoke) block
- }
-
- /*
- * If we need to catch any particular exceptions, finally write
- * the catch blocks for them, rethrow any other Exceptions with an
- * UnexpectedException, and end the try block.
- */
- if (catchList.size() > 0) {
- for (Enumeration enumeration = catchList.elements();
- enumeration.hasMoreElements();)
- {
- ClassDefinition def = enumeration.nextElement();
- p.pOlnI("} catch (" + def.getName() + " e) {");
- p.pln("throw e;");
- }
- p.pOlnI("} catch (java.lang.Exception e) {");
- p.pln("throw new " + idUnexpectedException +
- "(\"undeclared checked exception\", e);");
- p.pOln("}"); // end try/catch block
- }
-
- p.pOln("}"); // end stub method
- }
-
- /**
- * Compute the exceptions which need to be caught and rethrown in a
- * stub method before wrapping Exceptions in UnexpectedExceptions,
- * given the exceptions declared in the throws clause of the method.
- * Returns a Vector containing ClassDefinition objects for each
- * exception to catch. Each exception is guaranteed to be unique,
- * i.e. not a subclass of any of the other exceptions in the Vector,
- * so the catch blocks for these exceptions may be generated in any
- * order relative to each other.
- *
- * RemoteException and RuntimeException are each automatically placed
- * in the returned Vector (if none of their superclasses are already
- * present), since those exceptions should always be directly rethrown
- * by a stub method.
- *
- * The returned Vector will be empty if java.lang.Exception or one
- * of its superclasses is in the throws clause of the method, indicating
- * that no exceptions need to be caught.
- */
- private Vector computeUniqueCatchList(ClassDeclaration[] exceptions) {
- Vector uniqueList = new Vector<>(); // unique exceptions to catch
-
- uniqueList.addElement(defRuntimeException);
- uniqueList.addElement(defRemoteException);
-
- /* For each exception declared by the stub method's throws clause: */
- nextException:
- for (int i = 0; i < exceptions.length; i++) {
- ClassDeclaration decl = exceptions[i];
- try {
- if (defException.subClassOf(env, decl)) {
- /*
- * (If java.lang.Exception (or a superclass) was declared
- * in the throws clause of this stub method, then we don't
- * have to bother catching anything; clear the list and
- * return.)
- */
- uniqueList.clear();
- break;
- } else if (!defException.superClassOf(env, decl)) {
- /*
- * Ignore other Throwables that do not extend Exception,
- * since they do not need to be caught anyway.
- */
- continue;
- }
- /*
- * Compare this exception against the current list of
- * exceptions that need to be caught:
- */
- for (int j = 0; j < uniqueList.size();) {
- ClassDefinition def = uniqueList.elementAt(j);
- if (def.superClassOf(env, decl)) {
- /*
- * If a superclass of this exception is already on
- * the list to catch, then ignore and continue;
- */
- continue nextException;
- } else if (def.subClassOf(env, decl)) {
- /*
- * If a subclass of this exception is on the list
- * to catch, then remove it.
- */
- uniqueList.removeElementAt(j);
- } else {
- j++; // else continue comparing
- }
- }
- /* This exception is unique: add it to the list to catch. */
- uniqueList.addElement(decl.getClassDefinition(env));
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name, decl.getName());
- /*
- * REMIND: We do not exit from this exceptional condition,
- * generating questionable code and likely letting the
- * compiler report a resulting error later.
- */
- }
- }
- return uniqueList;
- }
-
- /**
- * Write the skeleton for the remote class to a stream.
- */
- private void writeSkeleton(IndentingWriter p) throws IOException {
- if (version == STUB_VERSION_1_2) {
- throw new Error("should not generate skeleton for version");
- }
-
- /*
- * Write boiler plate comment.
- */
- p.pln("// Skeleton class generated by rmic, do not edit.");
- p.pln("// Contents subject to change without notice.");
- p.pln();
-
- /*
- * If remote implementation class was in a particular package,
- * declare the skeleton class to be in the same package.
- */
- if (remoteClassName.isQualified()) {
- p.pln("package " + remoteClassName.getQualifier() + ";");
- p.pln();
- }
-
- /*
- * Declare the skeleton class.
- */
- p.plnI("public final class " +
- Names.mangleClass(skeletonClassName.getName()));
- p.pln("implements " + idSkeleton);
- p.pOlnI("{");
-
- writeOperationsArray(p);
- p.pln();
-
- writeInterfaceHash(p);
- p.pln();
-
- /*
- * Define the getOperations() method.
- */
- p.plnI("public " + idOperation + "[] getOperations() {");
- p.pln("return (" + idOperation + "[]) operations.clone();");
- p.pOln("}");
- p.pln();
-
- /*
- * Define the dispatch() method.
- */
- p.plnI("public void dispatch(" + idRemote + " obj, " +
- idRemoteCall + " call, int opnum, long hash)");
- p.pln("throws java.lang.Exception");
- p.pOlnI("{");
-
- if (version == STUB_VERSION_FAT) {
- p.plnI("if (opnum < 0) {");
- if (remoteMethods.length > 0) {
- for (int opnum = 0; opnum < remoteMethods.length; opnum++) {
- if (opnum > 0)
- p.pO("} else ");
- p.plnI("if (hash == " +
- remoteMethods[opnum].getMethodHash() + "L) {");
- p.pln("opnum = " + opnum + ";");
- }
- p.pOlnI("} else {");
- }
- /*
- * Skeleton throws UnmarshalException if it does not recognize
- * the method hash; this is what UnicastServerRef.dispatch()
- * would do.
- */
- p.pln("throw new " +
- idUnmarshalException + "(\"invalid method hash\");");
- if (remoteMethods.length > 0) {
- p.pOln("}");
- }
- /*
- * Ignore the validation of the interface hash if the
- * operation number was negative, since it is really a
- * method hash instead.
- */
- p.pOlnI("} else {");
- }
-
- p.plnI("if (hash != interfaceHash)");
- p.pln("throw new " +
- idSkeletonMismatchException + "(\"interface hash mismatch\");");
- p.pO();
-
- if (version == STUB_VERSION_FAT) {
- p.pOln("}"); // end if/else (opnum < 0) block
- }
- p.pln();
-
- /*
- * Cast remote object instance to our specific implementation class.
- */
- p.pln(remoteClassName + " server = (" + remoteClassName + ") obj;");
-
- /*
- * Process call according to the operation number.
- */
- p.plnI("switch (opnum) {");
- for (int opnum = 0; opnum < remoteMethods.length; opnum++) {
- writeSkeletonDispatchCase(p, opnum);
- }
- p.pOlnI("default:");
- /*
- * Skeleton throws UnmarshalException if it does not recognize
- * the operation number; this is consistent with the case of an
- * unrecognized method hash.
- */
- p.pln("throw new " + idUnmarshalException +
- "(\"invalid method number\");");
- p.pOln("}"); // end switch statement
-
- p.pOln("}"); // end dispatch() method
-
- p.pOln("}"); // end skeleton class
- }
-
- /**
- * Write the case block for the skeleton's dispatch method for
- * the remote method with the given "opnum".
- */
- private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
- throws IOException
- {
- RemoteClass.Method method = remoteMethods[opnum];
- Identifier methodName = method.getName();
- Type methodType = method.getType();
- Type paramTypes[] = methodType.getArgumentTypes();
- String paramNames[] = nameParameters(paramTypes);
- Type returnType = methodType.getReturnType();
-
- p.pOlnI("case " + opnum + ": // " +
- methodType.typeString(methodName.toString(), true, false));
- /*
- * Use nested block statement inside case to provide an independent
- * namespace for local variables used to unmarshal parameters for
- * this remote method.
- */
- p.pOlnI("{");
-
- if (paramTypes.length > 0) {
- /*
- * Declare local variables to hold arguments.
- */
- for (int i = 0; i < paramTypes.length; i++) {
- p.pln(paramTypes[i] + " " + paramNames[i] + ";");
- }
-
- /*
- * Unmarshal arguments from call stream.
- */
- p.plnI("try {");
- p.pln("java.io.ObjectInput in = call.getInputStream();");
- boolean objectsRead = writeUnmarshalArguments(p, "in",
- paramTypes, paramNames);
- p.pOlnI("} catch (java.io.IOException e) {");
- p.pln("throw new " + idUnmarshalException +
- "(\"error unmarshalling arguments\", e);");
- /*
- * If any only if readObject has been invoked, we must catch
- * ClassNotFoundException as well as IOException.
- */
- if (objectsRead) {
- p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
- p.pln("throw new " + idUnmarshalException +
- "(\"error unmarshalling arguments\", e);");
- }
- p.pOlnI("} finally {");
- p.pln("call.releaseInputStream();");
- p.pOln("}");
- } else {
- p.pln("call.releaseInputStream();");
- }
-
- if (!returnType.isType(TC_VOID)) {
- /*
- * Declare variable to hold return type, if not void.
- */
- p.p(returnType + " $result = "); // REMIND: why $?
- }
-
- /*
- * Invoke the method on the server object.
- */
- p.p("server." + methodName + "(");
- for (int i = 0; i < paramNames.length; i++) {
- if (i > 0)
- p.p(", ");
- p.p(paramNames[i]);
- }
- p.pln(");");
-
- /*
- * Always invoke getResultStream(true) on the call object to send
- * the indication of a successful invocation to the caller. If
- * the return type is not void, keep the result stream and marshal
- * the return value.
- */
- p.plnI("try {");
- if (!returnType.isType(TC_VOID)) {
- p.p("java.io.ObjectOutput out = ");
- }
- p.pln("call.getResultStream(true);");
- if (!returnType.isType(TC_VOID)) {
- writeMarshalArgument(p, "out", returnType, "$result");
- p.pln(";");
- }
- p.pOlnI("} catch (java.io.IOException e) {");
- p.pln("throw new " +
- idMarshalException + "(\"error marshalling return\", e);");
- p.pOln("}");
-
- p.pln("break;"); // break from switch statement
-
- p.pOlnI("}"); // end nested block statement
- p.pln();
- }
-
- /**
- * Write declaration and initializer for "operations" static array.
- */
- private void writeOperationsArray(IndentingWriter p)
- throws IOException
- {
- p.plnI("private static final " + idOperation + "[] operations = {");
- for (int i = 0; i < remoteMethods.length; i++) {
- if (i > 0)
- p.pln(",");
- p.p("new " + idOperation + "(\"" +
- remoteMethods[i].getOperationString() + "\")");
- }
- p.pln();
- p.pOln("};");
- }
-
- /**
- * Write declaration and initializer for "interfaceHash" static field.
- */
- private void writeInterfaceHash(IndentingWriter p)
- throws IOException
- {
- p.pln("private static final long interfaceHash = " +
- remoteClass.getInterfaceHash() + "L;");
- }
-
- /**
- * Write declaration for java.lang.reflect.Method static fields
- * corresponding to each remote method in a stub.
- */
- private void writeMethodFieldDeclarations(IndentingWriter p)
- throws IOException
- {
- for (int i = 0; i < methodFieldNames.length; i++) {
- p.pln("private static java.lang.reflect.Method " +
- methodFieldNames[i] + ";");
- }
- }
-
- /**
- * Write code to initialize the static fields for each method
- * using the Java Reflection API.
- */
- private void writeMethodFieldInitializers(IndentingWriter p)
- throws IOException
- {
- for (int i = 0; i < methodFieldNames.length; i++) {
- p.p(methodFieldNames[i] + " = ");
- /*
- * Here we look up the Method object in the arbitrary interface
- * that we find in the RemoteClass.Method object.
- * REMIND: Is this arbitrary choice OK?
- * REMIND: Should this access be part of RemoteClass.Method's
- * abstraction?
- */
- RemoteClass.Method method = remoteMethods[i];
- MemberDefinition def = method.getMemberDefinition();
- Identifier methodName = method.getName();
- Type methodType = method.getType();
- Type paramTypes[] = methodType.getArgumentTypes();
-
- p.p(def.getClassDefinition().getName() + ".class.getMethod(\"" +
- methodName + "\", new java.lang.Class[] {");
- for (int j = 0; j < paramTypes.length; j++) {
- if (j > 0)
- p.p(", ");
- p.p(paramTypes[j] + ".class");
- }
- p.pln("});");
- }
- }
-
-
- /*
- * Following are a series of static utility methods useful during
- * the code generation process:
- */
-
- /**
- * Generate an array of names for fields that correspond to the given
- * array of remote methods. Each name in the returned array is
- * guaranteed to be unique.
- *
- * The name of a method is included in its corresponding field name
- * to enhance readability of the generated code.
- */
- private static String[] nameMethodFields(RemoteClass.Method[] methods) {
- String[] names = new String[methods.length];
- for (int i = 0; i < names.length; i++) {
- names[i] = "$method_" + methods[i].getName() + "_" + i;
- }
- return names;
- }
-
- /**
- * Generate an array of names for parameters corresponding to the
- * given array of types for the parameters. Each name in the returned
- * array is guaranteed to be unique.
- *
- * A representation of the type of a parameter is included in its
- * corresponding field name to enhance the readability of the generated
- * code.
- */
- private static String[] nameParameters(Type[] types) {
- String[] names = new String[types.length];
- for (int i = 0; i < names.length; i++) {
- names[i] = "$param_" +
- generateNameFromType(types[i]) + "_" + (i + 1);
- }
- return names;
- }
-
- /**
- * Generate a readable string representing the given type suitable
- * for embedding within a Java identifier.
- */
- private static String generateNameFromType(Type type) {
- int typeCode = type.getTypeCode();
- switch (typeCode) {
- case TC_BOOLEAN:
- case TC_BYTE:
- case TC_CHAR:
- case TC_SHORT:
- case TC_INT:
- case TC_LONG:
- case TC_FLOAT:
- case TC_DOUBLE:
- return type.toString();
- case TC_ARRAY:
- return "arrayOf_" + generateNameFromType(type.getElementType());
- case TC_CLASS:
- return Names.mangleClass(type.getClassName().getName()).toString();
- default:
- throw new Error("unexpected type code: " + typeCode);
- }
- }
-
- /**
- * Write a snippet of Java code to marshal a value named "name" of
- * type "type" to the java.io.ObjectOutput stream named "stream".
- *
- * Primitive types are marshalled with their corresponding methods
- * in the java.io.DataOutput interface, and objects (including arrays)
- * are marshalled using the writeObject method.
- */
- private static void writeMarshalArgument(IndentingWriter p,
- String streamName,
- Type type, String name)
- throws IOException
- {
- int typeCode = type.getTypeCode();
- switch (typeCode) {
- case TC_BOOLEAN:
- p.p(streamName + ".writeBoolean(" + name + ")");
- break;
- case TC_BYTE:
- p.p(streamName + ".writeByte(" + name + ")");
- break;
- case TC_CHAR:
- p.p(streamName + ".writeChar(" + name + ")");
- break;
- case TC_SHORT:
- p.p(streamName + ".writeShort(" + name + ")");
- break;
- case TC_INT:
- p.p(streamName + ".writeInt(" + name + ")");
- break;
- case TC_LONG:
- p.p(streamName + ".writeLong(" + name + ")");
- break;
- case TC_FLOAT:
- p.p(streamName + ".writeFloat(" + name + ")");
- break;
- case TC_DOUBLE:
- p.p(streamName + ".writeDouble(" + name + ")");
- break;
- case TC_ARRAY:
- case TC_CLASS:
- p.p(streamName + ".writeObject(" + name + ")");
- break;
- default:
- throw new Error("unexpected type code: " + typeCode);
- }
- }
-
- /**
- * Write Java statements to marshal a series of values in order as
- * named in the "names" array, with types as specified in the "types"
- * array", to the java.io.ObjectOutput stream named "stream".
- */
- private static void writeMarshalArguments(IndentingWriter p,
- String streamName,
- Type[] types, String[] names)
- throws IOException
- {
- if (types.length != names.length) {
- throw new Error("parameter type and name arrays different sizes");
- }
-
- for (int i = 0; i < types.length; i++) {
- writeMarshalArgument(p, streamName, types[i], names[i]);
- p.pln(";");
- }
- }
-
- /**
- * Write a snippet of Java code to unmarshal a value of type "type"
- * from the java.io.ObjectInput stream named "stream" into a variable
- * named "name" (if "name" is null, the value in unmarshalled and
- * discarded).
- *
- * Primitive types are unmarshalled with their corresponding methods
- * in the java.io.DataInput interface, and objects (including arrays)
- * are unmarshalled using the readObject method.
- */
- private static boolean writeUnmarshalArgument(IndentingWriter p,
- String streamName,
- Type type, String name)
- throws IOException
- {
- boolean readObject = false;
-
- if (name != null) {
- p.p(name + " = ");
- }
-
- int typeCode = type.getTypeCode();
- switch (type.getTypeCode()) {
- case TC_BOOLEAN:
- p.p(streamName + ".readBoolean()");
- break;
- case TC_BYTE:
- p.p(streamName + ".readByte()");
- break;
- case TC_CHAR:
- p.p(streamName + ".readChar()");
- break;
- case TC_SHORT:
- p.p(streamName + ".readShort()");
- break;
- case TC_INT:
- p.p(streamName + ".readInt()");
- break;
- case TC_LONG:
- p.p(streamName + ".readLong()");
- break;
- case TC_FLOAT:
- p.p(streamName + ".readFloat()");
- break;
- case TC_DOUBLE:
- p.p(streamName + ".readDouble()");
- break;
- case TC_ARRAY:
- case TC_CLASS:
- p.p("(" + type + ") " + streamName + ".readObject()");
- readObject = true;
- break;
- default:
- throw new Error("unexpected type code: " + typeCode);
- }
- return readObject;
- }
-
- /**
- * Write Java statements to unmarshal a series of values in order of
- * types as in the "types" array from the java.io.ObjectInput stream
- * named "stream" into variables as named in "names" (for any element
- * of "names" that is null, the corresponding value is unmarshalled
- * and discarded).
- */
- private static boolean writeUnmarshalArguments(IndentingWriter p,
- String streamName,
- Type[] types,
- String[] names)
- throws IOException
- {
- if (types.length != names.length) {
- throw new Error("parameter type and name arrays different sizes");
- }
-
- boolean readObject = false;
- for (int i = 0; i < types.length; i++) {
- if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
- readObject = true;
- }
- p.pln(";");
- }
- return readObject;
- }
-
- /**
- * Return a snippet of Java code to wrap a value named "name" of
- * type "type" into an object as appropriate for use by the
- * Java Reflection API.
- *
- * For primitive types, an appropriate wrapper class instantiated
- * with the primitive value. For object types (including arrays),
- * no wrapping is necessary, so the value is named directly.
- */
- private static String wrapArgumentCode(Type type, String name) {
- int typeCode = type.getTypeCode();
- switch (typeCode) {
- case TC_BOOLEAN:
- return ("(" + name +
- " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
- case TC_BYTE:
- return "new java.lang.Byte(" + name + ")";
- case TC_CHAR:
- return "new java.lang.Character(" + name + ")";
- case TC_SHORT:
- return "new java.lang.Short(" + name + ")";
- case TC_INT:
- return "new java.lang.Integer(" + name + ")";
- case TC_LONG:
- return "new java.lang.Long(" + name + ")";
- case TC_FLOAT:
- return "new java.lang.Float(" + name + ")";
- case TC_DOUBLE:
- return "new java.lang.Double(" + name + ")";
- case TC_ARRAY:
- case TC_CLASS:
- return name;
- default:
- throw new Error("unexpected type code: " + typeCode);
- }
- }
-
- /**
- * Return a snippet of Java code to unwrap a value named "name" into
- * a value of type "type", as appropriate for the Java Reflection API.
- *
- * For primitive types, the value is assumed to be of the corresponding
- * wrapper type, and a method is called on the wrapper type to retrieve
- * the primitive value. For object types (include arrays), no
- * unwrapping is necessary; the value is simply cast to the expected
- * real object type.
- */
- private static String unwrapArgumentCode(Type type, String name) {
- int typeCode = type.getTypeCode();
- switch (typeCode) {
- case TC_BOOLEAN:
- return "((java.lang.Boolean) " + name + ").booleanValue()";
- case TC_BYTE:
- return "((java.lang.Byte) " + name + ").byteValue()";
- case TC_CHAR:
- return "((java.lang.Character) " + name + ").charValue()";
- case TC_SHORT:
- return "((java.lang.Short) " + name + ").shortValue()";
- case TC_INT:
- return "((java.lang.Integer) " + name + ").intValue()";
- case TC_LONG:
- return "((java.lang.Long) " + name + ").longValue()";
- case TC_FLOAT:
- return "((java.lang.Float) " + name + ").floatValue()";
- case TC_DOUBLE:
- return "((java.lang.Double) " + name + ").doubleValue()";
- case TC_ARRAY:
- case TC_CLASS:
- return "((" + type + ") " + name + ")";
- default:
- throw new Error("unexpected type code: " + typeCode);
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/RemoteClass.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/RemoteClass.java
deleted file mode 100644
index 6187d5ca866..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/RemoteClass.java
+++ /dev/null
@@ -1,876 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, 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 sun.rmi.rmic;
-
-import java.util.Vector;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.security.MessageDigest;
-import java.security.DigestOutputStream;
-import java.security.NoSuchAlgorithmException;
-import sun.tools.java.Type;
-import sun.tools.java.ClassDefinition;
-import sun.tools.java.ClassDeclaration;
-import sun.tools.java.MemberDefinition;
-import sun.tools.java.Identifier;
-import sun.tools.java.ClassNotFound;
-
-/**
- * A RemoteClass object encapsulates RMI-specific information about
- * a remote implementation class, i.e. a class that implements
- * one or more remote interfaces.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Peter Jones
- */
-public class RemoteClass implements sun.rmi.rmic.RMIConstants {
-
- /**
- * Create a RemoteClass object representing the remote meta-information
- * of the given class.
- *
- * Returns true if successful. If the class is not a properly formed
- * remote implementation class or if some other error occurs, the
- * return value will be null, and errors will have been reported to
- * the supplied BatchEnvironment.
- */
- public static RemoteClass forClass(BatchEnvironment env,
- ClassDefinition implClassDef)
- {
- RemoteClass rc = new RemoteClass(env, implClassDef);
- if (rc.initialize()) {
- return rc;
- } else {
- return null;
- }
- }
-
- /**
- * Return the ClassDefinition for this class.
- */
- public ClassDefinition getClassDefinition() {
- return implClassDef;
- }
-
- /**
- * Return the name of the class represented by this object.
- */
- public Identifier getName() {
- return implClassDef.getName();
- }
-
- /**
- * Return an array of ClassDefinitions representing all of the remote
- * interfaces implemented by this class.
- *
- * A remote interface is any interface that extends Remote,
- * directly or indirectly. The remote interfaces of a class
- * are the interfaces directly listed in either the class's
- * "implements" clause, or the "implements" clause of any
- * of its superclasses, that are remote interfaces.
- *
- * The order of the array returned is arbitrary, and some elements
- * may be superfluous (i.e., superinterfaces of other interfaces
- * in the array).
- */
- public ClassDefinition[] getRemoteInterfaces() {
- return remoteInterfaces.clone();
- }
-
- /**
- * Return an array of RemoteClass.Method objects representing all of
- * the remote methods implemented by this class, i.e. all of the
- * methods in the class's remote interfaces.
- *
- * The methods in the array are ordered according to the comparison
- * of the strings consisting of their method name followed by their
- * type signature, so each method's index in the array corresponds
- * to its "operation number" in the JDK 1.1 version of the
- * stub/skeleton protocol.
- */
- public Method[] getRemoteMethods() {
- return remoteMethods.clone();
- }
-
- /**
- * Return the "interface hash" used to match a stub/skeleton pair for
- * this class in the JDK 1.1 version of the stub/skeleton protocol.
- */
- public long getInterfaceHash() {
- return interfaceHash;
- }
-
- /**
- * Return string representation of this object, consisting of
- * the string "remote class " followed by the class name.
- */
- public String toString() {
- return "remote class " + implClassDef.getName().toString();
- }
-
- /** rmic environment for this object */
- private BatchEnvironment env;
-
- /** the remote implementation class this object corresponds to */
- private ClassDefinition implClassDef;
-
- /** remote interfaces implemented by this class */
- private ClassDefinition[] remoteInterfaces;
-
- /** all the remote methods of this class */
- private Method[] remoteMethods;
-
- /** stub/skeleton "interface hash" for this class */
- private long interfaceHash;
-
- /** cached definition for certain classes used in this environment */
- private ClassDefinition defRemote;
- private ClassDefinition defException;
- private ClassDefinition defRemoteException;
-
- /**
- * Create a RemoteClass instance for the given class. The resulting
- * object is not yet initialized.
- */
- private RemoteClass(BatchEnvironment env, ClassDefinition implClassDef) {
- this.env = env;
- this.implClassDef = implClassDef;
- }
-
- /**
- * Validate that the remote implementation class is properly formed
- * and fill in the data structures required by the public interface.
- */
- private boolean initialize() {
- /*
- * Verify that the "impl" is really a class, not an interface.
- */
- if (implClassDef.isInterface()) {
- env.error(0, "rmic.cant.make.stubs.for.interface",
- implClassDef.getName());
- return false;
- }
-
- /*
- * Initialize cached definitions for the Remote interface and
- * the RemoteException class.
- */
- try {
- defRemote =
- env.getClassDeclaration(idRemote).getClassDefinition(env);
- defException =
- env.getClassDeclaration(idJavaLangException).
- getClassDefinition(env);
- defRemoteException =
- env.getClassDeclaration(idRemoteException).
- getClassDefinition(env);
- } catch (ClassNotFound e) {
- env.error(0, "rmic.class.not.found", e.name);
- return false;
- }
-
- /*
- * Here we find all of the remote interfaces of our remote
- * implementation class. For each class up the superclass
- * chain, add each directly-implemented interface that
- * somehow extends Remote to a list.
- */
- Vector remotesImplemented = // list of remote interfaces found
- new Vector();
- for (ClassDefinition classDef = implClassDef;
- classDef != null;)
- {
- try {
- ClassDeclaration[] interfaces = classDef.getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- ClassDefinition interfaceDef =
- interfaces[i].getClassDefinition(env);
- /*
- * Add interface to the list if it extends Remote and
- * it is not already there.
- */
- if (!remotesImplemented.contains(interfaceDef) &&
- defRemote.implementedBy(env, interfaces[i]))
- {
- remotesImplemented.addElement(interfaceDef);
- /***** */
- if (env.verbose()) {
- System.out.println("[found remote interface: " +
- interfaceDef.getName() + "]");
- /***** */
- }
- }
- }
-
- /*
- * Verify that the candidate remote implementation class
- * implements at least one remote interface directly.
- */
- if (classDef == implClassDef && remotesImplemented.isEmpty()) {
- if (defRemote.implementedBy(env,
- implClassDef.getClassDeclaration()))
- {
- /*
- * This error message is used if the class does
- * implement a remote interface through one of
- * its superclasses, but not directly.
- */
- env.error(0, "rmic.must.implement.remote.directly",
- implClassDef.getName());
- } else {
- /*
- * This error message is used if the class never
- * implements a remote interface.
- */
- env.error(0, "rmic.must.implement.remote",
- implClassDef.getName());
- }
- return false;
- }
-
- /*
- * Get definition for next superclass.
- */
- classDef = (classDef.getSuperClass() != null ?
- classDef.getSuperClass().getClassDefinition(env) :
- null);
-
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name, classDef.getName());
- return false;
- }
- }
-
- /*
- * The "remotesImplemented" vector now contains all of the remote
- * interfaces directly implemented by the remote class or by any
- * of its superclasses.
- *
- * At this point, we could optimize the list by removing superfluous
- * entries, i.e. any interfaces that are implemented by some other
- * interface in the list anyway.
- *
- * This should be correct; would it be worthwhile?
- *
- * for (int i = 0; i < remotesImplemented.size();) {
- * ClassDefinition interfaceDef =
- * (ClassDefinition) remotesImplemented.elementAt(i);
- * boolean isOtherwiseImplemented = false;
- * for (int j = 0; j < remotesImplemented.size; j++) {
- * if (j != i &&
- * interfaceDef.implementedBy(env, (ClassDefinition)
- * remotesImplemented.elementAt(j).
- * getClassDeclaration()))
- * {
- * isOtherwiseImplemented = true;
- * break;
- * }
- * }
- * if (isOtherwiseImplemented) {
- * remotesImplemented.removeElementAt(i);
- * } else {
- * ++i;
- * }
- * }
- */
-
- /*
- * Now we collect the methods from all of the remote interfaces
- * into a hashtable.
- */
- Hashtable methods = new Hashtable();
- boolean errors = false;
- for (Enumeration enumeration
- = remotesImplemented.elements();
- enumeration.hasMoreElements();)
- {
- ClassDefinition interfaceDef = enumeration.nextElement();
- if (!collectRemoteMethods(interfaceDef, methods))
- errors = true;
- }
- if (errors)
- return false;
-
- /*
- * Convert vector of remote interfaces to an array
- * (order is not important for this array).
- */
- remoteInterfaces = new ClassDefinition[remotesImplemented.size()];
- remotesImplemented.copyInto(remoteInterfaces);
-
- /*
- * Sort table of remote methods into an array. The elements are
- * sorted in ascending order of the string of the method's name
- * and type signature, so that each elements index is equal to
- * its operation number of the JDK 1.1 version of the stub/skeleton
- * protocol.
- */
- String[] orderedKeys = new String[methods.size()];
- int count = 0;
- for (Enumeration enumeration = methods.elements();
- enumeration.hasMoreElements();)
- {
- Method m = enumeration.nextElement();
- String key = m.getNameAndDescriptor();
- int i;
- for (i = count; i > 0; --i) {
- if (key.compareTo(orderedKeys[i - 1]) >= 0) {
- break;
- }
- orderedKeys[i] = orderedKeys[i - 1];
- }
- orderedKeys[i] = key;
- ++count;
- }
- remoteMethods = new Method[methods.size()];
- for (int i = 0; i < remoteMethods.length; i++) {
- remoteMethods[i] = methods.get(orderedKeys[i]);
- /***** */
- if (env.verbose()) {
- System.out.print("[found remote method <" + i + ">: " +
- remoteMethods[i].getOperationString());
- ClassDeclaration[] exceptions =
- remoteMethods[i].getExceptions();
- if (exceptions.length > 0)
- System.out.print(" throws ");
- for (int j = 0; j < exceptions.length; j++) {
- if (j > 0)
- System.out.print(", ");
- System.out.print(exceptions[j].getName());
- }
- System.out.println("]");
- }
- /***** */
- }
-
- /**
- * Finally, pre-compute the interface hash to be used by
- * stubs/skeletons for this remote class.
- */
- interfaceHash = computeInterfaceHash();
-
- return true;
- }
-
- /**
- * Collect and validate all methods from given interface and all of
- * its superinterfaces as remote methods. Remote methods are added
- * to the supplied hashtable. Returns true if successful,
- * or false if an error occurred.
- */
- private boolean collectRemoteMethods(ClassDefinition interfaceDef,
- Hashtable table)
- {
- if (!interfaceDef.isInterface()) {
- throw new Error(
- "expected interface, not class: " + interfaceDef.getName());
- }
-
- /*
- * rmic used to enforce that a remote interface could not extend
- * a non-remote interface, i.e. an interface that did not itself
- * extend from Remote. The current version of rmic does not have
- * this restriction, so the following code is now commented out.
- *
- * Verify that this interface extends Remote, since all interfaces
- * extended by a remote interface must implement Remote.
- *
- * try {
- * if (!defRemote.implementedBy(env,
- * interfaceDef.getClassDeclaration()))
- * {
- * env.error(0, "rmic.can.mix.remote.nonremote",
- * interfaceDef.getName());
- * return false;
- * }
- * } catch (ClassNotFound e) {
- * env.error(0, "class.not.found", e.name,
- * interfaceDef.getName());
- * return false;
- * }
- */
-
- boolean errors = false;
-
- /*
- * Search interface's members for methods.
- */
- nextMember:
- for (MemberDefinition member = interfaceDef.getFirstMember();
- member != null;
- member = member.getNextMember())
- {
- if (member.isMethod() &&
- !member.isConstructor() && !member.isInitializer())
- {
- /*
- * Verify that each method throws RemoteException.
- */
- ClassDeclaration[] exceptions = member.getExceptions(env);
- boolean hasRemoteException = false;
- for (int i = 0; i < exceptions.length; i++) {
- /*
- * rmic used to enforce that a remote method had to
- * explicitly list RemoteException in its "throws"
- * clause; i.e., just throwing Exception was not
- * acceptable. The current version of rmic does not
- * have this restriction, so the following code is
- * now commented out. Instead, the method is
- * considered valid if RemoteException is a subclass
- * of any of the methods declared exceptions.
- *
- * if (exceptions[i].getName().equals(
- * idRemoteException))
- * {
- * hasRemoteException = true;
- * break;
- * }
- */
- try {
- if (defRemoteException.subClassOf(
- env, exceptions[i]))
- {
- hasRemoteException = true;
- break;
- }
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name,
- interfaceDef.getName());
- continue nextMember;
- }
- }
- /*
- * If this method did not throw RemoteException as required,
- * generate the error but continue, so that multiple such
- * errors can be reported.
- */
- if (!hasRemoteException) {
- env.error(0, "rmic.must.throw.remoteexception",
- interfaceDef.getName(), member.toString());
- errors = true;
- continue nextMember;
- }
-
- /*
- * Verify that the implementation of this method throws only
- * java.lang.Exception or its subclasses (fix bugid 4092486).
- * JRMP does not support remote methods throwing
- * java.lang.Throwable or other subclasses.
- */
- try {
- MemberDefinition implMethod = implClassDef.findMethod(
- env, member.getName(), member.getType());
- if (implMethod != null) { // should not be null
- exceptions = implMethod.getExceptions(env);
- for (int i = 0; i < exceptions.length; i++) {
- if (!defException.superClassOf(
- env, exceptions[i]))
- {
- env.error(0, "rmic.must.only.throw.exception",
- implMethod.toString(),
- exceptions[i].getName());
- errors = true;
- continue nextMember;
- }
- }
- }
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name,
- implClassDef.getName());
- continue nextMember;
- }
-
- /*
- * Create RemoteClass.Method object to represent this method
- * found in a remote interface.
- */
- Method newMethod = new Method(member);
- /*
- * Store remote method's representation in the table of
- * remote methods found, keyed by its name and parameter
- * signature.
- *
- * If the table already contains an entry with the same
- * method name and parameter signature, then we must
- * replace the old entry with a Method object that
- * represents a legal combination of the old and the new
- * methods; specifically, the combined method must have
- * a throws list that contains (only) all of the checked
- * exceptions that can be thrown by both the old or
- * the new method (see bugid 4070653).
- */
- String key = newMethod.getNameAndDescriptor();
- Method oldMethod = table.get(key);
- if (oldMethod != null) {
- newMethod = newMethod.mergeWith(oldMethod);
- if (newMethod == null) {
- errors = true;
- continue nextMember;
- }
- }
- table.put(key, newMethod);
- }
- }
-
- /*
- * Recursively collect methods for all superinterfaces.
- */
- try {
- ClassDeclaration[] superDefs = interfaceDef.getInterfaces();
- for (int i = 0; i < superDefs.length; i++) {
- ClassDefinition superDef =
- superDefs[i].getClassDefinition(env);
- if (!collectRemoteMethods(superDef, table))
- errors = true;
- }
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name, interfaceDef.getName());
- return false;
- }
-
- return !errors;
- }
-
- /**
- * Compute the "interface hash" of the stub/skeleton pair for this
- * remote implementation class. This is the 64-bit value used to
- * enforce compatibility between a stub and a skeleton using the
- * JDK 1.1 version of the stub/skeleton protocol.
- *
- * It is calculated using the first 64 bits of a SHA digest. The
- * digest is from a stream consisting of the following data:
- * (int) stub version number, always 1
- * for each remote method, in order of operation number:
- * (UTF) method name
- * (UTF) method type signature
- * for each declared exception, in alphabetical name order:
- * (UTF) name of exception class
- *
- */
- private long computeInterfaceHash() {
- long hash = 0;
- ByteArrayOutputStream sink = new ByteArrayOutputStream(512);
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- DataOutputStream out = new DataOutputStream(
- new DigestOutputStream(sink, md));
-
- out.writeInt(INTERFACE_HASH_STUB_VERSION);
- for (int i = 0; i < remoteMethods.length; i++) {
- MemberDefinition m = remoteMethods[i].getMemberDefinition();
- Identifier name = m.getName();
- Type type = m.getType();
-
- out.writeUTF(name.toString());
- // type signatures already use mangled class names
- out.writeUTF(type.getTypeSignature());
-
- ClassDeclaration exceptions[] = m.getExceptions(env);
- sortClassDeclarations(exceptions);
- for (int j = 0; j < exceptions.length; j++) {
- out.writeUTF(Names.mangleClass(
- exceptions[j].getName()).toString());
- }
- }
- out.flush();
-
- // use only the first 64 bits of the digest for the hash
- byte hashArray[] = md.digest();
- for (int i = 0; i < Math.min(8, hashArray.length); i++) {
- hash += ((long) (hashArray[i] & 0xFF)) << (i * 8);
- }
- } catch (IOException e) {
- throw new Error(
- "unexpected exception computing intetrface hash: " + e);
- } catch (NoSuchAlgorithmException e) {
- throw new Error(
- "unexpected exception computing intetrface hash: " + e);
- }
-
- return hash;
- }
-
- /**
- * Sort array of class declarations alphabetically by their mangled
- * fully-qualified class name. This is used to feed a method's exceptions
- * in a canonical order into the digest stream for the interface hash
- * computation.
- */
- private void sortClassDeclarations(ClassDeclaration[] decl) {
- for (int i = 1; i < decl.length; i++) {
- ClassDeclaration curr = decl[i];
- String name = Names.mangleClass(curr.getName()).toString();
- int j;
- for (j = i; j > 0; j--) {
- if (name.compareTo(
- Names.mangleClass(decl[j - 1].getName()).toString()) >= 0)
- {
- break;
- }
- decl[j] = decl[j - 1];
- }
- decl[j] = curr;
- }
- }
-
-
- /**
- * A RemoteClass.Method object encapsulates RMI-specific information
- * about a particular remote method in the remote implementation class
- * represented by the outer instance.
- */
- public class Method implements Cloneable {
-
- /**
- * Return the definition of the actual class member corresponing
- * to this method of a remote interface.
- *
- * REMIND: Can this method be removed?
- */
- public MemberDefinition getMemberDefinition() {
- return memberDef;
- }
-
- /**
- * Return the name of this method.
- */
- public Identifier getName() {
- return memberDef.getName();
- }
-
- /**
- * Return the type of this method.
- */
- public Type getType() {
- return memberDef.getType();
- }
-
- /**
- * Return an array of the exception classes declared to be
- * thrown by this remote method.
- *
- * For methods with the same name and type signature inherited
- * from multiple remote interfaces, the array will contain
- * the set of exceptions declared in all of the interfaces'
- * methods that can be legally thrown in each of them.
- */
- public ClassDeclaration[] getExceptions() {
- return exceptions.clone();
- }
-
- /**
- * Return the "method hash" used to identify this remote method
- * in the JDK 1.2 version of the stub protocol.
- */
- public long getMethodHash() {
- return methodHash;
- }
-
- /**
- * Return the string representation of this method.
- */
- public String toString() {
- return memberDef.toString();
- }
-
- /**
- * Return the string representation of this method appropriate
- * for the construction of a java.rmi.server.Operation object.
- */
- public String getOperationString() {
- return memberDef.toString();
- }
-
- /**
- * Return a string consisting of this method's name followed by
- * its method descriptor, using the Java VM's notation for
- * method descriptors (see section 4.3.3 of The Java Virtual
- * Machine Specification).
- */
- public String getNameAndDescriptor() {
- return memberDef.getName().toString() +
- memberDef.getType().getTypeSignature();
- }
-
- /**
- * Member definition for this method, from one of the remote
- * interfaces that this method was found in.
- *
- * Note that this member definition may be only one of several
- * member defintions that correspond to this remote method object,
- * if several of this class's remote interfaces contain methods
- * with the same name and type signature. Therefore, this member
- * definition may declare more exceptions thrown that this remote
- * method does.
- */
- private MemberDefinition memberDef;
-
- /** stub "method hash" to identify this method */
- private long methodHash;
-
- /**
- * Exceptions declared to be thrown by this remote method.
- *
- * This list can include superfluous entries, such as
- * unchecked exceptions and subclasses of other entries.
- */
- private ClassDeclaration[] exceptions;
-
- /**
- * Create a new Method object corresponding to the given
- * method definition.
- */
- /*
- * Temporarily comment out the private modifier until
- * the VM allows outer class to access inner class's
- * private constructor
- */
- /* private */ Method(MemberDefinition memberDef) {
- this.memberDef = memberDef;
- exceptions = memberDef.getExceptions(env);
- methodHash = computeMethodHash();
- }
-
- /**
- * Cloning is supported by returning a shallow copy of this object.
- */
- protected Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new Error("clone failed");
- }
- }
-
- /**
- * Return a new Method object that is a legal combination of
- * this method object and another one.
- *
- * This requires determining the exceptions declared by the
- * combined method, which must be (only) all of the exceptions
- * declared in both old Methods that may thrown in either of
- * them.
- */
- private Method mergeWith(Method other) {
- if (!getName().equals(other.getName()) ||
- !getType().equals(other.getType()))
- {
- throw new Error("attempt to merge method \"" +
- other.getNameAndDescriptor() + "\" with \"" +
- getNameAndDescriptor());
- }
-
- Vector legalExceptions
- = new Vector();
- try {
- collectCompatibleExceptions(
- other.exceptions, exceptions, legalExceptions);
- collectCompatibleExceptions(
- exceptions, other.exceptions, legalExceptions);
- } catch (ClassNotFound e) {
- env.error(0, "class.not.found", e.name,
- getClassDefinition().getName());
- return null;
- }
-
- Method merged = (Method) clone();
- merged.exceptions = new ClassDeclaration[legalExceptions.size()];
- legalExceptions.copyInto(merged.exceptions);
-
- return merged;
- }
-
- /**
- * Add to the supplied list all exceptions in the "from" array
- * that are subclasses of an exception in the "with" array.
- */
- private void collectCompatibleExceptions(ClassDeclaration[] from,
- ClassDeclaration[] with,
- Vector list)
- throws ClassNotFound
- {
- for (int i = 0; i < from.length; i++) {
- ClassDefinition exceptionDef = from[i].getClassDefinition(env);
- if (!list.contains(from[i])) {
- for (int j = 0; j < with.length; j++) {
- if (exceptionDef.subClassOf(env, with[j])) {
- list.addElement(from[i]);
- break;
- }
- }
- }
- }
- }
-
- /**
- * Compute the "method hash" of this remote method. The method
- * hash is a long containing the first 64 bits of the SHA digest
- * from the UTF encoded string of the method name and descriptor.
- *
- * REMIND: Should this method share implementation code with
- * the outer class's computeInterfaceHash() method?
- */
- private long computeMethodHash() {
- long hash = 0;
- ByteArrayOutputStream sink = new ByteArrayOutputStream(512);
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- DataOutputStream out = new DataOutputStream(
- new DigestOutputStream(sink, md));
-
- String methodString = getNameAndDescriptor();
- /***** */
- if (env.verbose()) {
- System.out.println("[string used for method hash: \"" +
- methodString + "\"]");
- }
- /***** */
- out.writeUTF(methodString);
-
- // use only the first 64 bits of the digest for the hash
- out.flush();
- byte hashArray[] = md.digest();
- for (int i = 0; i < Math.min(8, hashArray.length); i++) {
- hash += ((long) (hashArray[i] & 0xFF)) << (i * 8);
- }
- } catch (IOException e) {
- throw new Error(
- "unexpected exception computing intetrface hash: " + e);
- } catch (NoSuchAlgorithmException e) {
- throw new Error(
- "unexpected exception computing intetrface hash: " + e);
- }
-
- return hash;
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/Util.java b/src/jdk.rmic/share/classes/sun/rmi/rmic/Util.java
deleted file mode 100644
index f93b5096d1e..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/Util.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- */
-
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999 All Rights Reserved
- *
- */
-
-package sun.rmi.rmic;
-
-import java.io.File;
-import sun.tools.java.Identifier;
-
-/**
- * Util provides static utility methods used by other rmic classes.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Bryan Atsatt
- */
-
-public class Util implements sun.rmi.rmic.Constants {
-
- /**
- * Return the directory that should be used for output for a given
- * class.
- * @param theClass The fully qualified name of the class.
- * @param rootDir The directory to use as the root of the
- * package hierarchy. May be null, in which case the current
- * working directory is used as the root.
- */
- public static File getOutputDirectoryFor(Identifier theClass,
- File rootDir,
- BatchEnvironment env) {
-
- File outputDir = null;
- String className = theClass.getFlatName().toString().replace('.', SIGC_INNERCLASS);
- String qualifiedClassName = className;
- String packagePath = null;
- String packageName = theClass.getQualifier().toString();
-
- if (packageName.length() > 0) {
- qualifiedClassName = packageName + "." + className;
- packagePath = packageName.replace('.', File.separatorChar);
- }
-
- // Do we have a root directory?
-
- if (rootDir != null) {
-
- // Yes, do we have a package name?
-
- if (packagePath != null) {
-
- // Yes, so use it as the root. Open the directory...
-
- outputDir = new File(rootDir, packagePath);
-
- // Make sure the directory exists...
-
- ensureDirectory(outputDir,env);
-
- } else {
-
- // Default package, so use root as output dir...
-
- outputDir = rootDir;
- }
- } else {
-
- // No root directory. Get the current working directory...
-
- String workingDirPath = System.getProperty("user.dir");
- File workingDir = new File(workingDirPath);
-
- // Do we have a package name?
-
- if (packagePath == null) {
-
- // No, so use working directory...
-
- outputDir = workingDir;
-
- } else {
-
- // Yes, so use working directory as the root...
-
- outputDir = new File(workingDir, packagePath);
-
- // Make sure the directory exists...
-
- ensureDirectory(outputDir,env);
- }
- }
-
- // Finally, return the directory...
-
- return outputDir;
- }
-
- private static void ensureDirectory (File dir, BatchEnvironment env) {
- if (!dir.exists()) {
- dir.mkdirs();
- if (!dir.exists()) {
- env.error(0,"rmic.cannot.create.dir",dir.getAbsolutePath());
- throw new InternalError();
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic.properties b/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic.properties
deleted file mode 100644
index 5c2e83a462b..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic.properties
+++ /dev/null
@@ -1,144 +0,0 @@
-#
-#
-# Copyright (c) 1996, 2019, 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.
-#
-
-
-#*****************************************************************************
-#* Copyright (c) IBM Corporation 1998 *
-#* *
-#* (C) Copyright IBM Corp. 1998 *
-#* *
-#*****************************************************************************
-
-# To add a generator sun.rmi.rmic.Foo which is invoked via the -foo option:
-#
-# 1. Add "foo" to generator.args list.
-# 2. Add line: generator.class.foo=sun.rmi.rmic.Foo
-# 3. Update rmic.usage string to include new arguments.
-
-# For each available generator, list the command line argument used
-# to invoke it. The value can be a single item or a comma separated
-# list.
-
-generator.args=v1.1,vcompat,v1.2,xprint
-
-# For each generator, specify the class to invoke, using the following
-# syntax:
-#
-# generator.class.{arg}=fullClassName
-#
-# The 'default' entry is required and will be used if none of the args
-# specified in generator.args is passed. Note that {arg} is compared
-# using String.equalsIgnoreCase().
-
-generator.class.default=sun.rmi.rmic.RMIGenerator
-
-generator.class.v1.1=sun.rmi.rmic.RMIGenerator
-generator.class.vcompat=sun.rmi.rmic.RMIGenerator
-generator.class.v1.2=sun.rmi.rmic.RMIGenerator
-generator.class.xprint=sun.rmi.rmic.iiop.PrintGenerator
-
-# If a generator needs a BatchEnvironment other than
-# sun.rmi.rmic.BatchEnvironment, specify it as follows:
-#
-# generator.env.{arg}=fullClassName
-
-generator.env.iiop=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.idl=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.xprint=sun.rmi.rmic.iiop.BatchEnvironment
-
-rmic.usage=Usage: {0} \
-\n\
-\nwhere includes:\
-\n -keep Do not delete intermediate generated source files\
-\n -keepgenerated (same as "-keep")\
-\n -v1.1 Create stubs/skeletons for 1.1 stub protocol version (deprecated)\
-\n -vcompat Create stubs/skeletons compatible with both\
-\n 1.1 and 1.2 stub protocol versions (deprecated)\
-\n -v1.2 (default) Create stubs for 1.2 stub protocol version only (deprecated)\
-\n -g Generate debugging info\
-\n -nowarn Generate no warnings\
-\n -nowrite Do not write compiled classes to the file system\
-\n -verbose Output messages about what the compiler is doing\
-\n -classpath Specify where to find input class files\
-\n -bootclasspath Override location of bootstrap class files\
-\n -d Specify where to place generated class files\
-\n -J Pass argument to the java interpreter\
-\n
-
-#
-# Generic Messages
-#
-
-rmic.cant.read=Can''t read: {0}
-rmic.cant.write=Can''t write: {0}
-rmic.option.unsupported=The {0} option is no longer supported.
-rmic.option.unimplemented=The {0} option is not yet implemented.
-rmic.option.already.seen=The {0} option may be specified no more than once.
-rmic.option.requires.argument=The {0} option requires an argument.
-rmic.no.such.directory=The {0} directory does not exist.
-rmic.no.such.option={0} is an invalid option or argument.
-rmic.wrote=[wrote {0}]
-rmic.errors={0} errors
-rmic.1error=1 error
-rmic.warnings={0} warnings
-rmic.1warning=1 warning
-rmic.done_in=[done in {0} ms]
-rmic.no.memory=\
- The compiler has run out of memory. Consider using the "-J-Xmx" command line option to increase the maximum heap size.
-rmic.stack.overflow=\
- The compiler has run out of stack space. Consider using the "-J-Xss" command line option to increase the memory allocated for the Java stack.
-rmic.class.not.found=\
- Class {0} not found.
-rmic.missing.property=Missing property generator.class.{0}
-rmic.cannot.instantiate=Cannot instantiate class {0}
-rmic.cannot.use.both=Cannot use both {0} and {1}
-rmic.resource.not.found={0} not found.
-rmic.no.output.dir=\
- Cannot find suitable output directory for {0}. Use the -d option to specify a root directory.
-rmic.cannot.create.dir=\
- Cannot create output directory {0}.
-
-#
-# JRMP Messages
-#
-
-rmic.cant.make.stubs.for.interface=\
- {0} is an interface; stubs are needed only for remote object classes.
-rmic.must.implement.remote=\
- Class {0} does not implement an interface that extends java.rmi.Remote; only remote objects need stubs and skeletons.
-rmic.must.implement.remote.directly=\
- Stubs are only needed for classes that directly implement an interface that extends java.rmi.Remote; class {0} does not directly implement a remote interface.
-rmic.must.throw.remoteexception=\
- {0} is not a valid remote interface: method {1} must throw java.rmi.RemoteException.
-rmic.must.only.throw.exception=\
- Method {0} is not a valid remote method implementation because it throws {1}; implementations of remote methods may only throw java.lang.Exception or its subclasses.
-rmic.jrmp.stubs.deprecated=\
- Warning: {0} has been deprecated and is subject to removal in a future\
- \nrelease. Generation and use of skeletons and static stubs for JRMP\
- \nis deprecated. Skeletons are unnecessary, and static stubs have\
- \nbeen superseded by dynamically generated stubs. Users are encouraged\
- \nto migrate away from using this tool to generate skeletons and static\
- \nstubs. See the documentation for java.rmi.server.UnicastRemoteObject.
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_ja.properties b/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_ja.properties
deleted file mode 100644
index 8bb0425ea0c..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_ja.properties
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-#
-# Copyright (c) 1996, 2019, 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.
-#
-
-
-#*****************************************************************************
-#* Copyright (c) IBM Corporation 1998 *
-#* *
-#* (C) Copyright IBM Corp. 1998 *
-#* *
-#*****************************************************************************
-
-# To add a generator sun.rmi.rmic.Foo which is invoked via the -foo option:
-#
-# 1. Add "foo" to generator.args list.
-# 2. Add line: generator.class.foo=sun.rmi.rmic.Foo
-# 3. Update rmic.usage string to include new arguments.
-
-# For each available generator, list the command line argument used
-# to invoke it. The value can be a single item or a comma separated
-# list.
-
-generator.args=v1.1,vcompat,v1.2,xprint
-
-# For each generator, specify the class to invoke, using the following
-# syntax:
-#
-# generator.class.{arg}=fullClassName
-#
-# The 'default' entry is required and will be used if none of the args
-# specified in generator.args is passed. Note that {arg} is compared
-# using String.equalsIgnoreCase().
-
-generator.class.default=sun.rmi.rmic.RMIGenerator
-
-generator.class.v1.1=sun.rmi.rmic.RMIGenerator
-generator.class.vcompat=sun.rmi.rmic.RMIGenerator
-generator.class.v1.2=sun.rmi.rmic.RMIGenerator
-generator.class.xprint=sun.rmi.rmic.iiop.PrintGenerator
-
-# If a generator needs a BatchEnvironment other than
-# sun.rmi.rmic.BatchEnvironment, specify it as follows:
-#
-# generator.env.{arg}=fullClassName
-
-generator.env.iiop=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.idl=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.xprint=sun.rmi.rmic.iiop.BatchEnvironment
-
-rmic.usage=\u4F7F\u7528\u65B9\u6CD5: {0} \n\n\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002\n -keep \u4E2D\u9593\u751F\u6210\u3055\u308C\u305F\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u524A\u9664\u3057\u306A\u3044\n -keepgenerated("-keep"\u3068\u540C\u3058)\n -v1.1 1.1\u30B9\u30BF\u30D6\u30FB\u30D7\u30ED\u30C8\u30B3\u30EB\u7248\u7528\u306E\u30B9\u30BF\u30D6/\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u4F5C\u6210\u3059\u308B(\u975E\u63A8\u5968)\n -vcompat 1.1\u30681.2\u306E\u30B9\u30BF\u30D6\u30FB\u30D7\u30ED\u30C8\u30B3\u30EB\u7248\u3068\n \u4E92\u63DB\u6027\u306E\u3042\u308B\u30B9\u30BF\u30D6/\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u4F5C\u6210\u3059\u308B(\u975E\u63A8\u5968)\n -v1.2 (\u30C7\u30D5\u30A9\u30EB\u30C8)1.2\u30B9\u30BF\u30D6\u30FB\u30D7\u30ED\u30C8\u30B3\u30EB\u7248\u5C02\u7528\u306E\u30B9\u30BF\u30D6\u3092\u4F5C\u6210\u3059\u308B(\u975E\u63A8\u5968)\n -g \u30C7\u30D0\u30C3\u30B0\u60C5\u5831\u3092\u751F\u6210\u3059\u308B\n -nowarn \u8B66\u544A\u3092\u751F\u6210\u3057\u306A\u3044\n -nowrite \u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u305F\u30AF\u30E9\u30B9\u3092\u30D5\u30A1\u30A4\u30EB\u30FB\u30B7\u30B9\u30C6\u30E0\u306B\u66F8\u304D\u8FBC\u307E\u306A\u3044\n -verbose \u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u52D5\u4F5C\u306B\u95A2\u3059\u308B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B\n -classpath \u5165\u529B\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -bootclasspath \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -d \u751F\u6210\u3055\u308C\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u683C\u7D0D\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -J java\u30A4\u30F3\u30BF\u30D7\u30EA\u30BF\u306B\u5F15\u6570\u3092\u6E21\u3059\n
-
-#
-# Generic Messages
-#
-
-rmic.cant.read={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093
-rmic.cant.write={0}\u304C\u66F8\u304D\u8FBC\u3081\u307E\u305B\u3093
-rmic.option.unsupported=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306F\u73FE\u5728\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
-rmic.option.unimplemented=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306F\u307E\u3060\u5B9F\u88C5\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
-rmic.option.already.seen={0}\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u8907\u6570\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\u3002
-rmic.option.requires.argument={0}\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u306F\u5F15\u6570\u304C\u5FC5\u8981\u3067\u3059\u3002
-rmic.no.such.directory=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002
-rmic.no.such.option={0}\u306F\u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u307E\u305F\u306F\u5F15\u6570\u3067\u3059\u3002
-rmic.wrote=[{0}\u3092\u66F8\u8FBC\u307F\u5B8C\u4E86]
-rmic.errors=\u30A8\u30E9\u30FC{0}\u500B
-rmic.1error=\u30A8\u30E9\u30FC1\u500B
-rmic.warnings=\u8B66\u544A{0}\u500B
-rmic.1warning=\u8B66\u544A1\u500B
-rmic.done_in=[{0}\u30DF\u30EA\u79D2\u3067\u5B8C\u4E86]
-rmic.no.memory=\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u30E1\u30E2\u30EA\u30FC\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059\u3002"-J-Xmx"\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u3001\u6700\u5927\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u5897\u3084\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-rmic.stack.overflow=\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u30B9\u30BF\u30C3\u30AF\u7A7A\u9593\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059\u3002"-J-Xss"\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u3001Java\u30B9\u30BF\u30C3\u30AF\u306B\u5272\u308A\u5F53\u3066\u308B\u30E1\u30E2\u30EA\u30FC\u3092\u5897\u3084\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-rmic.class.not.found=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
-rmic.missing.property=\u30D7\u30ED\u30D1\u30C6\u30A3generator.class.{0}\u304C\u3042\u308A\u307E\u305B\u3093
-rmic.cannot.instantiate=\u30AF\u30E9\u30B9{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093
-rmic.cannot.use.both={0}\u3068{1}\u306E\u4E21\u65B9\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002
-rmic.resource.not.found={0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
-rmic.no.output.dir={0}\u306B\u9069\u5207\u306A\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002-d\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u30EB\u30FC\u30C8\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-rmic.cannot.create.dir=\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002
-
-#
-# JRMP Messages
-#
-
-rmic.cant.make.stubs.for.interface={0}\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059\u3002\u30B9\u30BF\u30D6\u306F\u30EA\u30E2\u30FC\u30C8\u30FB\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u30FB\u30AF\u30E9\u30B9\u306B\u306E\u307F\u5FC5\u8981\u3067\u3059\u3002
-rmic.must.implement.remote=\u30AF\u30E9\u30B9{0}\u306Fjava.rmi.Remote\u3092\u62E1\u5F35\u3059\u308B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u307E\u305B\u3093\u3002\u30B9\u30BF\u30D6\u3068\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u5FC5\u8981\u3068\u3059\u308B\u306E\u306F\u30EA\u30E2\u30FC\u30C8\u30FB\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u307F\u3067\u3059\u3002
-rmic.must.implement.remote.directly=\u30B9\u30BF\u30D6\u3092\u5FC5\u8981\u3068\u3059\u308B\u306E\u306Fjava.rmi.Remote\u3092\u62E1\u5F35\u3059\u308B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u76F4\u63A5\u5B9F\u88C5\u3059\u308B\u30AF\u30E9\u30B9\u306E\u307F\u3067\u3059\u3002\u30AF\u30E9\u30B9{0}\u306F\u30EA\u30E2\u30FC\u30C8\u30FB\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u76F4\u63A5\u306B\u306F\u5B9F\u88C5\u3057\u307E\u305B\u3093\u3002
-rmic.must.throw.remoteexception={0}\u306F\u4E0D\u6B63\u306A\u30EA\u30E2\u30FC\u30C8\u30FB\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059\u3002\u30E1\u30BD\u30C3\u30C9{1}\u306Fjava.rmi.RemoteException\u3092\u30B9\u30ED\u30FC\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002
-rmic.must.only.throw.exception=\u30E1\u30BD\u30C3\u30C9{0}\u306F{1}\u3092\u30B9\u30ED\u30FC\u3059\u308B\u306E\u3067\u4E0D\u6B63\u306A\u30EA\u30E2\u30FC\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u5B9F\u88C5\u3067\u3059\u3002\u30EA\u30E2\u30FC\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u306E\u5B9F\u88C5\u304C\u30B9\u30ED\u30FC\u3059\u308B\u306E\u306Fjava.lang.Exception\u304B\u305D\u306E\u30B5\u30D6\u30AF\u30E9\u30B9\u306E\u307F\u3067\u3059\u3002
-rmic.jrmp.stubs.deprecated=\u8B66\u544A: {0}\u306F\u975E\u63A8\u5968\u306B\u306A\u308A\u3001\u5C06\u6765\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u307E\u3059\u3002\nJRMP\u306E\u30B9\u30B1\u30EB\u30C8\u30F3\u3068static\u30B9\u30BF\u30D6\u306E\u751F\u6210\u3068\u4F7F\u7528\u306F\n\u975E\u63A8\u5968\u3067\u3059\u3002\u30B9\u30B1\u30EB\u30C8\u30F3\u306F\u4E0D\u8981\u3067\u3001static\u30B9\u30BF\u30D6\u306F\n\u52D5\u7684\u306B\u751F\u6210\u3055\u308C\u308B\u30B9\u30BF\u30D6\u306B\u5DEE\u3057\u66FF\u3048\u3089\u308C\u307E\u3057\u305F\u3002\u30E6\u30FC\u30B6\u30FC\u306F\n\u30B9\u30B1\u30EB\u30C8\u30F3\u3068static\u30B9\u30BF\u30D6\u3092\u751F\u6210\u3059\u308B\u305F\u3081\u306B\u3053\u306E\u30C4\u30FC\u30EB\u3092\u4F7F\u7528\u305B\u305A\u306B\u79FB\u884C\u3059\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u3059\u3002\njava.rmi.server.UnicastRemoteObject\u306B\u95A2\u3059\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
diff --git a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_zh_CN.properties b/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_zh_CN.properties
deleted file mode 100644
index c6462f070d9..00000000000
--- a/src/jdk.rmic/share/classes/sun/rmi/rmic/resources/rmic_zh_CN.properties
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-#
-# Copyright (c) 1996, 2019, 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.
-#
-
-
-#*****************************************************************************
-#* Copyright (c) IBM Corporation 1998 *
-#* *
-#* (C) Copyright IBM Corp. 1998 *
-#* *
-#*****************************************************************************
-
-# To add a generator sun.rmi.rmic.Foo which is invoked via the -foo option:
-#
-# 1. Add "foo" to generator.args list.
-# 2. Add line: generator.class.foo=sun.rmi.rmic.Foo
-# 3. Update rmic.usage string to include new arguments.
-
-# For each available generator, list the command line argument used
-# to invoke it. The value can be a single item or a comma separated
-# list.
-
-generator.args=v1.1,vcompat,v1.2,xprint
-
-# For each generator, specify the class to invoke, using the following
-# syntax:
-#
-# generator.class.{arg}=fullClassName
-#
-# The 'default' entry is required and will be used if none of the args
-# specified in generator.args is passed. Note that {arg} is compared
-# using String.equalsIgnoreCase().
-
-generator.class.default=sun.rmi.rmic.RMIGenerator
-
-generator.class.v1.1=sun.rmi.rmic.RMIGenerator
-generator.class.vcompat=sun.rmi.rmic.RMIGenerator
-generator.class.v1.2=sun.rmi.rmic.RMIGenerator
-generator.class.xprint=sun.rmi.rmic.iiop.PrintGenerator
-
-# If a generator needs a BatchEnvironment other than
-# sun.rmi.rmic.BatchEnvironment, specify it as follows:
-#
-# generator.env.{arg}=fullClassName
-
-generator.env.iiop=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.idl=sun.rmi.rmic.iiop.BatchEnvironment
-generator.env.xprint=sun.rmi.rmic.iiop.BatchEnvironment
-
-rmic.usage=\u7528\u6CD5\uFF1A{0} <\u9009\u9879> <\u7C7B\u540D>\n\n\u5176\u4E2D <\u9009\u9879> \u5305\u62EC\uFF1A\n -keep \u4E0D\u5220\u9664\u4E34\u65F6\u751F\u6210\u7684\u6E90\u6587\u4EF6\n -keepgenerated\uFF08\u4E0E "-keep" \u76F8\u540C\uFF09\n -v1.1 \u521B\u5EFA 1.1 \u5B58\u6839\u534F\u8BAE\u7248\u672C\u7684\u5B58\u6839/\u9AA8\u67B6\uFF08\u5DF2\u8FC7\u65F6\uFF09\n -vcompat \u521B\u5EFA\u4E0E 1.1 \u548C 1.2 \u5B58\u6839\u534F\u8BAE\u7248\u672C\n \u90FD\u517C\u5BB9\u7684\u5B58\u6839/\u9AA8\u67B6\uFF08\u5DF2\u8FC7\u65F6\uFF09\n -v1.2 \uFF08\u9ED8\u8BA4\u503C\uFF09\u4EC5\u521B\u5EFA 1.2 \u5B58\u6839\u534F\u8BAE\u7248\u672C\u7684\u5B58\u6839\uFF08\u5DF2\u8FC7\u65F6\uFF09\n -g \u751F\u6210\u8C03\u8BD5\u4FE1\u606F\n -nowarn \u4E0D\u751F\u6210\u4EFB\u4F55\u8B66\u544A\n -nowrite \u4E0D\u5C06\u7F16\u8BD1\u7684\u7C7B\u5199\u5165\u6587\u4EF6\u7CFB\u7EDF\n -verbose \u8F93\u51FA\u6709\u5173\u7F16\u8BD1\u5668\u6B63\u5728\u6267\u884C\u7684\u64CD\u4F5C\u7684\u6D88\u606F\n -classpath <\u8DEF\u5F84> \u6307\u5B9A\u67E5\u627E\u8F93\u5165\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n -bootclasspath <\u8DEF\u5F84> \u8986\u76D6\u5F15\u5BFC\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n -d <\u76EE\u5F55> \u6307\u5B9A\u653E\u7F6E\u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n -J<\u8FD0\u884C\u65F6\u6807\u8BB0> \u5C06\u53C2\u6570\u4F20\u9012\u7ED9 java \u89E3\u91CA\u5668\n
-
-#
-# Generic Messages
-#
-
-rmic.cant.read=\u65E0\u6CD5\u8BFB\u53D6: {0}
-rmic.cant.write=\u65E0\u6CD5\u5199\u5165: {0}
-rmic.option.unsupported=\u4E0D\u518D\u652F\u6301{0}\u9009\u9879\u3002
-rmic.option.unimplemented=\u5C1A\u672A\u5B9E\u73B0{0}\u9009\u9879\u3002
-rmic.option.already.seen={0}\u9009\u9879\u53EA\u80FD\u6307\u5B9A\u4E00\u6B21\u3002
-rmic.option.requires.argument=\u9009\u9879{0}\u9700\u8981\u53C2\u6570\u3002
-rmic.no.such.directory={0} \u76EE\u5F55\u4E0D\u5B58\u5728\u3002
-rmic.no.such.option={0}\u662F\u65E0\u6548\u9009\u9879\u6216\u53C2\u6570\u3002
-rmic.wrote=[\u5DF2\u5199\u5165{0}]
-rmic.errors={0} \u4E2A\u9519\u8BEF
-rmic.1error=1 \u4E2A\u9519\u8BEF
-rmic.warnings={0} \u4E2A\u8B66\u544A
-rmic.1warning=1 \u4E2A\u8B66\u544A
-rmic.done_in=[\u5728 {0} \u6BEB\u79D2\u5185\u5B8C\u6210]
-rmic.no.memory=\u7F16\u8BD1\u5668\u6240\u7528\u5185\u5B58\u4E0D\u8DB3\u3002\u8BF7\u8003\u8651\u4F7F\u7528 "-J-Xmx" \u547D\u4EE4\u884C\u9009\u9879\u6765\u589E\u52A0\u5806\u5927\u5C0F\u7684\u6700\u5927\u503C\u3002
-rmic.stack.overflow=\u7F16\u8BD1\u5668\u6240\u7528\u5806\u6808\u7A7A\u95F4\u4E0D\u8DB3\u3002\u8BF7\u8003\u8651\u4F7F\u7528 "-J-Xss" \u547D\u4EE4\u884C\u9009\u9879\u6765\u589E\u52A0\u5206\u914D\u7ED9 Java \u5806\u6808\u7684\u5185\u5B58\u5927\u5C0F\u3002
-rmic.class.not.found=\u627E\u4E0D\u5230\u7C7B{0}\u3002
-rmic.missing.property=\u7F3A\u5C11\u5C5E\u6027 generator.class.{0}
-rmic.cannot.instantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u7C7B{0}
-rmic.cannot.use.both=\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528{0}\u548C{1}
-rmic.resource.not.found=\u627E\u4E0D\u5230{0}\u3002
-rmic.no.output.dir=\u65E0\u6CD5\u627E\u5230\u9002\u7528\u4E8E{0}\u7684\u8F93\u51FA\u76EE\u5F55\u3002\u8BF7\u4F7F\u7528 -d \u9009\u9879\u6765\u6307\u5B9A\u6839\u76EE\u5F55\u3002
-rmic.cannot.create.dir=\u65E0\u6CD5\u521B\u5EFA\u8F93\u51FA\u76EE\u5F55 {0}\u3002
-
-#
-# JRMP Messages
-#
-
-rmic.cant.make.stubs.for.interface={0}\u662F\u63A5\u53E3; \u4EC5\u8FDC\u7A0B\u5BF9\u8C61\u7C7B\u9700\u8981\u5B58\u6839\u3002
-rmic.must.implement.remote=\u7C7B{0}\u4E0D\u5B9E\u73B0\u6269\u5C55 java.rmi.Remote \u7684\u63A5\u53E3; \u4EC5\u8FDC\u7A0B\u5BF9\u8C61\u9700\u8981\u5B58\u6839\u548C\u6846\u67B6\u3002
-rmic.must.implement.remote.directly=\u4EC5\u76F4\u63A5\u5B9E\u73B0\u6269\u5C55 java.rmi.Remote \u7684\u63A5\u53E3\u7684\u7C7B\u9700\u8981\u5B58\u6839; \u7C7B{0}\u4E0D\u76F4\u63A5\u5B9E\u73B0\u8FDC\u7A0B\u63A5\u53E3\u3002
-rmic.must.throw.remoteexception={0}\u4E0D\u662F\u6709\u6548\u8FDC\u7A0B\u63A5\u53E3: \u65B9\u6CD5{1}\u5FC5\u987B\u629B\u51FA java.rmi.RemoteException\u3002
-rmic.must.only.throw.exception=\u65B9\u6CD5{0}\u4E0D\u662F\u6709\u6548\u7684\u8FDC\u7A0B\u65B9\u6CD5\u5B9E\u73B0, \u56E0\u4E3A\u5B83\u629B\u51FA\u4E86{1}; \u8FDC\u7A0B\u65B9\u6CD5\u5B9E\u73B0\u53EA\u53EF\u80FD\u629B\u51FA java.lang.Exception \u6216\u5176\u5B50\u7C7B\u3002
-rmic.jrmp.stubs.deprecated=\u8B66\u544A\uFF1A{0} \u5DF2\u8FC7\u65F6\uFF0C\u5C06\u4ECE\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664\u3002\n\u4E3A JRMP \u751F\u6210\u548C\u4F7F\u7528\u9AA8\u67B6\u53CA\u9759\u6001\u5B58\u6839\u5DF2\u8FC7\u65F6\u3002\n\u9AA8\u67B6\u4E0D\u518D\u5FC5\u8981\uFF0C\u800C\u9759\u6001\u5B58\u6839\u5DF2\u7531\u52A8\u6001\u751F\u6210\u7684\u5B58\u6839\u53D6\u4EE3\u3002\n\u5EFA\u8BAE\u7528\u6237\u4E0D\u518D\u4F7F\u7528\u6B64\u5DE5\u5177\u6765\u751F\u6210\u9AA8\u67B6\u548C\u9759\u6001\u5B58\u6839\u3002\n\u8BF7\u53C2\u9605\u6709\u5173 java.rmi.server.UnicastRemoteObject \n\u7684\u6587\u6863\u3002
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/ArrayData.java b/src/jdk.rmic/share/classes/sun/tools/asm/ArrayData.java
deleted file mode 100644
index cc66897a8a0..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/ArrayData.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class ArrayData {
- Type type;
- int nargs;
-
- public ArrayData(Type type, int nargs) {
- this.type = type;
- this.nargs = nargs;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/Assembler.java b/src/jdk.rmic/share/classes/sun/tools/asm/Assembler.java
deleted file mode 100644
index 7a9fdda2c73..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/Assembler.java
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.util.Enumeration;
-import java.io.IOException;
-import java.io.DataOutputStream;
-import java.io.PrintStream;
-import java.util.Vector;
-// JCOV
-import sun.tools.javac.*;
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.lang.String;
-// end JCOV
-
-/**
- * This class is used to assemble the bytecode instructions for a method.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-public final
-class Assembler implements Constants {
- static final int NOTREACHED = 0;
- static final int REACHED = 1;
- static final int NEEDED = 2;
-
- Label first = new Label();
- Instruction last = first;
- int maxdepth;
- int maxvar;
- int maxpc;
-
- /**
- * Add an instruction
- */
- public void add(Instruction inst) {
- if (inst != null) {
- last.next = inst;
- last = inst;
- }
- }
- public void add(long where, int opc) {
- add(new Instruction(where, opc, null));
- }
- public void add(long where, int opc, Object obj) {
- add(new Instruction(where, opc, obj));
- }
-// JCOV
- public void add(long where, int opc, Object obj, boolean flagCondInverted) {
- add(new Instruction(where, opc, obj, flagCondInverted));
- }
-
- public void add(boolean flagNoCovered, long where, int opc, Object obj) {
- add(new Instruction(flagNoCovered, where, opc, obj));
- }
-
- public void add(long where, int opc, boolean flagNoCovered) {
- add(new Instruction(where, opc, flagNoCovered));
- }
-
- static Vector SourceClassList = new Vector<>();
-
- static Vector TmpCovTable = new Vector<>();
-
- static int[] JcovClassCountArray = new int[CT_LAST_KIND + 1];
-
- static String JcovMagicLine = "JCOV-DATA-FILE-VERSION: 2.0";
- static String JcovClassLine = "CLASS: ";
- static String JcovSrcfileLine = "SRCFILE: ";
- static String JcovTimestampLine = "TIMESTAMP: ";
- static String JcovDataLine = "DATA: ";
- static String JcovHeadingLine = "#kind\tcount";
-
- static int[] arrayModifiers =
- {M_PUBLIC, M_PRIVATE, M_PROTECTED, M_ABSTRACT, M_FINAL, M_INTERFACE};
- static int[] arrayModifiersOpc =
- {PUBLIC, PRIVATE, PROTECTED, ABSTRACT, FINAL, INTERFACE};
-//end JCOV
-
- /**
- * Optimize instructions and mark those that can be reached
- */
- void optimize(Environment env, Label lbl) {
- lbl.pc = REACHED;
-
- for (Instruction inst = lbl.next ; inst != null ; inst = inst.next) {
- switch (inst.pc) {
- case NOTREACHED:
- inst.optimize(env);
- inst.pc = REACHED;
- break;
- case REACHED:
- return;
- case NEEDED:
- break;
- }
-
- switch (inst.opc) {
- case opc_label:
- case opc_dead:
- if (inst.pc == REACHED) {
- inst.pc = NOTREACHED;
- }
- break;
-
- case opc_ifeq:
- case opc_ifne:
- case opc_ifgt:
- case opc_ifge:
- case opc_iflt:
- case opc_ifle:
- case opc_if_icmpeq:
- case opc_if_icmpne:
- case opc_if_icmpgt:
- case opc_if_icmpge:
- case opc_if_icmplt:
- case opc_if_icmple:
- case opc_if_acmpeq:
- case opc_if_acmpne:
- case opc_ifnull:
- case opc_ifnonnull:
- optimize(env, (Label)inst.value);
- break;
-
- case opc_goto:
- optimize(env, (Label)inst.value);
- return;
-
- case opc_jsr:
- optimize(env, (Label)inst.value);
- break;
-
- case opc_ret:
- case opc_return:
- case opc_ireturn:
- case opc_lreturn:
- case opc_freturn:
- case opc_dreturn:
- case opc_areturn:
- case opc_athrow:
- return;
-
- case opc_tableswitch:
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)inst.value;
- optimize(env, sw.defaultLabel);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- optimize(env, e.nextElement());
- }
- return;
- }
-
- case opc_try: {
- TryData td = (TryData)inst.value;
- td.getEndLabel().pc = NEEDED;
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = e.nextElement();
- optimize(env, cd.getLabel());
- }
- break;
- }
- }
- }
- }
-
- /**
- * Eliminate instructions that are not reached
- */
- boolean eliminate() {
- boolean change = false;
- Instruction prev = first;
-
- for (Instruction inst = first.next ; inst != null ; inst = inst.next) {
- if (inst.pc != NOTREACHED) {
- prev.next = inst;
- prev = inst;
- inst.pc = NOTREACHED;
- } else {
- change = true;
- }
- }
- first.pc = NOTREACHED;
- prev.next = null;
- return change;
- }
-
- /**
- * Optimize the byte codes
- */
- public void optimize(Environment env) {
- //listing(System.out);
- do {
- // Figure out which instructions are reached
- optimize(env, first);
-
- // Eliminate instructions that are not reached
- } while (eliminate() && env.opt());
- }
-
- /**
- * Collect all constants into the constant table
- */
- public void collect(Environment env, MemberDefinition field, ConstantPool tab) {
- // Collect constants for arguments only
- // if a local variable table is generated
- if ((field != null) && env.debug_vars()) {
- @SuppressWarnings("unchecked")
- Vector v = field.getArguments();
- if (v != null) {
- for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
- MemberDefinition f = e.nextElement();
- tab.put(f.getName().toString());
- tab.put(f.getType().getTypeSignature());
- }
- }
- }
-
- // Collect constants from the instructions
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- inst.collect(tab);
- }
- }
-
- /**
- * Determine stack size, count local variables
- */
- void balance(Label lbl, int depth) {
- for (Instruction inst = lbl ; inst != null ; inst = inst.next) {
- //Environment.debugOutput(inst.toString() + ": " + depth + " => " +
- // (depth + inst.balance()));
- depth += inst.balance();
- if (depth < 0) {
- throw new CompilerError("stack under flow: " + inst.toString() + " = " + depth);
- }
- if (depth > maxdepth) {
- maxdepth = depth;
- }
- switch (inst.opc) {
- case opc_label:
- lbl = (Label)inst;
- if (inst.pc == REACHED) {
- if (lbl.depth != depth) {
- throw new CompilerError("stack depth error " +
- depth + "/" + lbl.depth +
- ": " + inst.toString());
- }
- return;
- }
- lbl.pc = REACHED;
- lbl.depth = depth;
- break;
-
- case opc_ifeq:
- case opc_ifne:
- case opc_ifgt:
- case opc_ifge:
- case opc_iflt:
- case opc_ifle:
- case opc_if_icmpeq:
- case opc_if_icmpne:
- case opc_if_icmpgt:
- case opc_if_icmpge:
- case opc_if_icmplt:
- case opc_if_icmple:
- case opc_if_acmpeq:
- case opc_if_acmpne:
- case opc_ifnull:
- case opc_ifnonnull:
- balance((Label)inst.value, depth);
- break;
-
- case opc_goto:
- balance((Label)inst.value, depth);
- return;
-
- case opc_jsr:
- balance((Label)inst.value, depth + 1);
- break;
-
- case opc_ret:
- case opc_return:
- case opc_ireturn:
- case opc_lreturn:
- case opc_freturn:
- case opc_dreturn:
- case opc_areturn:
- case opc_athrow:
- return;
-
- case opc_iload:
- case opc_fload:
- case opc_aload:
- case opc_istore:
- case opc_fstore:
- case opc_astore: {
- int v = ((inst.value instanceof Number)
- ? ((Number)inst.value).intValue()
- : ((LocalVariable)inst.value).slot) + 1;
- if (v > maxvar)
- maxvar = v;
- break;
- }
-
- case opc_lload:
- case opc_dload:
- case opc_lstore:
- case opc_dstore: {
- int v = ((inst.value instanceof Number)
- ? ((Number)inst.value).intValue()
- : ((LocalVariable)inst.value).slot) + 2;
- if (v > maxvar)
- maxvar = v;
- break;
- }
-
- case opc_iinc: {
- int v = ((int[])inst.value)[0] + 1;
- if (v > maxvar)
- maxvar = v + 1;
- break;
- }
-
- case opc_tableswitch:
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)inst.value;
- balance(sw.defaultLabel, depth);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- balance(e.nextElement(), depth);
- }
- return;
- }
-
- case opc_try: {
- TryData td = (TryData)inst.value;
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = e.nextElement();
- balance(cd.getLabel(), depth + 1);
- }
- break;
- }
- }
- }
- }
-
- /**
- * Generate code
- */
- public void write(Environment env, DataOutputStream out,
- MemberDefinition field, ConstantPool tab)
- throws IOException {
- //listing(System.out);
-
- if ((field != null) && field.getArguments() != null) {
- int sum = 0;
- @SuppressWarnings("unchecked")
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = e.nextElement();
- sum += f.getType().stackSize();
- }
- maxvar = sum;
- }
-
- // Make sure the stack balances. Also calculate maxvar and maxstack
- try {
- balance(first, 0);
- } catch (CompilerError e) {
- System.out.println("ERROR: " + e);
- listing(System.out);
- throw e;
- }
-
- // Assign PCs
- int pc = 0, nexceptions = 0;
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- inst.pc = pc;
- int sz = inst.size(tab);
- if (pc<65536 && (pc+sz)>=65536) {
- env.error(inst.where, "warn.method.too.long");
- }
- pc += sz;
-
- if (inst.opc == opc_try) {
- nexceptions += ((TryData)inst.value).catches.size();
- }
- }
-
- // Write header
- out.writeShort(maxdepth);
- out.writeShort(maxvar);
- out.writeInt(maxpc = pc);
-
- // Generate code
- for (Instruction inst = first.next ; inst != null ; inst = inst.next) {
- inst.write(out, tab);
- }
-
- // write exceptions
- out.writeShort(nexceptions);
- if (nexceptions > 0) {
- //listing(System.out);
- writeExceptions(env, out, tab, first, last);
- }
- }
-
- /**
- * Write the exceptions table
- */
- void writeExceptions(Environment env, DataOutputStream out, ConstantPool tab, Instruction first, Instruction last) throws IOException {
- for (Instruction inst = first ; inst != last.next ; inst = inst.next) {
- if (inst.opc == opc_try) {
- TryData td = (TryData)inst.value;
- writeExceptions(env, out, tab, inst.next, td.getEndLabel());
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = e.nextElement();
- //System.out.println("EXCEPTION: " + env.getSource() + ", pc=" + inst.pc + ", end=" + td.getEndLabel().pc + ", hdl=" + cd.getLabel().pc + ", tp=" + cd.getType());
- out.writeShort(inst.pc);
- out.writeShort(td.getEndLabel().pc);
- out.writeShort(cd.getLabel().pc);
- if (cd.getType() != null) {
- out.writeShort(tab.index(cd.getType()));
- } else {
- out.writeShort(0);
- }
- }
- inst = td.getEndLabel();
- }
- }
- }
-
-//JCOV
- /**
- * Write the coverage table
- */
- public void writeCoverageTable(Environment env, ClassDefinition c, DataOutputStream out, ConstantPool tab, long whereField) throws IOException {
- Vector TableLot = new Vector<>(); /* Coverage table */
- boolean begseg = false;
- boolean begmeth = false;
- @SuppressWarnings("deprecation")
- long whereClass = ((SourceClass)c).getWhere();
- Vector whereTry = new Vector<>();
- int numberTry = 0;
- int count = 0;
-
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- long n = (inst.where >> WHEREOFFSETBITS);
- if (n > 0 && inst.opc != opc_label) {
- if (!begmeth) {
- if ( whereClass == inst.where)
- TableLot.addElement(new Cover(CT_FIKT_METHOD, whereField, inst.pc));
- else
- TableLot.addElement(new Cover(CT_METHOD, whereField, inst.pc));
- count++;
- begmeth = true;
- }
- if (!begseg && !inst.flagNoCovered ) {
- boolean findTry = false;
- for (Enumeration e = whereTry.elements(); e.hasMoreElements();) {
- if (e.nextElement().longValue() == inst.where) {
- findTry = true;
- break;
- }
- }
- if (!findTry) {
- TableLot.addElement(new Cover(CT_BLOCK, inst.where, inst.pc));
- count++;
- begseg = true;
- }
- }
- }
- switch (inst.opc) {
- case opc_label:
- begseg = false;
- break;
- case opc_ifeq:
- case opc_ifne:
- case opc_ifnull:
- case opc_ifnonnull:
- case opc_ifgt:
- case opc_ifge:
- case opc_iflt:
- case opc_ifle:
- case opc_if_icmpeq:
- case opc_if_icmpne:
- case opc_if_icmpgt:
- case opc_if_icmpge:
- case opc_if_icmplt:
- case opc_if_icmple:
- case opc_if_acmpeq:
- case opc_if_acmpne: {
- if ( inst.flagCondInverted ) {
- TableLot.addElement(new Cover(CT_BRANCH_TRUE, inst.where, inst.pc));
- TableLot.addElement(new Cover(CT_BRANCH_FALSE, inst.where, inst.pc));
- } else {
- TableLot.addElement(new Cover(CT_BRANCH_FALSE, inst.where, inst.pc));
- TableLot.addElement(new Cover(CT_BRANCH_TRUE, inst.where, inst.pc));
- }
- count += 2;
- begseg = false;
- break;
- }
-
- case opc_goto: {
- begseg = false;
- break;
- }
-
- case opc_ret:
- case opc_return:
- case opc_ireturn:
- case opc_lreturn:
- case opc_freturn:
- case opc_dreturn:
- case opc_areturn:
- case opc_athrow: {
- break;
- }
-
- case opc_try: {
- whereTry.addElement(Long.valueOf(inst.where));
- begseg = false;
- break;
- }
-
- case opc_tableswitch: {
- SwitchData sw = (SwitchData)inst.value;
- for (int i = sw.minValue; i <= sw.maxValue; i++) {
- TableLot.addElement(new Cover(CT_CASE, sw.whereCase(i), inst.pc));
- count++;
- }
- if (!sw.getDefault()) {
- TableLot.addElement(new Cover(CT_SWITH_WO_DEF, inst.where, inst.pc));
- count++;
- } else {
- TableLot.addElement(new Cover(CT_CASE, sw.whereCase("default"), inst.pc));
- count++;
- }
- begseg = false;
- break;
- }
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)inst.value;
- for (Enumeration e = sw.sortedKeys(); e.hasMoreElements() ; ) {
- Integer v = e.nextElement();
- TableLot.addElement(new Cover(CT_CASE, sw.whereCase(v), inst.pc));
- count++;
- }
- if (!sw.getDefault()) {
- TableLot.addElement(new Cover(CT_SWITH_WO_DEF, inst.where, inst.pc));
- count++;
- } else {
- TableLot.addElement(new Cover(CT_CASE, sw.whereCase("default"), inst.pc));
- count++;
- }
- begseg = false;
- break;
- }
- }
- }
- Cover Lot;
- long ln, pos;
-
- out.writeShort(count);
- for (int i = 0; i < count; i++) {
- Lot = TableLot.elementAt(i);
- ln = (Lot.Addr >> WHEREOFFSETBITS);
- pos = (Lot.Addr << (64 - WHEREOFFSETBITS)) >> (64 - WHEREOFFSETBITS);
- out.writeShort(Lot.NumCommand);
- out.writeShort(Lot.Type);
- out.writeInt((int)ln);
- out.writeInt((int)pos);
-
- if ( !(Lot.Type == CT_CASE && Lot.Addr == 0) ) {
- JcovClassCountArray[Lot.Type]++;
- }
- }
-
- }
-
-/*
- * Increase count of methods for native methods
- */
-
-public void addNativeToJcovTab(Environment env, ClassDefinition c) {
- JcovClassCountArray[CT_METHOD]++;
-}
-
-/*
- * Create class jcov element
- */
-
-private String createClassJcovElement(Environment env, ClassDefinition c) {
- String SourceClass = (Type.mangleInnerType((c.getClassDeclaration()).getName())).toString();
- String ConvSourceClass;
- String classJcovLine;
-
- SourceClassList.addElement(SourceClass);
- ConvSourceClass = SourceClass.replace('.', '/');
- classJcovLine = JcovClassLine + ConvSourceClass;
-
- classJcovLine = classJcovLine + " [";
- String blank = "";
-
- for (int i = 0; i < arrayModifiers.length; i++ ) {
- if ((c.getModifiers() & arrayModifiers[i]) != 0) {
- classJcovLine = classJcovLine + blank + opNames[arrayModifiersOpc[i]];
- blank = " ";
- }
- }
- classJcovLine = classJcovLine + "]";
-
- return classJcovLine;
-}
-
-/*
- * generate coverage data
- */
-
-public void GenVecJCov(Environment env, ClassDefinition c, long Time) {
- @SuppressWarnings("deprecation")
- String SourceFile = ((SourceClass)c).getAbsoluteName();
-
- TmpCovTable.addElement(createClassJcovElement(env, c));
- TmpCovTable.addElement(JcovSrcfileLine + SourceFile);
- TmpCovTable.addElement(JcovTimestampLine + Time);
- TmpCovTable.addElement(JcovDataLine + "A"); // data format
- TmpCovTable.addElement(JcovHeadingLine);
-
- for (int i = CT_FIRST_KIND; i <= CT_LAST_KIND; i++) {
- if (JcovClassCountArray[i] != 0) {
- TmpCovTable.addElement(new String(i + "\t" + JcovClassCountArray[i]));
- JcovClassCountArray[i] = 0;
- }
- }
-}
-
-
-/*
- * generate file of coverage data
- */
-
-@SuppressWarnings("deprecation") // for JCovd.readLine() calls
-public void GenJCov(Environment env) {
-
- try {
- File outFile = env.getcovFile();
- if( outFile.exists()) {
- DataInputStream JCovd = new DataInputStream(
- new BufferedInputStream(
- new FileInputStream(outFile)));
- String CurrLine = null;
- boolean first = true;
- String Class;
-
- CurrLine = JCovd.readLine();
- if ((CurrLine != null) && CurrLine.startsWith(JcovMagicLine)) {
- // this is a good Jcov file
-
- while((CurrLine = JCovd.readLine()) != null ) {
- if ( CurrLine.startsWith(JcovClassLine) ) {
- first = true;
- for(Enumeration e = SourceClassList.elements(); e.hasMoreElements();) {
- String clsName = CurrLine.substring(JcovClassLine.length());
- int idx = clsName.indexOf(' ');
-
- if (idx != -1) {
- clsName = clsName.substring(0, idx);
- }
- Class = e.nextElement();
- if ( Class.compareTo(clsName) == 0) {
- first = false;
- break;
- }
- }
- }
- if (first) // re-write old class
- TmpCovTable.addElement(CurrLine);
- }
- }
- JCovd.close();
- }
- PrintStream CovFile = new PrintStream(new DataOutputStream(new FileOutputStream(outFile)));
- CovFile.println(JcovMagicLine);
- for(Enumeration e = TmpCovTable.elements(); e.hasMoreElements();) {
- CovFile.println(e.nextElement());
- }
- CovFile.close();
- }
- catch (FileNotFoundException e) {
- System.out.println("ERROR: " + e);
- }
- catch (IOException e) {
- System.out.println("ERROR: " + e);
- }
-}
-// end JCOV
-
-
- /**
- * Write the linenumber table
- */
- public void writeLineNumberTable(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- long ln = -1;
- int count = 0;
-
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- long n = (inst.where >> WHEREOFFSETBITS);
- if ((n > 0) && (ln != n)) {
- ln = n;
- count++;
- }
- }
-
- ln = -1;
- out.writeShort(count);
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- long n = (inst.where >> WHEREOFFSETBITS);
- if ((n > 0) && (ln != n)) {
- ln = n;
- out.writeShort(inst.pc);
- out.writeShort((int)ln);
- //System.out.println("pc = " + inst.pc + ", ln = " + ln);
- }
- }
- }
-
- /**
- * Figure out when registers contain a legal value. This is done
- * using a simple data flow algorithm. This information is later used
- * to generate the local variable table.
- */
- void flowFields(Environment env, Label lbl, MemberDefinition locals[]) {
- if (lbl.locals != null) {
- // Been here before. Erase any conflicts.
- MemberDefinition f[] = lbl.locals;
- for (int i = 0 ; i < maxvar ; i++) {
- if (f[i] != locals[i]) {
- f[i] = null;
- }
- }
- return;
- }
-
- // Remember the set of active registers at this point
- lbl.locals = new MemberDefinition[maxvar];
- System.arraycopy(locals, 0, lbl.locals, 0, maxvar);
-
- MemberDefinition newlocals[] = new MemberDefinition[maxvar];
- System.arraycopy(locals, 0, newlocals, 0, maxvar);
- locals = newlocals;
-
- for (Instruction inst = lbl.next ; inst != null ; inst = inst.next) {
- switch (inst.opc) {
- case opc_istore: case opc_istore_0: case opc_istore_1:
- case opc_istore_2: case opc_istore_3:
- case opc_fstore: case opc_fstore_0: case opc_fstore_1:
- case opc_fstore_2: case opc_fstore_3:
- case opc_astore: case opc_astore_0: case opc_astore_1:
- case opc_astore_2: case opc_astore_3:
- case opc_lstore: case opc_lstore_0: case opc_lstore_1:
- case opc_lstore_2: case opc_lstore_3:
- case opc_dstore: case opc_dstore_0: case opc_dstore_1:
- case opc_dstore_2: case opc_dstore_3:
- if (inst.value instanceof LocalVariable) {
- LocalVariable v = (LocalVariable)inst.value;
- locals[v.slot] = v.field;
- }
- break;
-
- case opc_label:
- flowFields(env, (Label)inst, locals);
- return;
-
- case opc_ifeq: case opc_ifne: case opc_ifgt:
- case opc_ifge: case opc_iflt: case opc_ifle:
- case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmpgt:
- case opc_if_icmpge: case opc_if_icmplt: case opc_if_icmple:
- case opc_if_acmpeq: case opc_if_acmpne:
- case opc_ifnull: case opc_ifnonnull:
- case opc_jsr:
- flowFields(env, (Label)inst.value, locals);
- break;
-
- case opc_goto:
- flowFields(env, (Label)inst.value, locals);
- return;
-
- case opc_return: case opc_ireturn: case opc_lreturn:
- case opc_freturn: case opc_dreturn: case opc_areturn:
- case opc_athrow: case opc_ret:
- return;
-
- case opc_tableswitch:
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)inst.value;
- flowFields(env, sw.defaultLabel, locals);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- flowFields(env, e.nextElement(), locals);
- }
- return;
- }
-
- case opc_try: {
- Vector catches = ((TryData)inst.value).catches;
- for (Enumeration e = catches.elements(); e.hasMoreElements();) {
- CatchData cd = e.nextElement();
- flowFields(env, cd.getLabel(), locals);
- }
- break;
- }
- }
- }
- }
-
- /**
- * Write the local variable table. The necessary constants have already been
- * added to the constant table by the collect() method. The flowFields method
- * is used to determine which variables are alive at each pc.
- */
- public void writeLocalVariableTable(Environment env, MemberDefinition field, DataOutputStream out, ConstantPool tab) throws IOException {
- MemberDefinition locals[] = new MemberDefinition[maxvar];
- int i = 0;
-
- // Initialize arguments
- if ((field != null) && (field.getArguments() != null)) {
- int reg = 0;
- @SuppressWarnings("unchecked")
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = e.nextElement();
- locals[reg] = f;
- reg += f.getType().stackSize();
- }
- }
-
- flowFields(env, first, locals);
- LocalVariableTable lvtab = new LocalVariableTable();
-
- // Initialize arguments again
- for (i = 0; i < maxvar; i++)
- locals[i] = null;
- if ((field != null) && (field.getArguments() != null)) {
- int reg = 0;
- @SuppressWarnings("unchecked")
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = e.nextElement();
- locals[reg] = f;
- lvtab.define(f, reg, 0, maxpc);
- reg += f.getType().stackSize();
- }
- }
-
- int pcs[] = new int[maxvar];
-
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- switch (inst.opc) {
- case opc_istore: case opc_istore_0: case opc_istore_1:
- case opc_istore_2: case opc_istore_3: case opc_fstore:
- case opc_fstore_0: case opc_fstore_1: case opc_fstore_2:
- case opc_fstore_3:
- case opc_astore: case opc_astore_0: case opc_astore_1:
- case opc_astore_2: case opc_astore_3:
- case opc_lstore: case opc_lstore_0: case opc_lstore_1:
- case opc_lstore_2: case opc_lstore_3:
- case opc_dstore: case opc_dstore_0: case opc_dstore_1:
- case opc_dstore_2: case opc_dstore_3:
- if (inst.value instanceof LocalVariable) {
- LocalVariable v = (LocalVariable)inst.value;
- int pc = (inst.next != null) ? inst.next.pc : inst.pc;
- if (locals[v.slot] != null) {
- lvtab.define(locals[v.slot], v.slot, pcs[v.slot], pc);
- }
- pcs[v.slot] = pc;
- locals[v.slot] = v.field;
- }
- break;
-
- case opc_label: {
- // flush previous labels
- for (i = 0 ; i < maxvar ; i++) {
- if (locals[i] != null) {
- lvtab.define(locals[i], i, pcs[i], inst.pc);
- }
- }
- // init new labels
- int pc = inst.pc;
- MemberDefinition[] labelLocals = ((Label)inst).locals;
- if (labelLocals == null) { // unreachable code??
- for (i = 0; i < maxvar; i++)
- locals[i] = null;
- } else {
- System.arraycopy(labelLocals, 0, locals, 0, maxvar);
- }
- for (i = 0 ; i < maxvar ; i++) {
- pcs[i] = pc;
- }
- break;
- }
- }
- }
-
- // flush remaining labels
- for (i = 0 ; i < maxvar ; i++) {
- if (locals[i] != null) {
- lvtab.define(locals[i], i, pcs[i], maxpc);
- }
- }
-
- // write the local variable table
- lvtab.write(env, out, tab);
- }
-
- /**
- * Return true if empty
- */
- public boolean empty() {
- return first == last;
- }
-
- /**
- * Print the byte codes
- */
- public void listing(PrintStream out) {
- out.println("-- listing --");
- for (Instruction inst = first ; inst != null ; inst = inst.next) {
- out.println(inst.toString());
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/CatchData.java b/src/jdk.rmic/share/classes/sun/tools/asm/CatchData.java
deleted file mode 100644
index eb569769323..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/CatchData.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.util.Hashtable;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class CatchData {
- Object type;
- Label label;
-
- /**
- * Constructor
- */
- CatchData(Object type) {
- this.type = type;
- this.label = new Label();
- }
-
- /**
- * Get the label
- */
- public Label getLabel() {
- return label;
- }
-
- /**
- * Get the clazz
- */
- public Object getType() {
- return type;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/ClassConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/ClassConstantData.java
deleted file mode 100644
index 3c160650b5b..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/ClassConstantData.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This is a class constant pool item.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class ClassConstantData extends ConstantPoolData {
- String name;
-
- /**
- * Constructor
- */
-
- ClassConstantData(ConstantPool tab, ClassDeclaration clazz) {
- String sig = clazz.getType().getTypeSignature();
- // sig is like "Lfoo/bar;", name is like "foo/bar".
- // We assume SIG_CLASS and SIG_ENDCLASS are 1 char each.
- name = sig.substring(1, sig.length()-1);
- tab.put(name);
- }
-
- // REMIND: this case should eventually go away.
- ClassConstantData(ConstantPool tab, Type t) {
- name = t.getTypeSignature();
- tab.put(name);
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- out.writeByte(CONSTANT_CLASS);
- out.writeShort(tab.index(name));
- }
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 1;
- }
-
- public String toString() {
- return "ClassConstantData[" + name + "]";
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPool.java b/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPool.java
deleted file mode 100644
index 2292c2cd64b..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPool.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import sun.tools.tree.StringExpression;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * A table of constants
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class ConstantPool implements RuntimeConstants {
- Hashtable hash = new Hashtable<>(101);
-
- /**
- * Find an entry, may return 0
- */
- public int index(Object obj) {
- return hash.get(obj).index;
- }
-
- /**
- * Add an entry
- */
- public void put(Object obj) {
- ConstantPoolData data = hash.get(obj);
- if (data == null) {
- if (obj instanceof String) {
- data = new StringConstantData(this, (String)obj);
- } else if (obj instanceof StringExpression) {
- data = new StringExpressionConstantData(this, (StringExpression)obj);
- } else if (obj instanceof ClassDeclaration) {
- data = new ClassConstantData(this, (ClassDeclaration)obj);
- } else if (obj instanceof Type) {
- data = new ClassConstantData(this, (Type)obj);
- } else if (obj instanceof MemberDefinition) {
- data = new FieldConstantData(this, (MemberDefinition)obj);
- } else if (obj instanceof NameAndTypeData) {
- data = new NameAndTypeConstantData(this, (NameAndTypeData)obj);
- } else if (obj instanceof Number) {
- data = new NumberConstantData(this, (Number)obj);
- }
- hash.put(obj, data);
- }
- }
-
- /**
- * Write to output
- */
- public void write(Environment env, DataOutputStream out) throws IOException {
- ConstantPoolData list[] = new ConstantPoolData[hash.size()];
- String keys[] = new String[list.length];
- int index = 1, count = 0;
-
- // Make a list of all the constant pool items
- for (int n = 0 ; n < 5 ; n++) {
- int first = count;
- for (Enumeration e = hash.elements() ; e.hasMoreElements() ;) {
- ConstantPoolData data = e.nextElement();
- if (data.order() == n) {
- keys[count] = sortKey(data);
- list[count++] = data;
- }
- }
- xsort(list, keys, first, count-1);
- }
-
- // Assign an index to each constant pool item
- for (int n = 0 ; n < list.length ; n++) {
- ConstantPoolData data = list[n];
- data.index = index;
- index += data.width();
- }
-
- // Write length
- out.writeShort(index);
-
- // Write each constant pool item
- for (int n = 0 ; n < count ; n++) {
- list[n].write(env, out, this);
- }
- }
-
- private
- static String sortKey(ConstantPoolData f) {
- if (f instanceof NumberConstantData) {
- Number num = ((NumberConstantData)f).num;
- String str = num.toString();
- int key = 3;
- if (num instanceof Integer) key = 0;
- else if (num instanceof Float) key = 1;
- else if (num instanceof Long) key = 2;
- return "\0" + (char)(str.length() + key<<8) + str;
- }
- if (f instanceof StringExpressionConstantData)
- return (String)((StringExpressionConstantData)f).str.getValue();
- if (f instanceof FieldConstantData) {
- MemberDefinition fd = ((FieldConstantData)f).field;
- return fd.getName()+" "+fd.getType().getTypeSignature()
- +" "+fd.getClassDeclaration().getName();
- }
- if (f instanceof NameAndTypeConstantData)
- return ((NameAndTypeConstantData)f).name+
- " "+((NameAndTypeConstantData)f).type;
- if (f instanceof ClassConstantData)
- return ((ClassConstantData)f).name;
- return ((StringConstantData)f).str;
- }
-
- /**
- * Quick sort an array of pool entries and a corresponding array of Strings
- * that are the sort keys for the field.
- */
- private
- static void xsort(ConstantPoolData ff[], String ss[], int left, int right) {
- if (left >= right)
- return;
- String pivot = ss[left];
- int l = left;
- int r = right;
- while (l < r) {
- while (l <= right && ss[l].compareTo(pivot) <= 0)
- l++;
- while (r >= left && ss[r].compareTo(pivot) > 0)
- r--;
- if (l < r) {
- // swap items at l and at r
- ConstantPoolData def = ff[l];
- String name = ss[l];
- ff[l] = ff[r]; ff[r] = def;
- ss[l] = ss[r]; ss[r] = name;
- }
- }
- int middle = r;
- // swap left and middle
- ConstantPoolData def = ff[left];
- String name = ss[left];
- ff[left] = ff[middle]; ff[middle] = def;
- ss[left] = ss[middle]; ss[middle] = name;
- xsort(ff, ss, left, middle-1);
- xsort(ff, ss, middle + 1, right);
- }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPoolData.java b/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPoolData.java
deleted file mode 100644
index 498a9717858..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/ConstantPoolData.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * Base constant data class. Every constant pool data item
- * is derived from this class.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-abstract class ConstantPoolData implements RuntimeConstants {
- int index;
-
- /**
- * Write the constant to the output stream
- */
- abstract void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException;
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 0;
- }
-
- /**
- * Return the number of entries that it takes up in the constant pool
- */
- int width() {
- return 1;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/Cover.java b/src/jdk.rmic/share/classes/sun/tools/asm/Cover.java
deleted file mode 100644
index 7de1acc2cf6..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/Cover.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, 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 sun.tools.asm;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public class Cover {
-public int Type;
-public long Addr;
-public int NumCommand;
-
- /**
- * Constructor
- */
- public Cover(int type, long addr, int command) {
- Type=type;
- Addr=addr;
- NumCommand=command;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/FieldConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/FieldConstantData.java
deleted file mode 100644
index 3eec7f92951..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/FieldConstantData.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This is a field constant pool data item
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class FieldConstantData extends ConstantPoolData {
- MemberDefinition field;
- NameAndTypeData nt;
-
- /**
- * Constructor
- */
- FieldConstantData(ConstantPool tab, MemberDefinition field) {
- this.field = field;
- nt = new NameAndTypeData(field);
- tab.put(field.getClassDeclaration());
- tab.put(nt);
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- if (field.isMethod()) {
- if (field.getClassDefinition().isInterface()) {
- out.writeByte(CONSTANT_INTERFACEMETHOD);
- } else {
- out.writeByte(CONSTANT_METHOD);
- }
- } else {
- out.writeByte(CONSTANT_FIELD);
- }
- out.writeShort(tab.index(field.getClassDeclaration()));
- out.writeShort(tab.index(nt));
- }
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 2;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/Instruction.java b/src/jdk.rmic/share/classes/sun/tools/asm/Instruction.java
deleted file mode 100644
index 48621c71c4e..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/Instruction.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.util.Enumeration;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * An Java instruction
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public
-class Instruction implements Constants {
- long where;
- int pc;
- int opc;
- Object value;
- Instruction next;
-//JCOV
- boolean flagCondInverted; /* if true, the condition is reversed
- relatively of source code */
- boolean flagNoCovered = false; /* if true, the command will
- ignored for coverage */
-
-
- /**
- * Constructor
- */
- public Instruction(long where, int opc, Object value, boolean flagCondInverted) {
- this.where = where;
- this.opc = opc;
- this.value = value;
- this.flagCondInverted = flagCondInverted;
- }
-
- /**
- * Constructor
- */
- public Instruction(boolean flagNoCovered, long where, int opc, Object value) {
- this.where = where;
- this.opc = opc;
- this.value = value;
- this.flagNoCovered = flagNoCovered;
- }
-
- /**
- * Constructor
- */
- public Instruction(long where, int opc, boolean flagNoCovered) {
- this.where = where;
- this.opc = opc;
- this.flagNoCovered = flagNoCovered;
- }
-//end JCOV
-
- /**
- * Constructor
- */
- public Instruction(long where, int opc, Object value) {
- this.where = where;
- this.opc = opc;
- this.value = value;
- }
-
- /**
- * When deciding between a lookupswitch and a tableswitch, this
- * value is used in determining how much size increase is
- * acceptable.
- */
- public static final double SWITCHRATIO;
-
- static {
- // Set SWITCHRATIO from the property javac.switchratio
- // if it exists and is reasonable. Otherwise, set
- // SWITCHRATIO to 1.5, meaning that we will accept a 1.5x
- // blowup (for the instruction) to use a tableswitch instead
- // of a lookupswitch.
- double ratio = 1.5;
- String valStr = System.getProperty("javac.switchratio");
- if (valStr != null) {
- try {
- double temp = Double.valueOf(valStr).doubleValue();
- if (!(Double.isNaN(temp) || temp < 0.0)) {
- ratio = temp;
- }
- } catch (NumberFormatException ee) {}
- }
- SWITCHRATIO = ratio;
- }
-
- /**
- * Accessor
- */
- public int getOpcode() {
- return pc;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
-
- /**
- * Optimize
- */
- void optimize(Environment env) {
- switch (opc) {
- case opc_istore: case opc_lstore: case opc_fstore:
- case opc_dstore: case opc_astore:
- // Don't keep the LocalVariable info around, unless we
- // are actually going to generate a local variable table.
- if ((value instanceof LocalVariable) && !env.debug_vars()) {
- value = ((LocalVariable)value).slot;
- }
- break;
-
- case opc_goto: {
- Label lbl = (Label)value;
- value = lbl = lbl.getDestination();
- if (lbl == next) {
- // goto to the next instruction, obsolete
- opc = opc_dead;
- break;
- }
-
- // We optimize
- //
- // goto Tag
- // ...
- // Tag:
- // return
- //
- // except when we're generating debuggable code. When
- // we're generating debuggable code, we leave it alone,
- // in order to provide better stepping behavior. Consider
- // a method the end of which looks like this:
- //
- // ...
- // break;
- // } // end of loop
- // } // end of method
- //
- // If we optimize the goto away, we'll be left with a
- // single instruction (return) and the need to ascribe that
- // instruction to two source lines (the break statement and
- // the method's right curly). Can't get there from here.
- // Depending on which line-number ascription we choose, the
- // stepping user will step directly from the break statement
- // back into the caller of the method (case 1) or from the
- // statement that precedes the break statement to the method's
- // right curly (case 2). Similarly, he'll be able to set a
- // breakpoint on the break statement (case 1) or the method's
- // right curly (case 2), but not on both. Neither case 1 nor
- // case 2 is desirable. .We want him to see both the break
- // statement and the method's right curly when stepping,
- // and we want him to be able to set a breakpoint on either or
- // both. So we suppress the optimization when generating
- // debuggable code.
- // (Above notes from brucek@eng in JDK1.0.2, copied here
- // by kelly.ohair@eng for JDK1.1)
- //
- // With the changes to allow -O and -g at the same time,
- // I've changed the condition to be whether optimization is
- // on instead of the debugging flag being off.
- // - david.stoutamire@eng for 1.2
-
- if (lbl.next != null && env.opt()) {
- switch (lbl.next.opc) {
- case opc_return: case opc_ireturn: case opc_lreturn:
- case opc_freturn: case opc_dreturn: case opc_areturn:
- // goto to return
- opc = lbl.next.opc;
- value = lbl.next.value;
- break;
- }
- }
- break;
- }
-
- case opc_ifeq: case opc_ifne: case opc_ifgt:
- case opc_ifge: case opc_iflt: case opc_ifle:
- case opc_ifnull: case opc_ifnonnull:
- value = ((Label)value).getDestination();
- if (value == next) {
- // branch to next instruction, obsolete
- opc = opc_pop;
- break;
- }
- if ((next.opc == opc_goto) && (value == next.next)) {
- // Conditional branch over goto, invert
- // Note that you can't invert all conditions, condition
- // results for float/double compares are not invertable.
- switch (opc) {
- case opc_ifeq: opc = opc_ifne; break;
- case opc_ifne: opc = opc_ifeq; break;
- case opc_iflt: opc = opc_ifge; break;
- case opc_ifle: opc = opc_ifgt; break;
- case opc_ifgt: opc = opc_ifle; break;
- case opc_ifge: opc = opc_iflt; break;
- case opc_ifnull: opc = opc_ifnonnull; break;
- case opc_ifnonnull: opc = opc_ifnull; break;
- }
-//JCOV
- flagCondInverted = !flagCondInverted;
-//end JCOV
- value = next.value;
- next.opc = opc_dead;
- }
- break;
-
- case opc_if_acmpeq: case opc_if_acmpne:
- case opc_if_icmpeq: case opc_if_icmpne:
- case opc_if_icmpgt: case opc_if_icmpge:
- case opc_if_icmplt: case opc_if_icmple:
- value = ((Label)value).getDestination();
- if (value == next) {
- // branch to next instruction, obsolete
- opc = opc_pop2;
- break;
- }
- if ((next.opc == opc_goto) && (value == next.next)) {
- // Conditional branch over goto, invert
- switch (opc) {
- case opc_if_acmpeq: opc = opc_if_acmpne; break;
- case opc_if_acmpne: opc = opc_if_acmpeq; break;
- case opc_if_icmpeq: opc = opc_if_icmpne; break;
- case opc_if_icmpne: opc = opc_if_icmpeq; break;
- case opc_if_icmpgt: opc = opc_if_icmple; break;
- case opc_if_icmpge: opc = opc_if_icmplt; break;
- case opc_if_icmplt: opc = opc_if_icmpge; break;
- case opc_if_icmple: opc = opc_if_icmpgt; break;
- }
-//JCOV
- flagCondInverted = !flagCondInverted;
-//end JCOV
- value = next.value;
- next.opc = opc_dead;
- }
- break;
-
- case opc_tableswitch:
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)value;
- sw.defaultLabel = sw.defaultLabel.getDestination();
- for (Enumeration e = sw.tab.keys() ; e.hasMoreElements() ; ) {
- Integer k = e.nextElement();
- Label lbl = sw.tab.get(k);
- sw.tab.put(k, lbl.getDestination());
- }
-
- // Compute the approximate sizes of a tableswitch and a
- // lookupswitch. Decide which one we want to generate.
-
- long range = (long)sw.maxValue - (long)sw.minValue + 1;
- long entries = sw.tab.size();
-
- long tableSize = 4 + range;
- long lookupSize = 3 + 2 * entries;
-
- if (tableSize <= lookupSize * SWITCHRATIO) {
- opc = opc_tableswitch;
- } else {
- opc = opc_lookupswitch;
- }
- break;
- }
-
- }
- }
-
- /**
- * Collect constants into the constant table
- */
- void collect(ConstantPool tab) {
- switch (opc) {
- case opc_istore: case opc_lstore: case opc_fstore:
- case opc_dstore: case opc_astore:
- if (value instanceof LocalVariable) {
- MemberDefinition field = ((LocalVariable)value).field;
- tab.put(field.getName().toString());
- tab.put(field.getType().getTypeSignature());
- }
- return;
-
- case opc_new: case opc_putfield:
- case opc_putstatic: case opc_getfield:
- case opc_getstatic: case opc_invokevirtual:
- case opc_invokespecial: case opc_invokestatic:
- case opc_invokeinterface: case opc_instanceof:
- case opc_checkcast:
- tab.put(value);
- return;
-
- case opc_anewarray:
- tab.put(value);
- return;
-
- case opc_multianewarray:
- tab.put(((ArrayData)value).type);
- return;
-
- case opc_ldc:
- case opc_ldc_w:
- if (value instanceof Integer) {
- int v = ((Integer)value).intValue();
- if ((v >= -1) && (v <= 5)) {
- opc = opc_iconst_0 + v;
- return;
- } else if ((v >= -(1 << 7)) && (v < (1 << 7))) {
- opc = opc_bipush;
- return;
- } else if ((v >= -(1 << 15)) && (v < (1 << 15))) {
- opc = opc_sipush;
- return;
- }
- } else if (value instanceof Float) {
- float v = ((Float)value).floatValue();
- if (v == 0) {
- if (Float.floatToIntBits(v) == 0) {
- opc = opc_fconst_0;
- return;
- }
- } else if (v == 1) {
- opc = opc_fconst_1;
- return;
- } else if (v == 2) {
- opc = opc_fconst_2;
- return;
- }
- }
- tab.put(value);
- return;
-
- case opc_ldc2_w:
- if (value instanceof Long) {
- long v = ((Long)value).longValue();
- if (v == 0) {
- opc = opc_lconst_0;
- return;
- } else if (v == 1) {
- opc = opc_lconst_1;
- return;
- }
- } else if (value instanceof Double) {
- double v = ((Double)value).doubleValue();
- if (v == 0) {
- if (Double.doubleToLongBits(v) == 0) {
- opc = opc_dconst_0;
- return;
- }
- } else if (v == 1) {
- opc = opc_dconst_1;
- return;
- }
- }
- tab.put(value);
- return;
-
- case opc_try:
- for (Enumeration e = ((TryData)value).catches.elements() ; e.hasMoreElements() ;) {
- CatchData cd = e.nextElement();
- if (cd.getType() != null) {
- tab.put(cd.getType());
- }
- }
- return;
-
- case opc_nop:
- if ((value != null) && (value instanceof ClassDeclaration))
- tab.put(value);
- return;
- }
- }
-
- /**
- * Balance the stack
- */
- int balance() {
- switch (opc) {
- case opc_dead: case opc_label: case opc_iinc:
- case opc_arraylength: case opc_laload: case opc_daload:
- case opc_nop: case opc_ineg: case opc_fneg:
- case opc_lneg: case opc_dneg: case opc_i2f:
- case opc_f2i: case opc_l2d: case opc_d2l:
- case opc_i2b: case opc_i2c: case opc_i2s:
- case opc_jsr: case opc_goto: case opc_jsr_w:
- case opc_goto_w: case opc_return: case opc_ret:
- case opc_instanceof: case opc_checkcast: case opc_newarray:
- case opc_anewarray: case opc_try: case opc_swap:
- return 0;
-
- case opc_ldc: case opc_ldc_w: case opc_bipush:
- case opc_sipush: case opc_aconst_null: case opc_iconst_m1:
- case opc_iconst_0: case opc_iconst_1: case opc_iconst_2:
- case opc_iconst_3: case opc_iconst_4: case opc_iconst_5:
- case opc_fconst_0: case opc_fconst_1: case opc_fconst_2:
- case opc_iload: case opc_fload: case opc_aload:
- case opc_dup: case opc_dup_x1: case opc_dup_x2:
- case opc_i2l: case opc_i2d: case opc_f2l:
- case opc_f2d: case opc_new:
- return 1;
-
- case opc_lload: case opc_dload: case opc_dup2:
- case opc_dup2_x1: case opc_dup2_x2: case opc_ldc2_w:
- case opc_lconst_0: case opc_lconst_1: case opc_dconst_0:
- case opc_dconst_1:
- return 2;
-
- case opc_istore: case opc_fstore: case opc_astore:
- case opc_iaload: case opc_faload: case opc_aaload:
- case opc_baload: case opc_caload: case opc_saload:
- case opc_pop: case opc_iadd: case opc_fadd:
- case opc_isub: case opc_fsub: case opc_imul:
- case opc_fmul: case opc_idiv: case opc_fdiv:
- case opc_irem: case opc_frem: case opc_ishl:
- case opc_ishr: case opc_iushr: case opc_lshl:
- case opc_lshr: case opc_lushr: case opc_iand:
- case opc_ior: case opc_ixor: case opc_l2i:
- case opc_l2f: case opc_d2i: case opc_d2f:
- case opc_ifeq: case opc_ifne: case opc_iflt:
- case opc_ifle: case opc_ifgt: case opc_ifge:
- case opc_ifnull: case opc_ifnonnull: case opc_fcmpl:
- case opc_fcmpg: case opc_ireturn: case opc_freturn:
- case opc_areturn: case opc_tableswitch: case opc_lookupswitch:
- case opc_athrow: case opc_monitorenter: case opc_monitorexit:
- return -1;
-
- case opc_lstore: case opc_dstore: case opc_pop2:
- case opc_ladd: case opc_dadd: case opc_lsub:
- case opc_dsub: case opc_lmul: case opc_dmul:
- case opc_ldiv: case opc_ddiv: case opc_lrem:
- case opc_drem: case opc_land: case opc_lor:
- case opc_lxor: case opc_if_acmpeq: case opc_if_acmpne:
- case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmplt:
- case opc_if_icmple: case opc_if_icmpgt: case opc_if_icmpge:
- case opc_lreturn: case opc_dreturn:
- return -2;
-
- case opc_iastore: case opc_fastore: case opc_aastore:
- case opc_bastore: case opc_castore: case opc_sastore:
- case opc_lcmp: case opc_dcmpl: case opc_dcmpg:
- return -3;
-
- case opc_lastore: case opc_dastore:
- return -4;
-
- case opc_multianewarray:
- return 1 - ((ArrayData)value).nargs;
-
- case opc_getfield:
- return ((MemberDefinition)value).getType().stackSize() - 1;
-
- case opc_putfield:
- return -1 - ((MemberDefinition)value).getType().stackSize();
-
- case opc_getstatic:
- return ((MemberDefinition)value).getType().stackSize();
-
- case opc_putstatic:
- return -((MemberDefinition)value).getType().stackSize();
-
- case opc_invokevirtual:
- case opc_invokespecial:
- case opc_invokeinterface:
- return ((MemberDefinition)value).getType().getReturnType().stackSize() -
- (((MemberDefinition)value).getType().stackSize() + 1);
-
- case opc_invokestatic:
- return ((MemberDefinition)value).getType().getReturnType().stackSize() -
- (((MemberDefinition)value).getType().stackSize());
- }
- throw new CompilerError("invalid opcode: " + toString());
- }
-
- /**
- * Return the size of the instruction
- */
- int size(ConstantPool tab) {
- switch (opc) {
- case opc_try: case opc_label: case opc_dead:
- return 0;
-
- case opc_bipush: case opc_newarray:
- return 2;
-
- case opc_sipush: case opc_goto: case opc_jsr:
- case opc_ifeq: case opc_ifne: case opc_ifgt:
- case opc_ifge: case opc_iflt: case opc_ifle:
- case opc_ifnull: case opc_ifnonnull: case opc_if_acmpeq:
- case opc_if_acmpne: case opc_if_icmpeq: case opc_if_icmpne:
- case opc_if_icmpgt: case opc_if_icmpge: case opc_if_icmplt:
- case opc_if_icmple:
- return 3;
-
- case opc_ldc:
- case opc_ldc_w:
- if (tab.index(value) < 256) {
- opc = opc_ldc;
- return 2;
- } else {
- opc = opc_ldc_w;
- return 3;
- }
-
- case opc_iload: case opc_lload: case opc_fload:
- case opc_dload: case opc_aload: {
- int v = ((Number)value).intValue();
- if (v < 4) {
- if (v < 0) {
- throw new CompilerError("invalid slot: " + toString()
- + "\nThis error possibly resulted from poorly constructed class paths.");
- }
- opc = opc_iload_0 + (opc - opc_iload) * 4 + v;
- return 1;
- } else if (v <= 255) {
- return 2;
- } else {
- opc += 256; // indicate wide variant
- return 4;
- }
- }
-
- case opc_iinc: {
- int register = ((int[])value)[0];
- int increment = ((int[])value)[1];
- if (register < 0) {
- throw new CompilerError("invalid slot: " + toString());
- }
- if (register <= 255 && (((byte)increment) == increment)) {
- return 3;
- } else {
- opc += 256; // indicate wide variant
- return 6;
- }
- }
-
- case opc_istore: case opc_lstore: case opc_fstore:
- case opc_dstore: case opc_astore: {
- int v = (value instanceof Number) ?
- ((Number)value).intValue() : ((LocalVariable)value).slot;
- if (v < 4) {
- if (v < 0) {
- throw new CompilerError("invalid slot: " + toString());
- }
- opc = opc_istore_0 + (opc - opc_istore) * 4 + v;
- return 1;
- } else if (v <= 255) {
- return 2;
- } else {
- opc += 256; // indicate wide variant
- return 4;
- }
- }
-
- case opc_ret: {
- int v = ((Number)value).intValue();
- if (v <= 255) {
- if (v < 0) {
- throw new CompilerError("invalid slot: " + toString());
- }
- return 2;
- } else {
- opc += 256; // indicate wide variant
- return 4;
- }
- }
-
- case opc_ldc2_w: case opc_new:
- case opc_putstatic: case opc_getstatic:
- case opc_putfield: case opc_getfield:
- case opc_invokevirtual: case opc_invokespecial:
- case opc_invokestatic: case opc_instanceof:
- case opc_checkcast: case opc_anewarray:
- return 3;
-
- case opc_multianewarray:
- return 4;
-
- case opc_invokeinterface:
- case opc_goto_w:
- case opc_jsr_w:
- return 5;
-
- case opc_tableswitch: {
- SwitchData sw = (SwitchData)value;
- int n = 1;
- for(; ((pc + n) % 4) != 0 ; n++);
- return n + 16 + (sw.maxValue - sw.minValue) * 4;
- }
-
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)value;
- int n = 1;
- for(; ((pc + n) % 4) != 0 ; n++);
- return n + 8 + sw.tab.size() * 8;
- }
-
- case opc_nop:
- if ((value != null) && !(value instanceof Integer))
- return 2;
- else
- return 1;
- }
-
- // most opcodes are only 1 byte long
- return 1;
- }
-
- /**
- * Generate code
- */
- @SuppressWarnings("fallthrough")
- void write(DataOutputStream out, ConstantPool tab) throws IOException {
- switch (opc) {
- case opc_try: case opc_label: case opc_dead:
- break;
-
- case opc_bipush: case opc_newarray:
- case opc_iload: case opc_lload: case opc_fload:
- case opc_dload: case opc_aload: case opc_ret:
- out.writeByte(opc);
- out.writeByte(((Number)value).intValue());
- break;
-
- case opc_iload + 256: case opc_lload + 256:
- case opc_fload + 256: case opc_dload + 256:
- case opc_aload + 256: case opc_ret + 256:
- out.writeByte(opc_wide);
- out.writeByte(opc - 256);
- out.writeShort(((Number)value).intValue());
- break;
-
- case opc_istore: case opc_lstore: case opc_fstore:
- case opc_dstore: case opc_astore:
- out.writeByte(opc);
- out.writeByte((value instanceof Number) ?
- ((Number)value).intValue() : ((LocalVariable)value).slot);
- break;
-
- case opc_istore + 256: case opc_lstore + 256:
- case opc_fstore + 256: case opc_dstore + 256:
- case opc_astore + 256:
- out.writeByte(opc_wide);
- out.writeByte(opc - 256);
- out.writeShort((value instanceof Number) ?
- ((Number)value).intValue() : ((LocalVariable)value).slot);
- break;
-
- case opc_sipush:
- out.writeByte(opc);
- out.writeShort(((Number)value).intValue());
- break;
-
- case opc_ldc:
- out.writeByte(opc);
- out.writeByte(tab.index(value));
- break;
-
- case opc_ldc_w: case opc_ldc2_w:
- case opc_new: case opc_putstatic:
- case opc_getstatic: case opc_putfield:
- case opc_getfield: case opc_invokevirtual:
- case opc_invokespecial: case opc_invokestatic:
- case opc_instanceof: case opc_checkcast:
- out.writeByte(opc);
- out.writeShort(tab.index(value));
- break;
-
- case opc_iinc:
- out.writeByte(opc);
- out.writeByte(((int[])value)[0]); // register
- out.writeByte(((int[])value)[1]); // increment
- break;
-
- case opc_iinc + 256:
- out.writeByte(opc_wide);
- out.writeByte(opc - 256);
- out.writeShort(((int[])value)[0]); // register
- out.writeShort(((int[])value)[1]); // increment
- break;
-
- case opc_anewarray:
- out.writeByte(opc);
- out.writeShort(tab.index(value));
- break;
-
- case opc_multianewarray:
- out.writeByte(opc);
- out.writeShort(tab.index(((ArrayData)value).type));
- out.writeByte(((ArrayData)value).nargs);
- break;
-
- case opc_invokeinterface:
- out.writeByte(opc);
- out.writeShort(tab.index(value));
- out.writeByte(((MemberDefinition)value).getType().stackSize() + 1);
- out.writeByte(0);
- break;
-
- case opc_goto: case opc_jsr: case opc_ifeq:
- case opc_ifne: case opc_ifgt: case opc_ifge:
- case opc_iflt: case opc_ifle: case opc_ifnull:
- case opc_ifnonnull: case opc_if_acmpeq: case opc_if_acmpne:
- case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmpgt:
- case opc_if_icmpge: case opc_if_icmplt: case opc_if_icmple:
- out.writeByte(opc);
- out.writeShort(((Instruction)value).pc - pc);
- break;
-
- case opc_goto_w:
- case opc_jsr_w:
- out.writeByte(opc);
- out.writeLong(((Instruction)value).pc - pc);
- break;
-
- case opc_tableswitch: {
- SwitchData sw = (SwitchData)value;
- out.writeByte(opc);
- for(int n = 1 ; ((pc + n) % 4) != 0 ; n++) {
- out.writeByte(0);
- }
- out.writeInt(sw.defaultLabel.pc - pc);
- out.writeInt(sw.minValue);
- out.writeInt(sw.maxValue);
- for (int n = sw.minValue ; n <= sw.maxValue ; n++) {
- Label lbl = sw.get(n);
- int target_pc = (lbl != null) ? lbl.pc : sw.defaultLabel.pc;
- out.writeInt(target_pc - pc);
- }
- break;
- }
-
- case opc_lookupswitch: {
- SwitchData sw = (SwitchData)value;
- out.writeByte(opc);
- int n = pc + 1;
- for(; (n % 4) != 0 ; n++) {
- out.writeByte(0);
- }
- out.writeInt(sw.defaultLabel.pc - pc);
- out.writeInt(sw.tab.size());
- for (Enumeration e = sw.sortedKeys(); e.hasMoreElements() ; ) {
- Integer v = e.nextElement();
- out.writeInt(v.intValue());
- out.writeInt(sw.get(v).pc - pc);
- }
- break;
- }
-
- case opc_nop:
- if (value != null) {
- if (value instanceof Integer)
- out.writeByte(((Integer)value).intValue());
- else
- out.writeShort(tab.index(value));
- return;
- }
- // fall through
-
- default:
- out.writeByte(opc);
- break;
- }
- }
-
- /**
- * toString
- */
- public String toString() {
- String prefix = (where >> WHEREOFFSETBITS) + ":\t";
- switch (opc) {
- case opc_try:
- return prefix + "try " + ((TryData)value).getEndLabel().hashCode();
-
- case opc_dead:
- return prefix + "dead";
-
- case opc_iinc: {
- int register = ((int[])value)[0];
- int increment = ((int[])value)[1];
- return prefix + opcNames[opc] + " " + register + ", " + increment;
- }
-
- default:
- if (value != null) {
- if (value instanceof Label) {
- return prefix + opcNames[opc] + " " + value.toString();
- } else if (value instanceof Instruction) {
- return prefix + opcNames[opc] + " " + value.hashCode();
- } else if (value instanceof String) {
- return prefix + opcNames[opc] + " \"" + value + "\"";
- } else {
- return prefix + opcNames[opc] + " " + value;
- }
- } else {
- return prefix + opcNames[opc];
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/Label.java b/src/jdk.rmic/share/classes/sun/tools/asm/Label.java
deleted file mode 100644
index 8c3541730e0..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/Label.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.asm;
-
-import sun.tools.java.MemberDefinition;
-import java.io.OutputStream;
-
-/**
- * A label instruction. This is a 0 size instruction.
- * It is the only valid target of a branch instruction.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class Label extends Instruction {
- static int labelCount = 0;
- int ID;
- int depth;
- MemberDefinition locals[];
-
- /**
- * Constructor
- */
- public Label() {
- super(0, opc_label, null);
- this.ID = ++labelCount;
- }
-
- /**
- * Get the final destination, eliminate jumps gotos, and jumps to
- * labels that are immediately folowed by another label. The depth
- * field is used to leave bread crumbs to avoid infinite loops.
- */
- Label getDestination() {
- Label lbl = this;
- if ((next != null) && (next != this) && (depth == 0)) {
- depth = 1;
-
- switch (next.opc) {
- case opc_label:
- lbl = ((Label)next).getDestination();
- break;
-
- case opc_goto:
- lbl = ((Label)next.value).getDestination();
- break;
-
- case opc_ldc:
- case opc_ldc_w:
- if (next.value instanceof Integer) {
- Instruction inst = next.next;
- if (inst.opc == opc_label) {
- inst = ((Label)inst).getDestination().next;
- }
-
- if (inst.opc == opc_ifeq) {
- if (((Integer)next.value).intValue() == 0) {
- lbl = (Label)inst.value;
- } else {
- lbl = new Label();
- lbl.next = inst.next;
- inst.next = lbl;
- }
- lbl = lbl.getDestination();
- break;
- }
- if (inst.opc == opc_ifne) {
- if (((Integer)next.value).intValue() == 0) {
- lbl = new Label();
- lbl.next = inst.next;
- inst.next = lbl;
- } else {
- lbl = (Label)inst.value;
- }
- lbl = lbl.getDestination();
- break;
- }
- }
- break;
- }
- depth = 0;
- }
- return lbl;
- }
-
- public String toString() {
- String s = "$" + ID + ":";
- if (value != null)
- s = s + " stack=" + value;
- return s;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariable.java b/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariable.java
deleted file mode 100644
index e0b878f3a45..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariable.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-
-/**
- * This class is used to assemble the local variables in the local
- * variable table.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-public final
-class LocalVariable {
- MemberDefinition field;
- int slot;
- int from;
- int to;
-
- public LocalVariable(MemberDefinition field, int slot) {
- if (field == null) {
- new Exception().printStackTrace();
- }
- this.field = field;
- this.slot = slot;
- to = -1;
- }
-
- LocalVariable(MemberDefinition field, int slot, int from, int to) {
- this.field = field;
- this.slot = slot;
- this.from = from;
- this.to = to;
- }
-
- public String toString() {
- return field + "/" + slot;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariableTable.java b/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariableTable.java
deleted file mode 100644
index 33493852b11..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/LocalVariableTable.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This class is used to assemble the local variable table.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-final
-class LocalVariableTable {
- LocalVariable locals[] = new LocalVariable[8];
- int len;
-
- /**
- * Define a new local variable. Merge entries where possible.
- */
- void define(MemberDefinition field, int slot, int from, int to) {
- if (from >= to) {
- return;
- }
- for (int i = 0 ; i < len ; i++) {
- if ((locals[i].field == field) && (locals[i].slot == slot) &&
- (from <= locals[i].to) && (to >= locals[i].from)) {
- locals[i].from = Math.min(locals[i].from, from);
- locals[i].to = Math.max(locals[i].to, to);
- return;
- }
- }
- if (len == locals.length) {
- LocalVariable newlocals[] = new LocalVariable[len * 2];
- System.arraycopy(locals, 0, newlocals, 0, len);
- locals = newlocals;
- }
- locals[len++] = new LocalVariable(field, slot, from, to);
- }
-
- /**
- * Trim overlapping local ranges. Java forbids shadowing of
- * locals in nested scopes, but non-nested scopes may still declare
- * locals with the same name. Because local variable ranges are
- * computed using flow analysis as part of assembly, it isn't
- * possible to simply make sure variable ranges end where the
- * enclosing lexical scope ends. This method makes sure that
- * variables with the same name don't overlap, giving priority to
- * fields with higher slot numbers that should have appeared later
- * in the source.
- */
- private void trim_ranges() {
- for (int i=0; i= locals[j].from)) {
- // At this point we know that both ranges are
- // the same name and there is also overlap or they abut
- if (locals[i].slot < locals[j].slot) {
- if (locals[i].from < locals[j].from) {
- locals[i].to = Math.min(locals[i].to, locals[j].from);
- } else {
- // We've detected two local variables with the
- // same name, and the one with the greater slot
- // number starts before the other. This order
- // reversal may happen with locals with the same
- // name declared in both a try body and an
- // associated catch clause. This is rare, and
- // we give up.
- }
- } else if (locals[i].slot > locals[j].slot) {
- if (locals[i].from > locals[j].from) {
- locals[j].to = Math.min(locals[j].to, locals[i].from);
- } else {
- // Same situation as above; just give up.
- }
- } else {
- // This case can happen if there are two variables
- // with the same name and slot numbers, and ranges
- // that abut. AFAIK the only way this can occur
- // is with multiple static initializers. Punt.
- }
- }
- }
- }
- }
-
- /**
- * Write out the data.
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- trim_ranges();
- out.writeShort(len);
- for (int i = 0 ; i < len ; i++) {
- //System.out.println("pc=" + locals[i].from + ", len=" + (locals[i].to - locals[i].from) + ", nm=" + locals[i].field.getName() + ", slot=" + locals[i].slot);
- out.writeShort(locals[i].from);
- out.writeShort(locals[i].to - locals[i].from);
- out.writeShort(tab.index(locals[i].field.getName().toString()));
- out.writeShort(tab.index(locals[i].field.getType().getTypeSignature()));
- out.writeShort(locals[i].slot);
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeConstantData.java
deleted file mode 100644
index 6f374af75d3..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeConstantData.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This is a name and type constant pool data item
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class NameAndTypeConstantData extends ConstantPoolData {
- String name;
- String type;
-
- /**
- * Constructor
- */
- NameAndTypeConstantData(ConstantPool tab, NameAndTypeData nt) {
- name = nt.field.getName().toString();
- type = nt.field.getType().getTypeSignature();
- tab.put(name);
- tab.put(type);
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- out.writeByte(CONSTANT_NAMEANDTYPE);
- out.writeShort(tab.index(name));
- out.writeShort(tab.index(type));
- }
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 3;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeData.java b/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeData.java
deleted file mode 100644
index 9c9e6765434..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/NameAndTypeData.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-
-/**
- * An object to represent a name and type constant pool data item.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class NameAndTypeData {
- MemberDefinition field;
-
- /**
- * Constructor
- */
- NameAndTypeData(MemberDefinition field) {
- this.field = field;
- }
-
- /**
- * Hashcode
- */
- public int hashCode() {
- return field.getName().hashCode() * field.getType().hashCode();
- }
-
- /**
- * Equality
- */
- public boolean equals(Object obj) {
- if ((obj != null) && (obj instanceof NameAndTypeData)) {
- NameAndTypeData nt = (NameAndTypeData)obj;
- return field.getName().equals(nt.field.getName()) &&
- field.getType().equals(nt.field.getType());
- }
- return false;
- }
-
- /**
- * Convert to string
- */
- public String toString() {
- return "%%" + field.toString() + "%%";
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/NumberConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/NumberConstantData.java
deleted file mode 100644
index 9fd776dac70..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/NumberConstantData.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * A numeric constant pool item. Can either be integer, float, long or double.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class NumberConstantData extends ConstantPoolData {
- Number num;
-
- /**
- * Constructor
- */
- NumberConstantData(ConstantPool tab, Number num) {
- this.num = num;
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- if (num instanceof Integer) {
- out.writeByte(CONSTANT_INTEGER);
- out.writeInt(num.intValue());
- } else if (num instanceof Long) {
- out.writeByte(CONSTANT_LONG);
- out.writeLong(num.longValue());
- } else if (num instanceof Float) {
- out.writeByte(CONSTANT_FLOAT);
- out.writeFloat(num.floatValue());
- } else if (num instanceof Double) {
- out.writeByte(CONSTANT_DOUBLE);
- out.writeDouble(num.doubleValue());
- }
- }
- /**
- * Return the order of the constant
- */
- int order() {
- return (width() == 1) ? 0 : 3;
- }
-
- /**
- * Return the number of entries that it takes up in the constant pool
- */
- int width() {
- return ((num instanceof Double) || (num instanceof Long)) ? 2 : 1;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/StringConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/StringConstantData.java
deleted file mode 100644
index 20eaf88956c..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/StringConstantData.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This is a string constant pool data item.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class StringConstantData extends ConstantPoolData {
- String str;
-
- /**
- * Constructor
- */
- StringConstantData(ConstantPool tab, String str) {
- this.str = str;
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- out.writeByte(CONSTANT_UTF8);
- out.writeUTF(str);
- }
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 4;
- }
-
- /**
- * toString
- */
- public String toString() {
- return "StringConstantData[" + str + "]=" + str.hashCode();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/StringExpressionConstantData.java b/src/jdk.rmic/share/classes/sun/tools/asm/StringExpressionConstantData.java
deleted file mode 100644
index 1afffcac413..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/StringExpressionConstantData.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import sun.tools.tree.StringExpression;
-import java.io.IOException;
-import java.io.DataOutputStream;
-
-/**
- * This is a string expression constant. This constant
- * represents an Java string constant.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class StringExpressionConstantData extends ConstantPoolData {
- StringExpression str;
-
- /**
- * Constructor
- */
- StringExpressionConstantData(ConstantPool tab, StringExpression str) {
- this.str = str;
- tab.put(str.getValue());
- }
-
- /**
- * Write the constant to the output stream
- */
- void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
- out.writeByte(CONSTANT_STRING);
- out.writeShort(tab.index(str.getValue()));
- }
-
- /**
- * Return the order of the constant
- */
- int order() {
- return 0;
- }
-
- /**
- * toString
- */
- public String toString() {
- return "StringExpressionConstantData[" + str.getValue() + "]=" + str.getValue().hashCode();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/SwitchData.java b/src/jdk.rmic/share/classes/sun/tools/asm/SwitchData.java
deleted file mode 100644
index e7cd0f966ea..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/SwitchData.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Arrays;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class SwitchData {
- int minValue, maxValue;
- Label defaultLabel = new Label();
- Hashtable tab = new Hashtable<>();
-// JCOV
- Hashtable whereCaseTab = null;
-// end JCOV
-
- /**
- * Get a label
- */
- public Label get(int n) {
- return tab.get(n);
- }
-
- /**
- * Get a label
- */
- public Label get(Integer n) {
- return tab.get(n);
- }
-
- /**
- * Add a label
- */
- public void add(int n, Label lbl) {
- if (tab.size() == 0) {
- minValue = n;
- maxValue = n;
- } else {
- if (n < minValue) {
- minValue = n;
- }
- if (n > maxValue) {
- maxValue = n;
- }
- }
- tab.put(Integer.valueOf(n), lbl);
- }
-
- /**
- * Get the default label
- */
- public Label getDefaultLabel() {
- return defaultLabel;
- }
-
- /**
- * Return the keys of this enumaration sorted in ascending order
- */
- public synchronized Enumeration sortedKeys() {
- return new SwitchDataEnumeration(tab);
- }
-
-// JCOV
- public void initTableCase() {
- whereCaseTab = new Hashtable();
- }
- public void addTableCase(int index, long where) {
- if (whereCaseTab != null)
- whereCaseTab.put(Integer.valueOf(index), Long.valueOf(where));
- }
- // this puts String key into Hashtable
- @SuppressWarnings("unchecked")
- public void addTableDefault(long where) {
- if (whereCaseTab != null)
- ((Hashtable)whereCaseTab).put("default", Long.valueOf(where));
- }
- public long whereCase(Object key) {
- Long i = whereCaseTab.get(key);
- return (i == null) ? 0L : i.longValue();
- }
- public boolean getDefault() {
- return (whereCase("default") != 0L);
- }
-// end JCOV
-}
-
-class SwitchDataEnumeration implements Enumeration {
- private Integer table[];
- private int current_index = 0;
-
- /**
- * Create a new enumeration from the hashtable. Each key in the
- * hash table will be an Integer, with the value being a label. The
- * enumeration returns the keys in sorted order.
- */
- SwitchDataEnumeration(Hashtable tab) {
- table = new Integer[tab.size()];
- int i = 0;
- for (Enumeration e = tab.keys() ; e.hasMoreElements() ; ) {
- table[i++] = e.nextElement();
- }
- Arrays.sort(table);
- current_index = 0;
- }
-
- /**
- * Are there more keys to return?
- */
- public boolean hasMoreElements() {
- return current_index < table.length;
- }
-
- /**
- * Return the next key.
- */
- public Integer nextElement() {
- return table[current_index++];
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/asm/TryData.java b/src/jdk.rmic/share/classes/sun/tools/asm/TryData.java
deleted file mode 100644
index e18ed6f82c2..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/asm/TryData.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.asm;
-
-import sun.tools.java.*;
-import java.util.Vector;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class TryData {
- Vector catches = new Vector<>();
- Label endLabel = new Label();
-
- /**
- * Add a label
- */
- public CatchData add(Object type) {
- CatchData cd = new CatchData(type);
- catches.addElement(cd);
- return cd;
- }
-
- /**
- * Get a label
- */
- public CatchData getCatch(int n) {
- return catches.elementAt(n);
- }
-
- /**
- * Get the default label
- */
- public Label getEndLabel() {
- return endLabel;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousClass.java b/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousClass.java
deleted file mode 100644
index e8814d05284..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousClass.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.java;
-
-/**
- * This exception is thrown when an unqualified class name
- * is used that can be resolved in more than one way.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-@SuppressWarnings("serial") // JDK implementation class
-public
-class AmbiguousClass extends ClassNotFound {
- /**
- * The class that was not found
- */
- public Identifier name1;
- public Identifier name2;
-
- /**
- * Constructor
- */
- public AmbiguousClass(Identifier name1, Identifier name2) {
- super(name1.getName());
- this.name1 = name1;
- this.name2 = name2;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousMember.java b/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousMember.java
deleted file mode 100644
index cad2bd6f9c5..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/AmbiguousMember.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.java;
-
-import java.util.Enumeration;
-
-/**
- * This exception is thrown when a field reference is
- * ambiguous.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("serial") // JDK implementation class
-public
-class AmbiguousMember extends Exception {
- /**
- * The field that was not found
- */
- public MemberDefinition field1;
- public MemberDefinition field2;
-
- /**
- * Constructor
- */
- public AmbiguousMember(MemberDefinition field1, MemberDefinition field2) {
- super(field1.getName() + " + " + field2.getName());
- this.field1 = field1;
- this.field2 = field2;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ArrayType.java b/src/jdk.rmic/share/classes/sun/tools/java/ArrayType.java
deleted file mode 100644
index 7c2ea19bb8f..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ArrayType.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-/**
- * This class represents an Java array type.
- * It overrides the relevant methods in class Type.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-public final
-class ArrayType extends Type {
- /**
- * The type of the element.
- */
- Type elemType;
-
- /**
- * Construct an array type. Use Type.tArray to create
- * a new array type.
- */
- ArrayType(String typeSig, Type elemType) {
- super(TC_ARRAY, typeSig);
- this.elemType = elemType;
- }
-
- public Type getElementType() {
- return elemType;
- }
-
- public int getArrayDimension() {
- return elemType.getArrayDimension() + 1;
- }
-
- public String typeString(String id, boolean abbrev, boolean ret) {
- return getElementType().typeString(id, abbrev, ret) + "[]";
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryAttribute.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryAttribute.java
deleted file mode 100644
index ed184f23324..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryAttribute.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-/**
- * This class is used to represent an attribute from a binary class.
- * This class should go away once arrays are objects.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class BinaryAttribute implements Constants {
- Identifier name;
- byte data[];
- BinaryAttribute next;
-
- /**
- * Constructor
- */
- BinaryAttribute(Identifier name, byte data[], BinaryAttribute next) {
- this.name = name;
- this.data = data;
- this.next = next;
- }
-
- /**
- * Load a list of attributes
- */
- public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
- BinaryAttribute atts = null;
- int natt = in.readUnsignedShort(); // JVM 4.6 method_info.attrutes_count
-
- for (int i = 0 ; i < natt ; i++) {
- // id from JVM 4.7 attribute_info.attribute_name_index
- Identifier id = cpool.getIdentifier(in.readUnsignedShort());
- // id from JVM 4.7 attribute_info.attribute_length
- int len = in.readInt();
-
- if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
- in.skipBytes(len);
- } else {
- byte data[] = new byte[len];
- in.readFully(data);
- atts = new BinaryAttribute(id, data, atts);
- }
- }
- return atts;
- }
-
- // write out the Binary attributes to the given stream
- // (note that attributes may be null)
- static void write(BinaryAttribute attributes, DataOutputStream out,
- BinaryConstantPool cpool, Environment env) throws IOException {
- // count the number of attributes
- int attributeCount = 0;
- for (BinaryAttribute att = attributes; att != null; att = att.next)
- attributeCount++;
- out.writeShort(attributeCount);
-
- // write out each attribute
- for (BinaryAttribute att = attributes; att != null; att = att.next) {
- Identifier name = att.name;
- byte data[] = att.data;
- // write the identifier
- out.writeShort(cpool.indexString(name.toString(), env));
- // write the length
- out.writeInt(data.length);
- // write the data
- out.write(data, 0, data.length);
- }
- }
-
- /**
- * Accessors
- */
-
- public Identifier getName() { return name; }
-
- public byte[] getData() { return data; }
-
- public BinaryAttribute getNextAttribute() { return next; }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java
deleted file mode 100644
index 711f4dada8a..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.OutputStream;
-import java.io.DataOutputStream;
-import java.io.ByteArrayInputStream;
-import java.util.Hashtable;
-import java.util.Vector;
-import java.util.Enumeration;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("deprecation")
-public final
-class BinaryClass extends ClassDefinition implements Constants {
- BinaryConstantPool cpool;
- BinaryAttribute atts;
- Vector dependencies;
- private boolean haveLoadedNested = false;
-
- /**
- * Constructor
- */
- public BinaryClass(Object source, ClassDeclaration declaration, int modifiers,
- ClassDeclaration superClass, ClassDeclaration interfaces[],
- Vector dependencies) {
- super(source, 0, declaration, modifiers, null, null);
- this.dependencies = dependencies;
- this.superClass = superClass;
- this.interfaces = interfaces;
- }
-
- /**
- * Flags used by basicCheck() to avoid duplicate calls.
- * (Part of fix for 4105911)
- */
- private boolean basicCheckDone = false;
- private boolean basicChecking = false;
-
- /**
- * Ready a BinaryClass for further checking. Note that, until recently,
- * BinaryClass relied on the default basicCheck() provided by
- * ClassDefinition. The definition here has been added to ensure that
- * the information generated by collectInheritedMethods is available
- * for BinaryClasses.
- */
- protected void basicCheck(Environment env) throws ClassNotFound {
- if (tracing) env.dtEnter("BinaryClass.basicCheck: " + getName());
-
- // We need to guard against duplicate calls to basicCheck(). They
- // can lead to calling collectInheritedMethods() for this class
- // from within a previous call to collectInheritedMethods() for
- // this class. That is not allowed.
- // (Part of fix for 4105911)
- if (basicChecking || basicCheckDone) {
- if (tracing) env.dtExit("BinaryClass.basicCheck: OK " + getName());
- return;
- }
-
- if (tracing) env.dtEvent("BinaryClass.basicCheck: CHECKING " + getName());
- basicChecking = true;
-
- super.basicCheck(env);
-
- // Collect inheritance information.
- if (doInheritanceChecks) {
- collectInheritedMethods(env);
- }
-
- basicCheckDone = true;
- basicChecking = false;
- if (tracing) env.dtExit("BinaryClass.basicCheck: " + getName());
- }
-
- /**
- * Load a binary class
- */
- public static BinaryClass load(Environment env, DataInputStream in) throws IOException {
- return load(env, in, ~(ATT_CODE|ATT_ALLCLASSES));
- }
-
- public static BinaryClass load(Environment env,
- DataInputStream in, int mask) throws IOException {
- // Read the header
- int magic = in.readInt(); // JVM 4.1 ClassFile.magic
- if (magic != JAVA_MAGIC) {
- throw new ClassFormatError("wrong magic: " + magic + ", expected " + JAVA_MAGIC);
- }
- int minor_version = in.readUnsignedShort(); // JVM 4.1 ClassFile.minor_version
- int version = in.readUnsignedShort(); // JVM 4.1 ClassFile.major_version
- if (version < JAVA_MIN_SUPPORTED_VERSION) {
- throw new ClassFormatError(
- sun.tools.javac.Main.getText(
- "javac.err.version.too.old",
- String.valueOf(version)));
- } else if ((version >= JAVA_MIN_PREVIEW_MAJOR_VERSION)
- && (minor_version == JAVA_PREVIEW_MINOR_VERSION)) {
- // reject all class files that have preview features enabled
- throw new ClassFormatError(
- sun.tools.javac.Main.getText(
- "javac.err.version.preview",
- version+"."+minor_version));
- } else if ((version > JAVA_MAX_SUPPORTED_VERSION)
- || (version == JAVA_MAX_SUPPORTED_VERSION
- && minor_version > JAVA_MAX_SUPPORTED_MINOR_VERSION)) {
- throw new ClassFormatError(
- sun.tools.javac.Main.getText(
- "javac.err.version.too.recent",
- version+"."+minor_version));
- }
-
- // Read the constant pool
- BinaryConstantPool cpool = new BinaryConstantPool(in);
-
- // The dependencies of this class
- Vector dependencies = cpool.getDependencies(env);
-
- // Read modifiers
- int classMod = in.readUnsignedShort() & ACCM_CLASS; // JVM 4.1 ClassFile.access_flags
-
- // Read the class name - from JVM 4.1 ClassFile.this_class
- ClassDeclaration classDecl = cpool.getDeclaration(env, in.readUnsignedShort());
-
- // Read the super class name (may be null) - from JVM 4.1 ClassFile.super_class
- ClassDeclaration superClassDecl = cpool.getDeclaration(env, in.readUnsignedShort());
-
- // Read the interface names - from JVM 4.1 ClassFile.interfaces_count
- ClassDeclaration interfaces[] = new ClassDeclaration[in.readUnsignedShort()];
- for (int i = 0 ; i < interfaces.length ; i++) {
- // JVM 4.1 ClassFile.interfaces[]
- interfaces[i] = cpool.getDeclaration(env, in.readUnsignedShort());
- }
-
- // Allocate the class
- BinaryClass c = new BinaryClass(null, classDecl, classMod, superClassDecl,
- interfaces, dependencies);
- c.cpool = cpool;
-
- // Add any additional dependencies
- c.addDependency(superClassDecl);
-
- // Read the fields
- int nfields = in.readUnsignedShort(); // JVM 4.1 ClassFile.fields_count
- for (int i = 0 ; i < nfields ; i++) {
- // JVM 4.5 field_info.access_flags
- int fieldMod = in.readUnsignedShort() & ACCM_FIELD;
- // JVM 4.5 field_info.name_index
- Identifier fieldName = cpool.getIdentifier(in.readUnsignedShort());
- // JVM 4.5 field_info.descriptor_index
- Type fieldType = cpool.getType(in.readUnsignedShort());
- BinaryAttribute atts = BinaryAttribute.load(in, cpool, mask);
- c.addMember(new BinaryMember(c, fieldMod, fieldType, fieldName, atts));
- }
-
- // Read the methods
- int nmethods = in.readUnsignedShort(); // JVM 4.1 ClassFile.methods_count
- for (int i = 0 ; i < nmethods ; i++) {
- // JVM 4.6 method_info.access_flags
- int methMod = in.readUnsignedShort() & ACCM_METHOD;
- // JVM 4.6 method_info.name_index
- Identifier methName = cpool.getIdentifier(in.readUnsignedShort());
- // JVM 4.6 method_info.descriptor_index
- Type methType = cpool.getType(in.readUnsignedShort());
- BinaryAttribute atts = BinaryAttribute.load(in, cpool, mask);
- c.addMember(new BinaryMember(c, methMod, methType, methName, atts));
- }
-
- // Read the class attributes
- c.atts = BinaryAttribute.load(in, cpool, mask);
-
- // See if the SourceFile is known
- byte data[] = c.getAttribute(idSourceFile);
- if (data != null) {
- DataInputStream dataStream = new DataInputStream(new ByteArrayInputStream(data));
- // JVM 4.7.2 SourceFile_attribute.sourcefile_index
- c.source = cpool.getString(dataStream.readUnsignedShort());
- }
-
- // See if the Documentation is know
- data = c.getAttribute(idDocumentation);
- if (data != null) {
- c.documentation = new DataInputStream(new ByteArrayInputStream(data)).readUTF();
- }
-
- // Was it compiled as deprecated?
- if (c.getAttribute(idDeprecated) != null) {
- c.modifiers |= M_DEPRECATED;
- }
-
- // Was it synthesized by the compiler?
- if (c.getAttribute(idSynthetic) != null) {
- c.modifiers |= M_SYNTHETIC;
- }
-
- return c;
- }
-
- /**
- * Called when an environment ties a binary definition to a declaration.
- * At this point, auxiliary definitions may be loaded.
- */
-
- public void loadNested(Environment env) {
- loadNested(env, 0);
- }
-
- public void loadNested(Environment env, int flags) {
- // Sanity check.
- if (haveLoadedNested) {
- // Duplicate calls most likely should not occur, but they do
- // in javap. Be tolerant of them for the time being.
- // throw new CompilerError("multiple loadNested");
- if (tracing) env.dtEvent("loadNested: DUPLICATE CALL SKIPPED");
- return;
- }
- haveLoadedNested = true;
- // Read class-nesting information.
- try {
- byte data[];
- data = getAttribute(idInnerClasses);
- if (data != null) {
- initInnerClasses(env, data, flags);
- }
- } catch (IOException ee) {
- // The inner classes attribute is not well-formed.
- // It may, for example, contain no data. Report this.
- // We used to throw a CompilerError here (bug 4095108).
- env.error(0, "malformed.attribute", getClassDeclaration(),
- idInnerClasses);
- if (tracing)
- env.dtEvent("loadNested: MALFORMED ATTRIBUTE (InnerClasses)");
- }
- }
-
- private void initInnerClasses(Environment env,
- byte data[],
- int flags) throws IOException {
- DataInputStream ds = new DataInputStream(new ByteArrayInputStream(data));
- int nrec = ds.readUnsignedShort(); // InnerClasses_attribute.number_of_classes
- for (int i = 0; i < nrec; i++) {
- // For each inner class name transformation, we have a record
- // with the following fields:
- //
- // u2 inner_class_info_index; // CONSTANT_Class_info index
- // u2 outer_class_info_index; // CONSTANT_Class_info index
- // u2 inner_name_index; // CONSTANT_Utf8_info index
- // u2 inner_class_access_flags; // access_flags bitmask
- //
- // The spec states that outer_class_info_index is 0 iff
- // the inner class is not a member of its enclosing class (i.e.
- // it is a local or anonymous class). The spec also states
- // that if a class is anonymous then inner_name_index should
- // be 0.
- //
- // Prior to jdk1.2, javac did not implement the spec. Instead
- // it always set outer_class_info_index to the
- // enclosing outer class and if the class was anonymous,
- // it set inner_name_index to be the index of a CONSTANT_Utf8
- // entry containing the null string "" (idNull). This code is
- // designed to handle either kind of class file.
- //
- // See also the compileClass() method in SourceClass.java.
-
- // Read in the inner_class_info
- // InnerClasses_attribute.classes.inner_class_info_index
- int inner_index = ds.readUnsignedShort();
- // could check for zero.
- ClassDeclaration inner = cpool.getDeclaration(env, inner_index);
-
- // Read in the outer_class_info. Note that the index will be
- // zero if the class is "not a member".
- ClassDeclaration outer = null;
- // InnerClasses_attribute.classes.outer_class_info_index
- int outer_index = ds.readUnsignedShort();
- if (outer_index != 0) {
- outer = cpool.getDeclaration(env, outer_index);
- }
-
- // Read in the inner_name_index. This may be zero. An anonymous
- // class will either have an inner_nm_index of zero (as the spec
- // dictates) or it will have an inner_nm of idNull (for classes
- // generated by pre-1.2 compilers). Handle both.
- Identifier inner_nm = idNull;
- // InnerClasses_attribute.classes.inner_name_index
- int inner_nm_index = ds.readUnsignedShort();
- if (inner_nm_index != 0) {
- inner_nm = Identifier.lookup(cpool.getString(inner_nm_index));
- }
-
- // Read in the modifiers for the inner class.
- // InnerClasses_attribute.classes.inner_name_index
- int mods = ds.readUnsignedShort();
-
- // Is the class accessible?
- // The old code checked for
- //
- // (!inner_nm.equals(idNull) && (mods & M_PRIVATE) == 0)
- //
- // which we will preserve to keep it working for class files
- // generated by 1.1 compilers. In addition we check for
- //
- // (outer != null)
- //
- // as an additional check that only makes sense with 1.2
- // generated files. Note that it is entirely possible that
- // the M_PRIVATE bit is always enough. We are being
- // conservative here.
- //
- // The ATT_ALLCLASSES flag causes the M_PRIVATE modifier
- // to be ignored, and is used by tools such as 'javap' that
- // wish to examine all classes regardless of the normal access
- // controls that apply during compilation. Note that anonymous
- // and local classes are still not considered accessible, though
- // named local classes in jdk1.1 may slip through. Note that
- // this accessibility test is an optimization, and it is safe to
- // err on the side of greater accessibility.
- boolean accessible =
- (outer != null) &&
- (!inner_nm.equals(idNull)) &&
- ((mods & M_PRIVATE) == 0 ||
- (flags & ATT_ALLCLASSES) != 0);
-
- // The reader should note that there has been a significant change
- // in the way that the InnerClasses attribute is being handled.
- // In particular, previously the compiler called initInner() for
- // every inner class. Now the compiler does not call
- // initInner() if the inner class is inaccessible. This means
- // that inaccessible inner classes don't have any of the processing
- // from initInner() done for them: fixing the access flags,
- // setting outerClass, setting outerMember in their outerClass,
- // etc. We believe this is fine: if the class is inaccessible
- // and binary, then everyone who needs to see its internals
- // has already been compiled. Hopefully.
-
- if (accessible) {
- Identifier nm =
- Identifier.lookupInner(outer.getName(), inner_nm);
-
- // Tell the type module about the nesting relation:
- Type.tClass(nm);
-
- if (inner.equals(getClassDeclaration())) {
- // The inner class in the record is this class.
- try {
- ClassDefinition outerClass = outer.getClassDefinition(env);
- initInner(outerClass, mods);
- } catch (ClassNotFound e) {
- // report the error elsewhere
- }
- } else if (outer.equals(getClassDeclaration())) {
- // The outer class in the record is this class.
- try {
- ClassDefinition innerClass =
- inner.getClassDefinition(env);
- initOuter(innerClass, mods);
- } catch (ClassNotFound e) {
- // report the error elsewhere
- }
- }
- }
- }
- }
-
- private void initInner(ClassDefinition outerClass, int mods) {
- if (getOuterClass() != null)
- return; // already done
- /******
- // Maybe set static, protected, or private.
- if ((modifiers & M_PUBLIC) != 0)
- mods &= M_STATIC;
- else
- mods &= M_PRIVATE | M_PROTECTED | M_STATIC;
- modifiers |= mods;
- ******/
- // For an inner class, the class access may have been weakened
- // from that originally declared the source. We must take the
- // actual access permissions against which we check any source
- // we are currently compiling from the InnerClasses attribute.
- // We attempt to guard here against bogus combinations of modifiers.
- if ((mods & M_PRIVATE) != 0) {
- // Private cannot be combined with public or protected.
- mods &= ~(M_PUBLIC | M_PROTECTED);
- } else if ((mods & M_PROTECTED) != 0) {
- // Protected cannot be combined with public.
- mods &= ~M_PUBLIC;
- }
- if ((mods & M_INTERFACE) != 0) {
- // All interfaces are implicitly abstract.
- // All interfaces that are members of a type are implicitly static.
- mods |= (M_ABSTRACT | M_STATIC);
- }
- if (outerClass.isInterface()) {
- // All types that are members of interfaces are implicitly
- // public and static.
- mods |= (M_PUBLIC | M_STATIC);
- mods &= ~(M_PRIVATE | M_PROTECTED);
- }
- modifiers = mods;
-
- setOuterClass(outerClass);
-
- for (MemberDefinition field = getFirstMember();
- field != null;
- field = field.getNextMember()) {
- if (field.isUplevelValue()
- && outerClass.getType().equals(field.getType())
- && field.getName().toString().startsWith(prefixThis)) {
- setOuterMember(field);
- }
- }
- }
-
- private void initOuter(ClassDefinition innerClass, int mods) {
- if (innerClass instanceof BinaryClass)
- ((BinaryClass)innerClass).initInner(this, mods);
- addMember(new BinaryMember(innerClass));
- }
-
- /**
- * Write the class out to a given stream. This function mirrors the loader.
- */
- public void write(Environment env, OutputStream out) throws IOException {
- DataOutputStream data = new DataOutputStream(out);
-
- // write out the header
- data.writeInt(JAVA_MAGIC);
- data.writeShort(env.getMinorVersion());
- data.writeShort(env.getMajorVersion());
-
- // Write out the constant pool
- cpool.write(data, env);
-
- // Write class information
- data.writeShort(getModifiers() & ACCM_CLASS);
- data.writeShort(cpool.indexObject(getClassDeclaration(), env));
- data.writeShort((getSuperClass() != null)
- ? cpool.indexObject(getSuperClass(), env) : 0);
- data.writeShort(interfaces.length);
- for (int i = 0 ; i < interfaces.length ; i++) {
- data.writeShort(cpool.indexObject(interfaces[i], env));
- }
-
- // count the fields and the methods
- int fieldCount = 0, methodCount = 0;
- for (MemberDefinition f = firstMember; f != null; f = f.getNextMember())
- if (f.isMethod()) methodCount++; else fieldCount++;
-
- // write out each the field count, and then each field
- data.writeShort(fieldCount);
- for (MemberDefinition f = firstMember; f != null; f = f.getNextMember()) {
- if (!f.isMethod()) {
- data.writeShort(f.getModifiers() & ACCM_FIELD);
- String name = f.getName().toString();
- String signature = f.getType().getTypeSignature();
- data.writeShort(cpool.indexString(name, env));
- data.writeShort(cpool.indexString(signature, env));
- BinaryAttribute.write(((BinaryMember)f).atts, data, cpool, env);
- }
- }
-
- // write out each method count, and then each method
- data.writeShort(methodCount);
- for (MemberDefinition f = firstMember; f != null; f = f.getNextMember()) {
- if (f.isMethod()) {
- data.writeShort(f.getModifiers() & ACCM_METHOD);
- String name = f.getName().toString();
- String signature = f.getType().getTypeSignature();
- data.writeShort(cpool.indexString(name, env));
- data.writeShort(cpool.indexString(signature, env));
- BinaryAttribute.write(((BinaryMember)f).atts, data, cpool, env);
- }
- }
-
- // write out the class attributes
- BinaryAttribute.write(atts, data, cpool, env);
- data.flush();
- }
-
- /**
- * Get the dependencies
- */
- public Enumeration getDependencies() {
- return dependencies.elements();
- }
-
- /**
- * Add a dependency
- */
- public void addDependency(ClassDeclaration c) {
- if ((c != null) && !dependencies.contains(c)) {
- dependencies.addElement(c);
- }
- }
-
- /**
- * Get the constant pool
- */
- public BinaryConstantPool getConstants() {
- return cpool;
- }
-
- /**
- * Get a class attribute
- */
- public byte[] getAttribute(Identifier name) {
- for (BinaryAttribute att = atts ; att != null ; att = att.next) {
- if (att.name.equals(name)) {
- return att.data;
- }
- }
- return null;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryCode.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryCode.java
deleted file mode 100644
index db027a723b7..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryCode.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 1995, 2019, 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 sun.tools.java;
-
-import java.io.*;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public class BinaryCode implements Constants {
- int maxStack; // maximum stack used by code
- int maxLocals; // maximum locals used by code
- BinaryExceptionHandler exceptionHandlers[];
- BinaryAttribute atts; // code attributes
- BinaryConstantPool cpool; // constant pool of the class
- byte code[]; // the byte code
-
- /**
- * Construct the binary code from the code attribute
- */
-
- public
- BinaryCode(byte data[], BinaryConstantPool cpool, Environment env) {
- DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
- try {
- this.cpool = cpool;
- // JVM 4.7.4 CodeAttribute.max_stack
- this.maxStack = in.readUnsignedShort();
- // JVM 4.7.4 CodeAttribute.max_locals
- this.maxLocals = in.readUnsignedShort();
- // JVM 4.7.4 CodeAttribute.code_length
- int code_length = in.readInt();
- this.code = new byte[code_length];
- // JVM 4.7.4 CodeAttribute.code[]
- in.read(this.code);
- // JVM 4.7.4 CodeAttribute.exception_table_length
- int exception_count = in.readUnsignedShort();
- this.exceptionHandlers = new BinaryExceptionHandler[exception_count];
- for (int i = 0; i < exception_count; i++) {
- // JVM 4.7.4 CodeAttribute.exception_table.start_pc
- int start = in.readUnsignedShort();
- // JVM 4.7.4 CodeAttribute.exception_table.end_pc
- int end = in.readUnsignedShort();
- // JVM 4.7.4 CodeAttribute.exception_table.handler_pc
- int handler = in.readUnsignedShort();
- // JVM 4.7.4 CodeAttribute.exception_table.catch_type
- ClassDeclaration xclass = cpool.getDeclaration(env, in.readUnsignedShort());
- this.exceptionHandlers[i] =
- new BinaryExceptionHandler(start, end, handler, xclass);
- }
- this.atts = BinaryAttribute.load(in, cpool, ~0);
- if (in.available() != 0) {
- System.err.println("Should have exhausted input stream!");
- }
- } catch (IOException e) {
- throw new CompilerError(e);
- }
- }
-
-
- /**
- * Accessors
- */
-
- public BinaryExceptionHandler[] getExceptionHandlers() {
- return exceptionHandlers;
- }
-
- public byte[] getCode() { return code; }
-
- public int getMaxStack() { return maxStack; }
-
- public int getMaxLocals() { return maxLocals; }
-
- public BinaryAttribute getAttributes() { return atts; }
-
- /**
- * Load a binary class
- */
- public static
- BinaryCode load(BinaryMember bf, BinaryConstantPool cpool, Environment env) {
- byte code[] = bf.getAttribute(idCode);
- return (code != null) ? new BinaryCode(code, cpool, env) : null;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryConstantPool.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryConstantPool.java
deleted file mode 100644
index 9507a19362a..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryConstantPool.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.java;
-
-import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.util.Vector;
-import java.util.Hashtable;
-
-/**
- * This class is used to represent a constant table once
- * it is read from a class file.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class BinaryConstantPool implements Constants {
- private byte types[];
- private Object cpool[];
-
- /**
- * Constructor
- */
- BinaryConstantPool(DataInputStream in) throws IOException {
- // JVM 4.1 ClassFile.constant_pool_count
- types = new byte[in.readUnsignedShort()];
- cpool = new Object[types.length];
- for (int i = 1 ; i < cpool.length ; i++) {
- int j = i;
- // JVM 4.4 cp_info.tag
- switch(types[i] = in.readByte()) {
- case CONSTANT_UTF8:
- cpool[i] = in.readUTF();
- break;
-
- case CONSTANT_INTEGER:
- cpool[i] = in.readInt();
- break;
- case CONSTANT_FLOAT:
- cpool[i] = new Float(in.readFloat());
- break;
- case CONSTANT_LONG:
- cpool[i++] = in.readLong();
- break;
- case CONSTANT_DOUBLE:
- cpool[i++] = new Double(in.readDouble());
- break;
-
- case CONSTANT_CLASS:
- case CONSTANT_STRING:
- // JVM 4.4.3 CONSTANT_String_info.string_index
- // or JVM 4.4.1 CONSTANT_Class_info.name_index
- cpool[i] =in.readUnsignedShort();
- break;
-
- case CONSTANT_FIELD:
- case CONSTANT_METHOD:
- case CONSTANT_INTERFACEMETHOD:
- case CONSTANT_NAMEANDTYPE:
- // JVM 4.4.2 CONSTANT_*ref_info.class_index & name_and_type_index
- cpool[i] = (in.readUnsignedShort() << 16) | in.readUnsignedShort();
- break;
-
- case CONSTANT_METHODHANDLE:
- cpool[i] = readBytes(in, 3);
- break;
- case CONSTANT_METHODTYPE:
- cpool[i] = readBytes(in, 2);
- break;
- case CONSTANT_INVOKEDYNAMIC:
- cpool[i] = readBytes(in, 4);
- break;
-
- case 0:
- default:
- throw new ClassFormatError("invalid constant type: " + (int)types[i]);
- }
- }
- }
-
- private byte[] readBytes(DataInputStream in, int cnt) throws IOException {
- byte[] b = new byte[cnt];
- in.readFully(b);
- return b;
- }
-
- /**
- * get a integer
- */
- public int getInteger(int n) {
- return (n == 0) ? 0 : ((Number)cpool[n]).intValue();
- }
-
- /**
- * get a value
- */
- public Object getValue(int n) {
- return (n == 0) ? null : cpool[n];
- }
-
- /**
- * get a string
- */
- public String getString(int n) {
- return (n == 0) ? null : (String)cpool[n];
- }
-
- /**
- * get an identifier
- */
- public Identifier getIdentifier(int n) {
- return (n == 0) ? null : Identifier.lookup(getString(n));
- }
-
- /**
- * get class declaration
- */
- public ClassDeclaration getDeclarationFromName(Environment env, int n) {
- return (n == 0) ? null : env.getClassDeclaration(Identifier.lookup(getString(n).replace('/','.')));
- }
-
- /**
- * get class declaration
- */
- public ClassDeclaration getDeclaration(Environment env, int n) {
- return (n == 0) ? null : getDeclarationFromName(env, getInteger(n));
- }
-
- /**
- * get a type from a type signature
- */
- public Type getType(int n) {
- return Type.tType(getString(n));
- }
-
- /**
- * get the type of constant given an index
- */
- public int getConstantType(int n) {
- return types[n];
- }
-
- /**
- * get the n-th constant from the constant pool
- */
- public Object getConstant(int n, Environment env) {
- int constant_type = getConstantType(n);
- switch (constant_type) {
- case CONSTANT_INTEGER:
- case CONSTANT_FLOAT:
- case CONSTANT_LONG:
- case CONSTANT_DOUBLE:
- case CONSTANT_METHODHANDLE:
- case CONSTANT_METHODTYPE:
- case CONSTANT_INVOKEDYNAMIC:
- return getValue(n);
-
- case CONSTANT_CLASS:
- return getDeclaration(env, n);
-
- case CONSTANT_STRING:
- return getString(getInteger(n));
-
- case CONSTANT_FIELD:
- case CONSTANT_METHOD:
- case CONSTANT_INTERFACEMETHOD:
- try {
- int key = getInteger(n);
- ClassDefinition clazz =
- getDeclaration(env, key >> 16).getClassDefinition(env);
- int name_and_type = getInteger(key & 0xFFFF);
- Identifier id = getIdentifier(name_and_type >> 16);
- Type type = getType(name_and_type & 0xFFFF);
-
- for (MemberDefinition field = clazz.getFirstMatch(id);
- field != null;
- field = field.getNextMatch()) {
- Type field_type = field.getType();
- if ((constant_type == CONSTANT_FIELD)
- ? (field_type == type)
- : (field_type.equalArguments(type)))
- return field;
- }
- } catch (ClassNotFound e) {
- }
- return null;
-
- default:
- throw new ClassFormatError("invalid constant type: " +
- constant_type);
- }
- }
-
-
- /**
- * Get a list of dependencies, ie: all the classes referenced in this
- * constant pool.
- */
- public Vector getDependencies(Environment env) {
- Vector v = new Vector<>();
- for (int i = 1 ; i < cpool.length ; i++) {
- switch(types[i]) {
- case CONSTANT_CLASS:
- v.addElement(getDeclarationFromName(env, getInteger(i)));
- break;
- }
- }
- return v;
- }
-
- Hashtable indexHashObject;
- Hashtable indexHashAscii;
- Vector MoreStuff;
-
- /**
- * Find the index of an Object in the constant pool
- */
- public int indexObject(Object obj, Environment env) {
- if (indexHashObject == null)
- createIndexHash(env);
- Integer result = indexHashObject.get(obj);
- if (result == null)
- throw new IndexOutOfBoundsException("Cannot find object " + obj + " of type " +
- obj.getClass() + " in constant pool");
- return result.intValue();
- }
-
- /**
- * Find the index of an ascii string in the constant pool. If it's not in
- * the constant pool, then add it at the end.
- */
- public int indexString(String string, Environment env) {
- if (indexHashObject == null)
- createIndexHash(env);
- Integer result = indexHashAscii.get(string);
- if (result == null) {
- if (MoreStuff == null) MoreStuff = new Vector<>();
- result = cpool.length + MoreStuff.size();
- MoreStuff.addElement(string);
- indexHashAscii.put(string, result);
- }
- return result.intValue();
- }
-
- /**
- * Create a hash table of all the items in the constant pool that could
- * possibly be referenced from the outside.
- */
-
- public void createIndexHash(Environment env) {
- indexHashObject = new Hashtable<>();
- indexHashAscii = new Hashtable<>();
- for (int i = 1; i < cpool.length; i++) {
- if (types[i] == CONSTANT_UTF8) {
- indexHashAscii.put(cpool[i], i);
- } else {
- try {
- indexHashObject.put(getConstant(i, env), i);
- } catch (ClassFormatError e) { }
- }
- }
- }
-
-
- /**
- * Write out the contents of the constant pool, including any additions
- * that have been added.
- */
- public void write(DataOutputStream out, Environment env) throws IOException {
- int length = cpool.length;
- if (MoreStuff != null)
- length += MoreStuff.size();
- out.writeShort(length);
- for (int i = 1 ; i < cpool.length; i++) {
- int type = types[i];
- Object x = cpool[i];
- out.writeByte(type);
- switch (type) {
- case CONSTANT_UTF8:
- out.writeUTF((String) x);
- break;
- case CONSTANT_INTEGER:
- out.writeInt(((Number)x).intValue());
- break;
- case CONSTANT_FLOAT:
- out.writeFloat(((Number)x).floatValue());
- break;
- case CONSTANT_LONG:
- out.writeLong(((Number)x).longValue());
- i++;
- break;
- case CONSTANT_DOUBLE:
- out.writeDouble(((Number)x).doubleValue());
- i++;
- break;
- case CONSTANT_CLASS:
- case CONSTANT_STRING:
- out.writeShort(((Number)x).intValue());
- break;
- case CONSTANT_FIELD:
- case CONSTANT_METHOD:
- case CONSTANT_INTERFACEMETHOD:
- case CONSTANT_NAMEANDTYPE: {
- int value = ((Number)x).intValue();
- out.writeShort(value >> 16);
- out.writeShort(value & 0xFFFF);
- break;
- }
- case CONSTANT_METHODHANDLE:
- case CONSTANT_METHODTYPE:
- case CONSTANT_INVOKEDYNAMIC:
- out.write((byte[])x, 0, ((byte[])x).length);
- break;
- default:
- throw new ClassFormatError("invalid constant type: "
- + (int)types[i]);
- }
- }
- for (int i = cpool.length; i < length; i++) {
- String string = MoreStuff.elementAt(i - cpool.length);
- out.writeByte(CONSTANT_UTF8);
- out.writeUTF(string);
- }
- }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryExceptionHandler.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryExceptionHandler.java
deleted file mode 100644
index 27b829097d3..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryExceptionHandler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.tools.java;
-
-/**
- * A single exception handler. This class hangs off BinaryCode.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-public class BinaryExceptionHandler {
- public int startPC;
- public int endPC;
- public int handlerPC;
- public ClassDeclaration exceptionClass;
-
- BinaryExceptionHandler(int start, int end,
- int handler, ClassDeclaration xclass) {
- startPC = start;
- endPC = end;
- handlerPC = handler;
- exceptionClass = xclass;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/BinaryMember.java b/src/jdk.rmic/share/classes/sun/tools/java/BinaryMember.java
deleted file mode 100644
index 0b0b75a6772..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryMember.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-import sun.tools.tree.*;
-import java.util.Vector;
-import java.util.Hashtable;
-import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.ByteArrayInputStream;
-
-/**
- * This class represents a binary member
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public final
-class BinaryMember extends MemberDefinition {
- Expression value;
- BinaryAttribute atts;
-
- /**
- * Constructor
- */
- public BinaryMember(ClassDefinition clazz, int modifiers, Type type,
- Identifier name, BinaryAttribute atts) {
- super(0, clazz, modifiers, type, name, null, null);
- this.atts = atts;
-
- // Was it compiled as deprecated?
- if (getAttribute(idDeprecated) != null) {
- this.modifiers |= M_DEPRECATED;
- }
-
- // Was it synthesized by the compiler?
- if (getAttribute(idSynthetic) != null) {
- this.modifiers |= M_SYNTHETIC;
- }
- }
-
- /**
- * Constructor for an inner class.
- */
- public BinaryMember(ClassDefinition innerClass) {
- super(innerClass);
- }
-
- /**
- * Inline allowed (currently only allowed for the constructor of Object).
- */
- public boolean isInlineable(Environment env, boolean fromFinal) {
- // It is possible for 'getSuperClass()' to return null due to error
- // recovery from cyclic inheritace. Can this cause a problem here?
- return isConstructor() && (getClassDefinition().getSuperClass() == null);
- }
-
- /**
- * Get arguments
- */
- public Vector getArguments() {
- if (isConstructor() && (getClassDefinition().getSuperClass() == null)) {
- Vector v = new Vector<>();
- v.addElement(new LocalMember(0, getClassDefinition(), 0,
- getClassDefinition().getType(), idThis));
- return v;
- }
- return null;
- }
-
- /**
- * Get exceptions
- */
- public ClassDeclaration[] getExceptions(Environment env) {
- if ((!isMethod()) || (exp != null)) {
- return exp;
- }
- byte data[] = getAttribute(idExceptions);
- if (data == null) {
- return new ClassDeclaration[0];
- }
-
- try {
- BinaryConstantPool cpool = ((BinaryClass)getClassDefinition()).getConstants();
- DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
- // JVM 4.7.5 Exceptions_attribute.number_of_exceptions
- int n = in.readUnsignedShort();
- exp = new ClassDeclaration[n];
- for (int i = 0 ; i < n ; i++) {
- // JVM 4.7.5 Exceptions_attribute.exception_index_table[]
- exp[i] = cpool.getDeclaration(env, in.readUnsignedShort());
- }
- return exp;
- } catch (IOException e) {
- throw new CompilerError(e);
- }
- }
-
- /**
- * Get documentation
- */
- public String getDocumentation() {
- if (documentation != null) {
- return documentation;
- }
- byte data[] = getAttribute(idDocumentation);
- if (data == null) {
- return null;
- }
- try {
- return documentation = new DataInputStream(new ByteArrayInputStream(data)).readUTF();
- } catch (IOException e) {
- throw new CompilerError(e);
- }
- }
-
- /**
- * Check if constant: Will it inline away to a constant?
- * This override is needed to solve bug 4128266. It is also
- * integral to the solution of 4119776.
- */
- private boolean isConstantCache = false;
- private boolean isConstantCached = false;
- public boolean isConstant() {
- if (!isConstantCached) {
- isConstantCache = isFinal()
- && isVariable()
- && getAttribute(idConstantValue) != null;
- isConstantCached = true;
- }
- return isConstantCache;
- }
-
- /**
- * Get the value
- */
- public Node getValue(Environment env) {
- if (isMethod()) {
- return null;
- }
- if (!isFinal()) {
- return null;
- }
- if (getValue() != null) {
- return (Expression)getValue();
- }
- byte data[] = getAttribute(idConstantValue);
- if (data == null) {
- return null;
- }
-
- try {
- BinaryConstantPool cpool = ((BinaryClass)getClassDefinition()).getConstants();
- // JVM 4.7.3 ConstantValue.constantvalue_index
- Object obj = cpool.getValue(new DataInputStream(new ByteArrayInputStream(data)).readUnsignedShort());
- switch (getType().getTypeCode()) {
- case TC_BOOLEAN:
- setValue(new BooleanExpression(0, ((Number)obj).intValue() != 0));
- break;
- case TC_BYTE:
- case TC_SHORT:
- case TC_CHAR:
- case TC_INT:
- setValue(new IntExpression(0, ((Number)obj).intValue()));
- break;
- case TC_LONG:
- setValue(new LongExpression(0, ((Number)obj).longValue()));
- break;
- case TC_FLOAT:
- setValue(new FloatExpression(0, ((Number)obj).floatValue()));
- break;
- case TC_DOUBLE:
- setValue(new DoubleExpression(0, ((Number)obj).doubleValue()));
- break;
- case TC_CLASS:
- setValue(new StringExpression(0, (String)cpool.getValue(((Number)obj).intValue())));
- break;
- }
- return (Expression)getValue();
- } catch (IOException e) {
- throw new CompilerError(e);
- }
- }
-
- /**
- * Get a field attribute
- */
- public byte[] getAttribute(Identifier name) {
- for (BinaryAttribute att = atts ; att != null ; att = att.next) {
- if (att.name.equals(name)) {
- return att.data;
- }
- }
- return null;
- }
-
- public boolean deleteAttribute(Identifier name) {
- BinaryAttribute walker = null, next = null;
-
- boolean succeed = false;
-
- while (atts.name.equals(name)) {
- atts = atts.next;
- succeed = true;
- }
- for (walker = atts; walker != null; walker = next) {
- next = walker.next;
- if (next != null) {
- if (next.name.equals(name)) {
- walker.next = next.next;
- next = next.next;
- succeed = true;
- }
- }
- }
- for (walker = atts; walker != null; walker = walker.next) {
- if (walker.name.equals(name)) {
- throw new InternalError("Found attribute " + name);
- }
- }
-
- return succeed;
- }
-
-
-
- /*
- * Add an attribute to a field
- */
- public void addAttribute(Identifier name, byte data[], Environment env) {
- this.atts = new BinaryAttribute(name, data, this.atts);
- // Make sure that the new attribute is in the constant pool
- ((BinaryClass)(this.clazz)).cpool.indexString(name.toString(), env);
- }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassDeclaration.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassDeclaration.java
deleted file mode 100644
index b55c191f751..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassDeclaration.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 1994, 2013, 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 sun.tools.java;
-
-/**
- * This class represents an Java class declaration. It refers
- * to either a binary or source definition.
- *
- * ClassDefinitions are loaded on demand, this means that
- * class declarations are late bound. The definition of the
- * class is obtained in stages. The status field describes
- * the state of the class definition:
- *
- * CS_UNDEFINED - the definition is not yet loaded
- * CS_UNDECIDED - a binary definition is loaded, but it is
- * still unclear if the source definition need to
- * be loaded
- * CS_BINARY - the binary class is loaded
- * CS_PARSED - the class is loaded from the source file, the
- * type information is available, but the class has
- * not yet been compiled.
- * CS_CHECKED - the class is loaded from the source file and has
- * been type-checked.
- * CS_COMPILED - the class has been type checked, compiled,
- * and written out.
- * CS_NOTFOUND - no class definition could be found
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-public final
-class ClassDeclaration implements Constants {
- int status;
- Type type;
- ClassDefinition definition;
-
- /**
- * Constructor
- */
- public ClassDeclaration(Identifier name) {
- this.type = Type.tClass(name);
- }
-
- /**
- * Get the status of the class
- */
- public int getStatus() {
- return status;
- }
-
- /**
- * Get the name of the class
- */
- public Identifier getName() {
- return type.getClassName();
- }
-
- /**
- * Get the type of the class
- */
- public Type getType() {
- return type;
- }
-
- /**
- * Check if the class is defined
- */
- public boolean isDefined() {
- switch (status) {
- case CS_BINARY:
- case CS_PARSED:
- case CS_CHECKED:
- case CS_COMPILED:
- return true;
- }
- return false;
- }
-
- /**
- * Get the definition of this class. Returns null if
- * the class is not yet defined.
- */
- public ClassDefinition getClassDefinition() {
- return definition;
- }
-
- /**
- * This is a flag for use by getClassDefinition(env). It is
- * used to mark that a class has been successfully looked up
- * by that method before.
- */
- private boolean found = false;
-
- /**
- * Get the definition of this class, if the class is not
- * yet defined, load the definition. Loading a class may
- * throw various exceptions.
- */
- public ClassDefinition getClassDefinition(Environment env)
- throws ClassNotFound {
- if (tracing) env.dtEvent("getClassDefinition: " +
- getName() + ", status " + getStatus());
-
- // The majority of calls to getClassDefinition() are duplicates.
- // This check makes them fast. It also allows us to avoid
- // duplicate, useless calls to basicCheck(). In the future it
- // would be good to add an additional status value, CS_BASICCHECKED.
- if (found) {
- return definition;
- }
-
- for(;;) {
- switch (status) {
- case CS_UNDEFINED:
- case CS_UNDECIDED:
- case CS_SOURCE:
- env.loadDefinition(this);
- break;
-
- case CS_BINARY:
- case CS_PARSED:
- //+FIX FOR BUGID 4056065
- //definition.basicCheck(env);
- if (!definition.isInsideLocal()) {
- // Classes inside a block, including anonymous classes,
- // are checked when their surrounding member is checked.
- definition.basicCheck(env);
- }
- //-FIX FOR BUGID 4056065
- found = true;
- return definition;
-
- case CS_CHECKED:
- case CS_COMPILED:
- found = true;
- return definition;
-
- default:
- throw new ClassNotFound(getName());
- }
- }
- }
-
- /**
- * Get the definition of this class, if the class is not
- * yet defined, load the definition. Loading a class may
- * throw various exceptions. Perform no basicCheck() on this
- * class.
- */
- public ClassDefinition getClassDefinitionNoCheck(Environment env) throws ClassNotFound {
- if (tracing) env.dtEvent("getClassDefinition: " +
- getName() + ", status " + getStatus());
- for(;;) {
- switch (status) {
- case CS_UNDEFINED:
- case CS_UNDECIDED:
- case CS_SOURCE:
- env.loadDefinition(this);
- break;
-
- case CS_BINARY:
- case CS_PARSED:
- case CS_CHECKED:
- case CS_COMPILED:
- return definition;
-
- default:
- throw new ClassNotFound(getName());
- }
- }
- }
-
- /**
- * Set the class definition
- */
- public void setDefinition(ClassDefinition definition, int status) {
-
- // Sanity checks.
-
- // The name of the definition should match that of the declaration.
- if ((definition != null) && !getName().equals(definition.getName())) {
- throw new CompilerError("setDefinition: name mismatch: " +
- this + ", " + definition);
- }
-
- // The status states can be considered ordered in the same
- // manner as their numerical values. We expect classes to
- // progress through a sequence of monotonically increasing
- // states. NOTE: There are currently exceptions to this rule
- // which are believed to be legitimate. In particular, a
- // class may be checked more than once, though we believe that
- // this is unnecessary and may be avoided.
- /*-----------------*
- if (status <= this.status) {
- System.out.println("STATUS REGRESSION: " +
- this + " FROM " + this.status + " TO " + status);
- }
- *------------------*/
-
- this.definition = definition;
- this.status = status;
- }
-
- /**
- * Equality
- */
- public boolean equals(Object obj) {
- if (obj instanceof ClassDeclaration) {
- return type.equals(((ClassDeclaration)obj).type);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return type.hashCode();
- }
-
- /**
- * toString
- */
- public String toString() {
- String name = getName().toString();
- String type = "type ";
- String nested = getName().isInner() ? "nested " : "";
- if (getClassDefinition() != null) {
- if (getClassDefinition().isInterface()) {
- type = "interface ";
- } else {
- type = "class ";
- }
- if (!getClassDefinition().isTopLevel()) {
- nested = "inner ";
- if (getClassDefinition().isLocal()) {
- nested = "local ";
- if (!getClassDefinition().isAnonymous()) {
- name = getClassDefinition().getLocalName() +
- " (" + name + ")";
- }
- }
- }
- }
- return nested + type + name;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java
deleted file mode 100644
index 93837347d0c..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java
+++ /dev/null
@@ -1,2085 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-import java.util.*;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import sun.tools.tree.Context;
-import sun.tools.tree.Vset;
-import sun.tools.tree.Expression;
-import sun.tools.tree.LocalMember;
-import sun.tools.tree.UplevelReference;
-
-/**
- * This class is a Java class definition
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("deprecation")
-public
-class ClassDefinition implements Constants {
-
- protected Object source;
- protected long where;
- protected int modifiers;
- protected Identifier localName; // for local classes
- protected ClassDeclaration declaration;
- protected IdentifierToken superClassId;
- protected IdentifierToken interfaceIds[];
- protected ClassDeclaration superClass;
- protected ClassDeclaration interfaces[];
- protected ClassDefinition outerClass;
- protected MemberDefinition outerMember;
- protected MemberDefinition innerClassMember; // field for me in outerClass
- protected MemberDefinition firstMember;
- protected MemberDefinition lastMember;
- protected boolean resolved;
- protected String documentation;
- protected boolean error;
- protected boolean nestError;
- protected UplevelReference references;
- protected boolean referencesFrozen;
- private Hashtable fieldHash = new Hashtable<>(31);
- private int abstr;
-
- // Table of local and anonymous classes whose internal names are constructed
- // using the current class as a prefix. This is part of a fix for
- // bugid 4054523 and 4030421. See also 'Environment.getClassDefinition'
- // and 'BatchEnvironment.makeClassDefinition'. Allocated on demand.
- private Hashtable localClasses = null;
- private final int LOCAL_CLASSES_SIZE = 31;
-
- // The immediately surrounding context in which the class appears.
- // Set at the beginning of checking, upon entry to 'SourceClass.checkInternal'.
- // Null for classes that are not local or inside a local class.
- // At present, this field exists only for the benefit of 'resolveName' as part
- // of the fix for 4095716.
- protected Context classContext;
-
- // The saved class context is now also used in 'SourceClass.getAccessMember'.
- // Provide read-only access via this method. Part of fix for 4098093.
- public Context getClassContext() {
- return classContext;
- }
-
-
- /**
- * Constructor
- */
- protected ClassDefinition(Object source, long where, ClassDeclaration declaration,
- int modifiers, IdentifierToken superClass, IdentifierToken interfaces[]) {
- this.source = source;
- this.where = where;
- this.declaration = declaration;
- this.modifiers = modifiers;
- this.superClassId = superClass;
- this.interfaceIds = interfaces;
- }
-
- /**
- * Get the source of the class
- */
- public final Object getSource() {
- return source;
- }
-
- /**
- * Check if there were any errors in this class.
- */
- public final boolean getError() {
- return error;
- }
-
- /**
- * Mark this class to be erroneous.
- */
- public final void setError() {
- this.error = true;
- setNestError();
- }
-
- /**
- * Check if there were any errors in our class nest.
- */
- public final boolean getNestError() {
- // Check to see if our error value is set, or if any of our
- // outer classes' error values are set. This will work in
- // conjunction with setError(), which sets the error value
- // of its outer class, to yield true is any of our nest
- // siblings has an error. This addresses bug 4111488: either
- // code should be generated for all classes in a nest, or
- // none of them.
- return nestError || ((outerClass != null) ? outerClass.getNestError() : false);
- }
-
- /**
- * Mark this class, and all siblings in its class nest, to be
- * erroneous.
- */
- public final void setNestError() {
- this.nestError = true;
- if (outerClass != null) {
- // If we have an outer class, set it to be erroneous as well.
- // This will work in conjunction with getError(), which checks
- // the error value of its outer class, to set the whole class
- // nest to be erroneous. This address bug 4111488: either
- // code should be generated for all classes in a nest, or
- // none of them.
- outerClass.setNestError();
- }
- }
-
- /**
- * Get the position in the input
- */
- public final long getWhere() {
- return where;
- }
-
- /**
- * Get the class declaration
- */
- public final ClassDeclaration getClassDeclaration() {
- return declaration;
- }
-
- /**
- * Get the class' modifiers
- */
- public final int getModifiers() {
- return modifiers;
- }
- public final void subModifiers(int mod) {
- modifiers &= ~mod;
- }
- public final void addModifiers(int mod) {
- modifiers |= mod;
- }
-
- // *** DEBUG ***
- protected boolean supersCheckStarted = !(this instanceof sun.tools.javac.SourceClass);
-
- /**
- * Get the class' super class
- */
- public final ClassDeclaration getSuperClass() {
- /*---
- if (superClass == null && superClassId != null)
- throw new CompilerError("getSuperClass "+superClassId);
- // There are obscure cases where null is the right answer,
- // in order to enable some error reporting later on.
- // For example: class T extends T.N { class N { } }
- ---*/
-
- // *** DEBUG ***
- // This method should not be called if the superclass has not been resolved.
- if (!supersCheckStarted) throw new CompilerError("unresolved super");
-
- return superClass;
- }
-
- /**
- * Get the super class, and resolve names now if necessary.
- *
- * It is only possible to resolve names at this point if we are
- * a source class. The provision of this method at this level
- * in the class hierarchy is dubious, but see 'getInnerClass' below.
- * All other calls to 'getSuperClass(env)' appear in 'SourceClass'.
- * NOTE: An older definition of this method has been moved to
- * 'SourceClass', where it overrides this one.
- *
- * @see #resolveTypeStructure
- */
-
- public ClassDeclaration getSuperClass(Environment env) {
- return getSuperClass();
- }
-
- /**
- * Get the class' interfaces
- */
- public final ClassDeclaration[] getInterfaces() {
- if (interfaces == null) throw new CompilerError("getInterfaces");
- return interfaces;
- }
-
- /**
- * Get the class' enclosing class (or null if not inner)
- */
- public final ClassDefinition getOuterClass() {
- return outerClass;
- }
-
- /**
- * Set the class' enclosing class. Must be done at most once.
- */
- protected final void setOuterClass(ClassDefinition outerClass) {
- if (this.outerClass != null) throw new CompilerError("setOuterClass");
- this.outerClass = outerClass;
- }
-
- /**
- * Set the class' enclosing current instance pointer.
- * Must be done at most once.
- */
- protected final void setOuterMember(MemberDefinition outerMember) {
-
- if (isStatic() || !isInnerClass()) throw new CompilerError("setOuterField");
- if (this.outerMember != null) throw new CompilerError("setOuterField");
- this.outerMember = outerMember;
- }
-
- /**
- * Tell if the class is inner.
- * This predicate also returns true for top-level nested types.
- * To test for a true inner class as seen by the programmer,
- * use {@code !isTopLevel()}.
- */
- public final boolean isInnerClass() {
- return outerClass != null;
- }
-
- /**
- * Tell if the class is a member of another class.
- * This is false for package members and for block-local classes.
- */
- public final boolean isMember() {
- return outerClass != null && !isLocal();
- }
-
- /**
- * Tell if the class is "top-level", which is either a package member,
- * or a static member of another top-level class.
- */
- public final boolean isTopLevel() {
- return outerClass == null || isStatic() || isInterface();
- }
-
- /**
- * Tell if the class is local or inside a local class,
- * which means it cannot be mentioned outside of its file.
- */
-
- // The comment above is true only because M_LOCAL is set
- // whenever M_ANONYMOUS is. I think it is risky to assume that
- // isAnonymous(x) => isLocal(x).
-
- public final boolean isInsideLocal() {
- return isLocal() ||
- (outerClass != null && outerClass.isInsideLocal());
- }
-
- /**
- * Tell if the class is local or anonymous class, or inside
- * such a class, which means it cannot be mentioned outside of
- * its file.
- */
- public final boolean isInsideLocalOrAnonymous() {
- return isLocal() || isAnonymous () ||
- (outerClass != null && outerClass.isInsideLocalOrAnonymous());
- }
-
- /**
- * Return a simple identifier for this class (idNull if anonymous).
- */
- public Identifier getLocalName() {
- if (localName != null) {
- return localName;
- }
- // This is also the name of the innerClassMember, if any:
- return getName().getFlatName().getName();
- }
-
- /**
- * Set the local name of a class. Must be a local class.
- */
- public void setLocalName(Identifier name) {
- if (isLocal()) {
- localName = name;
- }
- }
-
- /**
- * If inner, get the field for this class in the enclosing class
- */
- public final MemberDefinition getInnerClassMember() {
- if (outerClass == null)
- return null;
- if (innerClassMember == null) {
- // We must find the field in the outer class.
- Identifier nm = getName().getFlatName().getName();
- for (MemberDefinition field = outerClass.getFirstMatch(nm);
- field != null; field = field.getNextMatch()) {
- if (field.isInnerClass()) {
- innerClassMember = field;
- break;
- }
- }
- if (innerClassMember == null)
- throw new CompilerError("getInnerClassField");
- }
- return innerClassMember;
- }
-
- /**
- * If inner, return an innermost uplevel self pointer, if any exists.
- * Otherwise, return null.
- */
- public final MemberDefinition findOuterMember() {
- return outerMember;
- }
-
- /**
- * See if this is a (nested) static class.
- */
- public final boolean isStatic() {
- return (modifiers & ACC_STATIC) != 0;
- }
-
- /**
- * Get the class' top-level enclosing class
- */
- public final ClassDefinition getTopClass() {
- ClassDefinition p, q;
- for (p = this; (q = p.outerClass) != null; p = q)
- ;
- return p;
- }
-
- /**
- * Get the class' first field or first match
- */
- public final MemberDefinition getFirstMember() {
- return firstMember;
- }
- public final MemberDefinition getFirstMatch(Identifier name) {
- return fieldHash.get(name);
- }
-
- /**
- * Get the class' name
- */
- public final Identifier getName() {
- return declaration.getName();
- }
-
- /**
- * Get the class' type
- */
- public final Type getType() {
- return declaration.getType();
- }
-
- /**
- * Get the class' documentation
- */
- public String getDocumentation() {
- return documentation;
- }
-
- /**
- * Return true if the given documentation string contains a deprecation
- * paragraph. This is true if the string contains the tag @deprecated
- * is the first word in a line.
- */
- public static boolean containsDeprecated(String documentation) {
- if (documentation == null) {
- return false;
- }
- doScan:
- for (int scan = 0;
- (scan = documentation.indexOf(paraDeprecated, scan)) >= 0;
- scan += paraDeprecated.length()) {
- // make sure there is only whitespace between this word
- // and the beginning of the line
- for (int beg = scan-1; beg >= 0; beg--) {
- char ch = documentation.charAt(beg);
- if (ch == '\n' || ch == '\r') {
- break; // OK
- }
- if (!Character.isSpace(ch)) {
- continue doScan;
- }
- }
- // make sure the char after the word is space or end of line
- int end = scan+paraDeprecated.length();
- if (end < documentation.length()) {
- char ch = documentation.charAt(end);
- if (!(ch == '\n' || ch == '\r') && !Character.isSpace(ch)) {
- continue doScan;
- }
- }
- return true;
- }
- return false;
- }
-
- public final boolean inSamePackage(ClassDeclaration c) {
- // find out if the class stored in c is defined in the same
- // package as the current class.
- return inSamePackage(c.getName().getQualifier());
- }
-
- public final boolean inSamePackage(ClassDefinition c) {
- // find out if the class stored in c is defined in the same
- // package as the current class.
- return inSamePackage(c.getName().getQualifier());
- }
-
- public final boolean inSamePackage(Identifier packageName) {
- return (getName().getQualifier().equals(packageName));
- }
-
- /**
- * Checks
- */
- public final boolean isInterface() {
- return (getModifiers() & M_INTERFACE) != 0;
- }
- public final boolean isClass() {
- return (getModifiers() & M_INTERFACE) == 0;
- }
- public final boolean isPublic() {
- return (getModifiers() & M_PUBLIC) != 0;
- }
- public final boolean isPrivate() {
- return (getModifiers() & M_PRIVATE) != 0;
- }
- public final boolean isProtected() {
- return (getModifiers() & M_PROTECTED) != 0;
- }
- public final boolean isPackagePrivate() {
- return (modifiers & (M_PUBLIC | M_PRIVATE | M_PROTECTED)) == 0;
- }
- public final boolean isFinal() {
- return (getModifiers() & M_FINAL) != 0;
- }
- public final boolean isAbstract() {
- return (getModifiers() & M_ABSTRACT) != 0;
- }
- public final boolean isSynthetic() {
- return (getModifiers() & M_SYNTHETIC) != 0;
- }
- public final boolean isDeprecated() {
- return (getModifiers() & M_DEPRECATED) != 0;
- }
- public final boolean isAnonymous() {
- return (getModifiers() & M_ANONYMOUS) != 0;
- }
- public final boolean isLocal() {
- return (getModifiers() & M_LOCAL) != 0;
- }
- public final boolean hasConstructor() {
- return getFirstMatch(idInit) != null;
- }
-
-
- /**
- * Check to see if a class must be abstract. This method replaces
- * isAbstract(env)
- */
- public final boolean mustBeAbstract(Environment env) {
- // If it is declared abstract, return true.
- // (Fix for 4110534.)
- if (isAbstract()) {
- return true;
- }
-
- // Check to see if the class should have been declared to be
- // abstract.
-
- // We make sure that the inherited method collection has been
- // performed.
- collectInheritedMethods(env);
-
- // We check for any abstract methods inherited or declared
- // by this class.
- Iterator methods = getMethods();
- while (methods.hasNext()) {
- MemberDefinition method = methods.next();
-
- if (method.isAbstract()) {
- return true;
- }
- }
-
- // We check for hidden "permanently abstract" methods in
- // our superclasses.
- return getPermanentlyAbstractMethods().hasNext();
- }
-
- /**
- * Check if this is a super class of another class
- */
- public boolean superClassOf(Environment env, ClassDeclaration otherClass)
- throws ClassNotFound {
- while (otherClass != null) {
- if (getClassDeclaration().equals(otherClass)) {
- return true;
- }
- otherClass = otherClass.getClassDefinition(env).getSuperClass();
- }
- return false;
- }
-
- /**
- * Check if this is an enclosing class of another class
- */
- public boolean enclosingClassOf(ClassDefinition otherClass) {
- while ((otherClass = otherClass.getOuterClass()) != null) {
- if (this == otherClass) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if this is a sub class of another class
- */
- public boolean subClassOf(Environment env, ClassDeclaration otherClass) throws ClassNotFound {
- ClassDeclaration c = getClassDeclaration();
- while (c != null) {
- if (c.equals(otherClass)) {
- return true;
- }
- c = c.getClassDefinition(env).getSuperClass();
- }
- return false;
- }
-
- /**
- * Check if this class is implemented by another class
- */
- public boolean implementedBy(Environment env, ClassDeclaration c) throws ClassNotFound {
- for (; c != null ; c = c.getClassDefinition(env).getSuperClass()) {
- if (getClassDeclaration().equals(c)) {
- return true;
- }
- ClassDeclaration intf[] = c.getClassDefinition(env).getInterfaces();
- for (int i = 0 ; i < intf.length ; i++) {
- if (implementedBy(env, intf[i])) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Check to see if a class which implements interface `this' could
- * possibly implement the interface `intDef'. Note that the only
- * way that this can fail is if `this' and `intDef' have methods
- * which are of the same signature and different return types. This
- * method is used by Environment.explicitCast() to determine if a
- * cast between two interfaces is legal.
- *
- * This method should only be called on a class after it has been
- * basicCheck()'ed.
- */
- public boolean couldImplement(ClassDefinition intDef) {
- // Check to see if we could have done the necessary checks.
- if (!doInheritanceChecks) {
- throw new CompilerError("couldImplement: no checks");
- }
-
- // This method should only be called for interfaces.
- if (!isInterface() || !intDef.isInterface()) {
- throw new CompilerError("couldImplement: not interface");
- }
-
- // Make sure we are not called before we have collected our
- // inheritance information.
- if (allMethods == null) {
- throw new CompilerError("couldImplement: called early");
- }
-
- // Get the other classes' methods. getMethods() in
- // general can return methods which are not visible to the
- // current package. We need to make sure that these do not
- // prevent this class from being implemented.
- Iterator otherMethods = intDef.getMethods();
-
- while (otherMethods.hasNext()) {
- // Get one of the methods from intDef...
- MemberDefinition method = otherMethods.next();
-
- Identifier name = method.getName();
- Type type = method.getType();
-
- // See if we implement a method of the same signature...
- MemberDefinition myMethod = allMethods.lookupSig(name, type);
-
- //System.out.println("Comparing\n\t" + myMethod +
- // "\nand\n\t" + method);
-
- if (myMethod != null) {
- // We do. Make sure the methods have the same return type.
- if (!myMethod.sameReturnType(method)) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
- * Check if another class can be accessed from the 'extends' or 'implements'
- * clause of this class.
- */
- public boolean extendsCanAccess(Environment env, ClassDeclaration c) throws ClassNotFound {
-
- // Names in the 'extends' or 'implements' clause of an inner class
- // are checked as if they appeared in the body of the surrounding class.
- if (outerClass != null) {
- return outerClass.canAccess(env, c);
- }
-
- // We are a package member.
-
- ClassDefinition cdef = c.getClassDefinition(env);
-
- if (cdef.isLocal()) {
- // No locals should be in scope in the 'extends' or
- // 'implements' clause of a package member.
- throw new CompilerError("top local");
- }
-
- if (cdef.isInnerClass()) {
- MemberDefinition f = cdef.getInnerClassMember();
-
- // Access to public member is always allowed.
- if (f.isPublic()) {
- return true;
- }
-
- // Private access is ok only from the same class nest. This can
- // happen only if the class represented by 'this' encloses the inner
- // class represented by 'f'.
- if (f.isPrivate()) {
- return getClassDeclaration().equals(f.getTopClass().getClassDeclaration());
- }
-
- // Protected or default access -- allow access if in same package.
- return getName().getQualifier().equals(f.getClassDeclaration().getName().getQualifier());
- }
-
- // Access to public member is always allowed.
- if (cdef.isPublic()) {
- return true;
- }
-
- // Default access -- allow access if in same package.
- return getName().getQualifier().equals(c.getName().getQualifier());
- }
-
- /**
- * Check if another class can be accessed from within the body of this class.
- */
- public boolean canAccess(Environment env, ClassDeclaration c) throws ClassNotFound {
- ClassDefinition cdef = c.getClassDefinition(env);
-
- if (cdef.isLocal()) {
- // if it's in scope, it's accessible
- return true;
- }
-
- if (cdef.isInnerClass()) {
- return canAccess(env, cdef.getInnerClassMember());
- }
-
- // Public access is always ok
- if (cdef.isPublic()) {
- return true;
- }
-
- // It must be in the same package
- return getName().getQualifier().equals(c.getName().getQualifier());
- }
-
- /**
- * Check if a field can be accessed from a class
- */
-
- public boolean canAccess(Environment env, MemberDefinition f)
- throws ClassNotFound {
-
- // Public access is always ok
- if (f.isPublic()) {
- return true;
- }
- // Protected access is ok from a subclass
- if (f.isProtected() && subClassOf(env, f.getClassDeclaration())) {
- return true;
- }
- // Private access is ok only from the same class nest
- if (f.isPrivate()) {
- return getTopClass().getClassDeclaration()
- .equals(f.getTopClass().getClassDeclaration());
- }
- // It must be in the same package
- return getName().getQualifier().equals(f.getClassDeclaration().getName().getQualifier());
- }
-
- /**
- * Check if a class is entitled to inline access to a class from
- * another class.
- */
- public boolean permitInlinedAccess(Environment env, ClassDeclaration c)
- throws ClassNotFound {
-
- return (env.opt() && c.equals(declaration)) ||
- (env.opt_interclass() && canAccess(env, c));
- }
-
- /**
- * Check if a class is entitled to inline access to a method from
- * another class.
- */
- public boolean permitInlinedAccess(Environment env, MemberDefinition f)
- throws ClassNotFound {
- return (env.opt()
- && (f.clazz.getClassDeclaration().equals(declaration))) ||
- (env.opt_interclass() && canAccess(env, f));
- }
-
- /**
- * We know the field is marked protected (and not public) and that
- * the field is visible (as per canAccess). Can we access the field as
- * ., where has the type ?
- *
- * Protected fields can only be accessed when the accessorType is a
- * subclass of the current class
- */
- public boolean protectedAccess(Environment env, MemberDefinition f,
- Type accessorType)
- throws ClassNotFound
- {
-
- return
- // static protected fields are accessible
- f.isStatic()
- || // allow array.clone()
- (accessorType.isType(TC_ARRAY) && (f.getName() == idClone)
- && (f.getType().getArgumentTypes().length == 0))
- || // is a subtype of the current class
- (accessorType.isType(TC_CLASS)
- && env.getClassDefinition(accessorType.getClassName())
- .subClassOf(env, getClassDeclaration()))
- || // we are accessing the field from a friendly class (same package)
- (getName().getQualifier()
- .equals(f.getClassDeclaration().getName().getQualifier()));
- }
-
-
- /**
- * Find or create an access method for a private member,
- * or return null if this is not possible.
- */
- public MemberDefinition getAccessMember(Environment env, Context ctx,
- MemberDefinition field, boolean isSuper) {
- throw new CompilerError("binary getAccessMember");
- }
-
- /**
- * Find or create an update method for a private member,
- * or return null if this is not possible.
- */
- public MemberDefinition getUpdateMember(Environment env, Context ctx,
- MemberDefinition field, boolean isSuper) {
- throw new CompilerError("binary getUpdateMember");
- }
-
- /**
- * Get a field from this class. Report ambiguous fields.
- * If no accessible field is found, this method may return an
- * inaccessible field to allow a useful error message.
- *
- * getVariable now takes the source class `source' as an argument.
- * This allows getVariable to check whether a field is inaccessible
- * before it signals that a field is ambiguous. The compiler used to
- * signal an ambiguity even when one of the fields involved was not
- * accessible. (bug 4053724)
- */
- public MemberDefinition getVariable(Environment env,
- Identifier nm,
- ClassDefinition source)
- throws AmbiguousMember, ClassNotFound {
-
- return getVariable0(env, nm, source, true, true);
- }
-
- /*
- * private fields are never inherited. package-private fields are
- * not inherited across package boundaries. To capture this, we
- * take two booleans as parameters: showPrivate indicates whether
- * we have passed a class boundary, and showPackage indicates whether
- * we have crossed a package boundary.
- */
- private MemberDefinition getVariable0(Environment env,
- Identifier nm,
- ClassDefinition source,
- boolean showPrivate,
- boolean showPackage)
- throws AmbiguousMember, ClassNotFound {
-
- // Check to see if this field is defined in the current class
- for (MemberDefinition member = getFirstMatch(nm);
- member != null;
- member = member.getNextMatch()) {
- if (member.isVariable()) {
- if ((showPrivate || !member.isPrivate()) &&
- (showPackage || !member.isPackagePrivate())) {
- // It is defined in this class.
- return member;
- } else {
- // Even though this definition is not inherited,
- // it hides all definitions in supertypes.
- return null;
- }
- }
- }
-
- // Find the field in our superclass.
- ClassDeclaration sup = getSuperClass();
- MemberDefinition field = null;
- if (sup != null) {
- field =
- sup.getClassDefinition(env)
- .getVariable0(env, nm, source,
- false,
- showPackage && inSamePackage(sup));
- }
-
- // Find the field in our superinterfaces.
- for (int i = 0 ; i < interfaces.length ; i++) {
- // Try to look up the field in an interface. Since interfaces
- // only have public fields, the values of the two boolean
- // arguments are not important.
- MemberDefinition field2 =
- interfaces[i].getClassDefinition(env)
- .getVariable0(env, nm, source, true, true);
-
- if (field2 != null) {
- // If we have two different, accessible fields, then
- // we've found an ambiguity.
- if (field != null &&
- source.canAccess(env, field) &&
- field2 != field) {
-
- throw new AmbiguousMember(field2, field);
- }
- field = field2;
- }
- }
- return field;
- }
-
- /**
- * Tells whether to report a deprecation error for this class.
- */
- public boolean reportDeprecated(Environment env) {
- return (isDeprecated()
- || (outerClass != null && outerClass.reportDeprecated(env)));
- }
-
- /**
- * Note that this class is being used somehow by {@code ref}.
- * Report deprecation errors, etc.
- */
- public void noteUsedBy(ClassDefinition ref, long where, Environment env) {
- // (Have this deal with canAccess() checks, too?)
- if (reportDeprecated(env)) {
- env.error(where, "warn.class.is.deprecated", this);
- }
- }
-
- /**
- * Get an inner class.
- * Look in supers but not outers.
- * (This is used directly to resolve expressions like "site.K", and
- * inside a loop to resolve lone names like "K" or the "K" in "K.L".)
- *
- * Called from 'Context' and 'FieldExpression' as well as this class.
- *
- * @see FieldExpression.checkCommon
- * @see resolveName
- */
- public MemberDefinition getInnerClass(Environment env, Identifier nm)
- throws ClassNotFound {
- // Note: AmbiguousClass will not be thrown unless and until
- // inner classes can be defined inside interfaces.
-
- // Check if it is defined in the current class
- for (MemberDefinition field = getFirstMatch(nm);
- field != null ; field = field.getNextMatch()) {
- if (field.isInnerClass()) {
- if (field.getInnerClass().isLocal()) {
- continue; // ignore this name; it is internally generated
- }
- return field;
- }
- }
-
- // Get it from the super class
- // It is likely that 'getSuperClass()' could be made to work here
- // but we would have to assure somehow that 'resolveTypeStructure'
- // has been called on the current class nest. Since we can get
- // here from 'resolveName', which is called from 'resolveSupers',
- // it is possible that the first attempt to resolve the superclass
- // will originate here, instead of in the call to 'getSuperClass'
- // in 'checkSupers'. See 'resolveTypeStructure', in which a call
- // to 'resolveSupers' precedes the call to 'checkSupers'. Why is
- // name resolution done twice, first in 'resolveName'?
- // NOTE: 'SourceMember.resolveTypeStructure' may initiate type
- // structure resolution for an inner class. Normally, this
- // occurs during the resolution of the outer class, but fields
- // added after the resolution of their containing class will
- // be resolved late -- see 'addMember(env,field)' below.
- // This should only happen for synthetic members, which should
- // never be an inner class.
- ClassDeclaration sup = getSuperClass(env);
- if (sup != null)
- return sup.getClassDefinition(env).getInnerClass(env, nm);
-
- return null;
- }
-
- /**
- * Lookup a method. This code implements the method lookup
- * mechanism specified in JLS 15.11.2.
- *
- * This mechanism cannot be used to lookup synthetic methods.
- */
- private MemberDefinition matchMethod(Environment env,
- ClassDefinition accessor,
- Identifier methodName,
- Type[] argumentTypes,
- boolean isAnonConstCall,
- Identifier accessPackage)
- throws AmbiguousMember, ClassNotFound {
-
- if (allMethods == null || !allMethods.isFrozen()) {
- // This may be too restrictive.
- throw new CompilerError("matchMethod called early");
- // collectInheritedMethods(env);
- }
-
- // A tentative maximally specific method.
- MemberDefinition tentative = null;
-
- // A list of other methods which may be maximally specific too.
- List candidateList = null;
-
- // Get all the methods inherited by this class which
- // have the name `methodName'.
- Iterator methods = allMethods.lookupName(methodName);
-
- while (methods.hasNext()) {
- MemberDefinition method = methods.next();
-
- // See if this method is applicable.
- if (!env.isApplicable(method, argumentTypes)) {
- continue;
- }
-
- // See if this method is accessible.
- if (accessor != null) {
- if (!accessor.canAccess(env, method)) {
- continue;
- }
- } else if (isAnonConstCall) {
- if (method.isPrivate() ||
- (method.isPackagePrivate() &&
- accessPackage != null &&
- !inSamePackage(accessPackage))) {
- // For anonymous constructor accesses, we
- // haven't yet built an accessing class.
- // We disallow anonymous classes from seeing
- // private/package-private inaccessible
- // constructors in their superclass.
- continue;
- }
- } else {
- // If accessor is null, we assume that the access
- // is allowed. Query: is this option used?
- }
-
- if (tentative == null) {
- // `method' becomes our tentative maximally specific match.
- tentative = method;
- } else {
- if (env.isMoreSpecific(method, tentative)) {
- // We have found a method which is a strictly better
- // match than `tentative'. Replace it.
- tentative = method;
- } else {
- // If this method could possibly be another
- // maximally specific method, add it to our
- // list of other candidates.
- if (!env.isMoreSpecific(tentative,method)) {
- if (candidateList == null) {
- candidateList = new ArrayList<>();
- }
- candidateList.add(method);
- }
- }
- }
- }
-
- if (tentative != null && candidateList != null) {
- // Find out if our `tentative' match is a uniquely
- // maximally specific.
- Iterator candidates = candidateList.iterator();
- while (candidates.hasNext()) {
- MemberDefinition method = candidates.next();
- if (!env.isMoreSpecific(tentative, method)) {
- throw new AmbiguousMember(tentative, method);
- }
- }
- }
-
- return tentative;
- }
-
- /**
- * Lookup a method. This code implements the method lookup
- * mechanism specified in JLS 15.11.2.
- *
- * This mechanism cannot be used to lookup synthetic methods.
- */
- public MemberDefinition matchMethod(Environment env,
- ClassDefinition accessor,
- Identifier methodName,
- Type[] argumentTypes)
- throws AmbiguousMember, ClassNotFound {
-
- return matchMethod(env, accessor, methodName,
- argumentTypes, false, null);
- }
-
- /**
- * Lookup a method. This code implements the method lookup
- * mechanism specified in JLS 15.11.2.
- *
- * This mechanism cannot be used to lookup synthetic methods.
- */
- public MemberDefinition matchMethod(Environment env,
- ClassDefinition accessor,
- Identifier methodName)
- throws AmbiguousMember, ClassNotFound {
-
- return matchMethod(env, accessor, methodName,
- Type.noArgs, false, null);
- }
-
- /**
- * A version of matchMethod to be used only for constructors
- * when we cannot pass in a sourceClass argument. We just assert
- * our package name.
- *
- * This is used only for anonymous classes, where we have to look up
- * a (potentially) protected constructor with no valid sourceClass
- * parameter available.
- */
- public MemberDefinition matchAnonConstructor(Environment env,
- Identifier accessPackage,
- Type argumentTypes[])
- throws AmbiguousMember, ClassNotFound {
-
- return matchMethod(env, null, idInit, argumentTypes,
- true, accessPackage);
- }
-
- /**
- * Find a method, ie: exact match in this class or any of the super
- * classes.
- *
- * Only called by javadoc. For now I am holding off rewriting this
- * code to rely on collectInheritedMethods(), as that code has
- * not gotten along with javadoc in the past.
- */
- public MemberDefinition findMethod(Environment env, Identifier nm, Type t)
- throws ClassNotFound {
- // look in the current class
- MemberDefinition f;
- for (f = getFirstMatch(nm) ; f != null ; f = f.getNextMatch()) {
- // Note that non-method types return false for equalArguments().
- if (f.getType().equalArguments(t)) {
- return f;
- }
- }
-
- // constructors are not inherited
- if (nm.equals(idInit)) {
- return null;
- }
-
- // look in the super class
- ClassDeclaration sup = getSuperClass();
- if (sup == null)
- return null;
-
- return sup.getClassDefinition(env).findMethod(env, nm, t);
- }
-
- // We create a stub for this. Source classes do more work.
- protected void basicCheck(Environment env) throws ClassNotFound {
- // Do the outer class first.
- if (outerClass != null)
- outerClass.basicCheck(env);
- }
-
- /**
- * Check this class.
- */
- public void check(Environment env) throws ClassNotFound {
- }
-
- public Vset checkLocalClass(Environment env, Context ctx,
- Vset vset, ClassDefinition sup,
- Expression args[], Type argTypes[]
- ) throws ClassNotFound {
- throw new CompilerError("checkLocalClass");
- }
-
- //---------------------------------------------------------------
- // The non-synthetic methods defined in this class or in any
- // of its parents (class or interface). This member is used
- // to cache work done in collectInheritedMethods for use by
- // getMethods() and matchMethod(). It should be accessed by
- // no other method without forethought.
- MethodSet allMethods = null;
-
- // One of our superclasses may contain an abstract method which
- // we are unable to ever implement. This happens when there is
- // a package-private abstract method in our parent and we are in
- // a different package than our parent. In these cases, we
- // keep a list of the "permanently abstract" or "unimplementable"
- // methods so that we can correctly detect that this class is
- // indeed abstract and so that we can give somewhat comprehensible
- // error messages.
- private List permanentlyAbstractMethods = new ArrayList<>();
-
- /**
- * This method returns an Iterator of all abstract methods
- * in our superclasses which we are unable to implement.
- */
- protected Iterator getPermanentlyAbstractMethods() {
- // This method can only be called after collectInheritedMethods.
- if (allMethods == null) {
- throw new CompilerError("isPermanentlyAbstract() called early");
- }
-
- return permanentlyAbstractMethods.iterator();
- }
-
- /**
- * A flag used by turnOffInheritanceChecks() to indicate if
- * inheritance checks are on or off.
- */
- protected static boolean doInheritanceChecks = true;
-
- /**
- * This is a workaround to allow javadoc to turn off certain
- * inheritance/override checks which interfere with javadoc
- * badly. In the future it might be good to eliminate the
- * shared sources of javadoc and javac to avoid the need for this
- * sort of workaround.
- */
- public static void turnOffInheritanceChecks() {
- doInheritanceChecks = false;
- }
-
- /**
- * Add all of the methods declared in or above `parent' to
- * `allMethods', the set of methods in the current class.
- * `myMethods' is the set of all methods declared in this
- * class, and `mirandaMethods' is a repository for Miranda methods.
- * If mirandaMethods is null, no mirandaMethods will be
- * generated.
- *
- * For a definition of Miranda methods, see the comment above the
- * method addMirandaMethods() which occurs later in this file.
- */
- private void collectOneClass(Environment env,
- ClassDeclaration parent,
- MethodSet myMethods,
- MethodSet allMethods,
- MethodSet mirandaMethods) {
-
- // System.out.println("Inheriting methods from " + parent);
-
- try {
- ClassDefinition pClass = parent.getClassDefinition(env);
- Iterator methods = pClass.getMethods(env);
- while (methods.hasNext()) {
- MemberDefinition method =
- methods.next();
-
- // Private methods are not inherited.
- //
- // Constructors are not inherited.
- //
- // Any non-abstract methods in an interface come
- // from java.lang.Object. This means that they
- // should have already been added to allMethods
- // when we walked our superclass lineage.
- if (method.isPrivate() ||
- method.isConstructor() ||
- (pClass.isInterface() && !method.isAbstract())) {
-
- continue;
- }
-
- // Get the components of the methods' signature.
- Identifier name = method.getName();
- Type type = method.getType();
-
- // Check for a method of the same signature which
- // was locally declared.
- MemberDefinition override =
- myMethods.lookupSig(name, type);
-
- // Is this method inaccessible due to package-private
- // visibility?
- if (method.isPackagePrivate() &&
- !inSamePackage(method.getClassDeclaration())) {
-
- if (override != null && this instanceof
- sun.tools.javac.SourceClass) {
- // We give a warning when a class shadows an
- // inaccessible package-private method from
- // its superclass. This warning is meant
- // to prevent people from relying on overriding
- // when it does not happen. This warning should
- // probably be removed to be consistent with the
- // general "no warnings" policy of this
- // compiler.
- //
- // The `instanceof' above is a hack so that only
- // SourceClass generates this warning, not a
- // BinaryClass, for example.
- env.error(method.getWhere(),
- "warn.no.override.access",
- override,
- override.getClassDeclaration(),
- method.getClassDeclaration());
- }
-
- // If our superclass has a package-private abstract
- // method that we have no access to, then we add
- // this method to our list of permanently abstract
- // methods. The idea is, since we cannot override
- // the method, we can never make this class
- // non-abstract.
- if (method.isAbstract()) {
- permanentlyAbstractMethods.add(method);
- }
-
- // `method' is inaccessible. We do not inherit it.
- continue;
- }
-
- if (override != null) {
- // `method' and `override' have the same signature.
- // We are required to check that `override' is a
- // legal override of `method'
-
- //System.out.println ("About to check override of " +
- // method);
-
- override.checkOverride(env, method);
- } else {
- // In the absence of a definition in the class
- // itself, we check to see if this definition
- // can be successfully merged with any other
- // inherited definitions.
-
- // Have we added a member of the same signature
- // to `allMethods' already?
- MemberDefinition formerMethod =
- allMethods.lookupSig(name, type);
-
- // If the previous definition is nonexistent or
- // ignorable, replace it.
- if (formerMethod == null) {
- //System.out.println("Added " + method + " to " +
- // this);
-
- if (mirandaMethods != null &&
- pClass.isInterface() && !isInterface()) {
- // Whenever a class inherits a method
- // from an interface, that method is
- // one of our "miranda" methods. Early
- // VMs require that these methods be
- // added as true members to the class
- // to enable method lookup to work in the
- // VM.
- method =
- new sun.tools.javac.SourceMember(method,this,
- env);
- mirandaMethods.add(method);
-
- //System.out.println("Added " + method +
- // " to " + this + " as a Miranda");
- }
-
- // There is no previous inherited definition.
- // Add `method' to `allMethods'.
- allMethods.add(method);
- } else if (isInterface() &&
- !formerMethod.isAbstract() &&
- method.isAbstract()) {
- // If we are in an interface and we have inherited
- // both an abstract method and a non-abstract method
- // then we know that the non-abstract method is
- // a placeholder from Object put in for type checking
- // and the abstract method was already checked to
- // be proper by our superinterface.
- allMethods.replace(method);
-
- } else {
- // Okay, `formerMethod' and `method' both have the
- // same signature. See if they are compatible.
-
- //System.out.println ("About to check meet of " +
- // method);
-
- if (!formerMethod.checkMeet(env,
- method,
- this.getClassDeclaration())) {
- // The methods are incompatible. Skip to
- // next method.
- continue;
- }
-
- if (formerMethod.couldOverride(env, method)) {
- // Do nothing. The current definition
- // is specific enough.
-
- //System.out.println("trivial meet of " +
- // method);
- continue;
- }
-
- if (method.couldOverride(env, formerMethod)) {
- // `method' is more specific than
- // `formerMethod'. replace `formerMethod'.
-
- //System.out.println("new def of " + method);
- if (mirandaMethods != null &&
- pClass.isInterface() && !isInterface()) {
- // Whenever a class inherits a method
- // from an interface, that method is
- // one of our "miranda" methods. Early
- // VMs require that these methods be
- // added as true members to the class
- // to enable method lookup to work in the
- // VM.
- method =
- new sun.tools.javac.SourceMember(method,
- this,env);
-
- mirandaMethods.replace(method);
-
- //System.out.println("Added " + method +
- // " to " + this + " as a Miranda");
- }
-
- allMethods.replace(method);
-
- continue;
- }
-
- // Neither method is more specific than the other.
- // Oh well. We need to construct a nontrivial
- // meet of the two methods.
- //
- // This is not yet implemented, so we give
- // a message with a helpful workaround.
- env.error(this.where,
- "nontrivial.meet", method,
- formerMethod.getClassDefinition(),
- method.getClassDeclaration()
- );
- }
- }
- }
- } catch (ClassNotFound ee) {
- env.error(getWhere(), "class.not.found", ee.name, this);
- }
- }
-
- /**
- * Collect all methods defined in this class or inherited from
- * any of our superclasses or interfaces. Look for any
- * incompatible definitions.
- *
- *
This function is also responsible for collecting the
- * Miranda methods for a class. For a definition of
- * Miranda methods, see the comment in addMirandaMethods()
- * below.
- */
- protected void collectInheritedMethods(Environment env) {
- // The methods defined in this class.
- MethodSet myMethods;
- MethodSet mirandaMethods;
-
- //System.out.println("Called collectInheritedMethods() for " +
- // this);
-
- if (allMethods != null) {
- if (allMethods.isFrozen()) {
- // We have already done the collection. No need to
- // do it again.
- return;
- } else {
- // We have run into a circular need to collect our methods.
- // This should not happen at this stage.
- throw new CompilerError("collectInheritedMethods()");
- }
- }
-
- myMethods = new MethodSet();
- allMethods = new MethodSet();
-
- // For testing, do not generate miranda methods.
- if (env.version12()) {
- mirandaMethods = null;
- } else {
- mirandaMethods = new MethodSet();
- }
-
- // Any methods defined in the current class get added
- // to both the myMethods and the allMethods MethodSets.
-
- for (MemberDefinition member = getFirstMember();
- member != null;
- member = member.nextMember) {
-
- // We only collect methods. Initializers are not relevant.
- if (member.isMethod() &&
- !member.isInitializer()) {
-
- //System.out.println("Declared in " + this + ", " + member);
-
- ////////////////////////////////////////////////////////////
- // PCJ 2003-07-30 modified the following code because with
- // the covariant return type feature of the 1.5 compiler,
- // there might be multiple methods with the same signature
- // but different return types, and MethodSet doesn't
- // support that. We use a new utility method that attempts
- // to ensure that the appropriate method winds up in the
- // MethodSet. See 4892308.
- ////////////////////////////////////////////////////////////
- // myMethods.add(member);
- // allMethods.add(member);
- ////////////////////////////////////////////////////////////
- methodSetAdd(env, myMethods, member);
- methodSetAdd(env, allMethods, member);
- ////////////////////////////////////////////////////////////
- }
- }
-
- // We're ready to start adding inherited methods. First add
- // the methods from our superclass.
-
- //System.out.println("About to start superclasses for " + this);
-
- ClassDeclaration scDecl = getSuperClass(env);
- if (scDecl != null) {
- collectOneClass(env, scDecl,
- myMethods, allMethods, mirandaMethods);
-
- // Make sure that we add all unimplementable methods from our
- // superclass to our list of unimplementable methods.
- ClassDefinition sc = scDecl.getClassDefinition();
- Iterator supIter = sc.getPermanentlyAbstractMethods();
- while (supIter.hasNext()) {
- permanentlyAbstractMethods.add(supIter.next());
- }
- }
-
- // Now we inherit all of the methods from our interfaces.
-
- //System.out.println("About to start interfaces for " + this);
-
- for (int i = 0; i < interfaces.length; i++) {
- collectOneClass(env, interfaces[i],
- myMethods, allMethods, mirandaMethods);
- }
- allMethods.freeze();
-
- // Now we have collected all of our methods from our superclasses
- // and interfaces into our `allMethods' member. Good. As a last
- // task, we add our collected miranda methods to this class.
- //
- // If we do not add the mirandas to the class explicitly, there
- // will be no code generated for them.
- if (mirandaMethods != null && mirandaMethods.size() > 0) {
- addMirandaMethods(env, mirandaMethods.iterator());
- }
- }
-
- ////////////////////////////////////////////////////////////
- // PCJ 2003-07-30 added this utility method to insulate
- // MethodSet additions from the covariant return type
- // feature of the 1.5 compiler. When there are multiple
- // methods with the same signature and different return
- // types to be added, we try to ensure that the one with
- // the most specific return type winds up in the MethodSet.
- // This logic was not put into MethodSet itself because it
- // requires access to an Environment for type relationship
- // checking. No error checking is performed here, but that
- // should be OK because this code is only still used by
- // rmic. See 4892308.
- ////////////////////////////////////////////////////////////
- private static void methodSetAdd(Environment env,
- MethodSet methodSet,
- MemberDefinition newMethod)
- {
- MemberDefinition oldMethod = methodSet.lookupSig(newMethod.getName(),
- newMethod.getType());
- if (oldMethod != null) {
- Type oldReturnType = oldMethod.getType().getReturnType();
- Type newReturnType = newMethod.getType().getReturnType();
- try {
- if (env.isMoreSpecific(newReturnType, oldReturnType)) {
- methodSet.replace(newMethod);
- }
- } catch (ClassNotFound ignore) {
- }
- } else {
- methodSet.add(newMethod);
- }
- }
- ////////////////////////////////////////////////////////////
-
- /**
- * Get an Iterator of all methods which could be accessed in an
- * instance of this class.
- */
- public Iterator getMethods(Environment env) {
- if (allMethods == null) {
- collectInheritedMethods(env);
- }
- return getMethods();
- }
-
- /**
- * Get an Iterator of all methods which could be accessed in an
- * instance of this class. Throw a compiler error if we haven't
- * generated this information yet.
- */
- public Iterator getMethods() {
- if (allMethods == null) {
- throw new CompilerError("getMethods: too early");
- }
- return allMethods.iterator();
- }
-
- // In early VM's there was a bug -- the VM didn't walk the interfaces
- // of a class looking for a method, they only walked the superclass
- // chain. This meant that abstract methods defined only in interfaces
- // were not being found. To fix this bug, a counter-bug was introduced
- // in the compiler -- the so-called Miranda methods. If a class
- // does not provide a definition for an abstract method in one of
- // its interfaces then the compiler inserts one in the class artificially.
- // That way the VM didn't have to bother looking at the interfaces.
- //
- // This is a problem. Miranda methods are not part of the specification.
- // But they continue to be inserted so that old VM's can run new code.
- // Someday, when the old VM's are gone, perhaps classes can be compiled
- // without Miranda methods. Towards this end, the compiler has a
- // flag, -nomiranda, which can turn off the creation of these methods.
- // Eventually that behavior should become the default.
- //
- // Why are they called Miranda methods? Well the sentence "If the
- // class is not able to provide a method, then one will be provided
- // by the compiler" is very similar to the sentence "If you cannot
- // afford an attorney, one will be provided by the court," -- one
- // of the so-called "Miranda" rights in the United States.
-
- /**
- * Add a list of methods to this class as miranda methods. This
- * gets overridden with a meaningful implementation in SourceClass.
- * BinaryClass should not need to do anything -- it should already
- * have its miranda methods and, if it doesn't, then that doesn't
- * affect our compilation.
- */
- protected void addMirandaMethods(Environment env,
- Iterator mirandas) {
- // do nothing.
- }
-
- //---------------------------------------------------------------
-
- public void inlineLocalClass(Environment env) {
- }
-
- /**
- * We create a stub for this. Source classes do more work.
- * Some calls from 'SourceClass.checkSupers' execute this method.
- * @see sun.tools.javac.SourceClass#resolveTypeStructure
- */
-
- public void resolveTypeStructure(Environment env) {
- }
-
- /**
- * Look up an inner class name, from somewhere inside this class.
- * Since supers and outers are in scope, search them too.
- *
- * If no inner class is found, env.resolveName() is then called,
- * to interpret the ambient package and import directives.
- *
- * This routine operates on a "best-efforts" basis. If
- * at some point a class is not found, the partially-resolved
- * identifier is returned. Eventually, someone else has to
- * try to get the ClassDefinition and diagnose the ClassNotFound.
- *
- * resolveName() looks at surrounding scopes, and hence
- * pulling in both inherited and uplevel types. By contrast,
- * resolveInnerClass() is intended only for interpreting
- * explicitly qualified names, and so look only at inherited
- * types. Also, resolveName() looks for package prefixes,
- * which appear similar to "very uplevel" outer classes.
- *
- * A similar (but more complex) name-lookup process happens
- * when field and identifier expressions denoting qualified names
- * are type-checked. The added complexity comes from the fact
- * that variables may occur in such names, and take precedence
- * over class and package names.
- *
- * In the expression type-checker, resolveInnerClass() is paralleled
- * by code in FieldExpression.checkAmbigName(), which also calls
- * ClassDefinition.getInnerClass() to interpret names of the form
- * "OuterClass.Inner" (and also outerObject.Inner). The checking
- * of an identifier expression that fails to be a variable is referred
- * directly to resolveName().
- */
- public Identifier resolveName(Environment env, Identifier name) {
- if (tracing) env.dtEvent("ClassDefinition.resolveName: " + name);
- // This logic is pretty much exactly parallel to that of
- // Environment.resolveName().
- if (name.isQualified()) {
- // Try to resolve the first identifier component,
- // because inner class names take precedence over
- // package prefixes. (Cf. Environment.resolveName.)
- Identifier rhead = resolveName(env, name.getHead());
-
- if (rhead.hasAmbigPrefix()) {
- // The first identifier component refers to an
- // ambiguous class. Limp on. We throw away the
- // rest of the classname as it is irrelevant.
- // (part of solution for 4059855).
- return rhead;
- }
-
- if (!env.classExists(rhead)) {
- return env.resolvePackageQualifiedName(name);
- }
- try {
- return env.getClassDefinition(rhead).
- resolveInnerClass(env, name.getTail());
- } catch (ClassNotFound ee) {
- // return partially-resolved name someone else can fail on
- return Identifier.lookupInner(rhead, name.getTail());
- }
- }
-
- // This method used to fail to look for local classes, thus a
- // reference to a local class within, e.g., the type of a member
- // declaration, would fail to resolve if the immediately enclosing
- // context was an inner class. The code added below is ugly, but
- // it works, and is lifted from existing code in 'Context.resolveName'
- // and 'Context.getClassCommon'. See the comments there about the design.
- // Fixes 4095716.
-
- int ls = -2;
- LocalMember lf = null;
- if (classContext != null) {
- lf = classContext.getLocalClass(name);
- if (lf != null) {
- ls = lf.getScopeNumber();
- }
- }
-
- // Look for an unqualified name in enclosing scopes.
- for (ClassDefinition c = this; c != null; c = c.outerClass) {
- try {
- MemberDefinition f = c.getInnerClass(env, name);
- if (f != null &&
- (lf == null || classContext.getScopeNumber(c) > ls)) {
- // An uplevel member was found, and was nested more deeply than
- // any enclosing local of the same name.
- return f.getInnerClass().getName();
- }
- } catch (ClassNotFound ee) {
- // a missing superclass, or something catastrophic
- }
- }
-
- // No uplevel member found, so use the enclosing local if one was found.
- if (lf != null) {
- return lf.getInnerClass().getName();
- }
-
- // look in imports, etc.
- return env.resolveName(name);
- }
-
- /**
- * Interpret a qualified class name, which may have further subcomponents..
- * Follow inheritance links, as in:
- * class C { class N { } } class D extends C { } ... new D.N() ...
- * Ignore outer scopes and packages.
- * @see resolveName
- */
- public Identifier resolveInnerClass(Environment env, Identifier nm) {
- if (nm.isInner()) throw new CompilerError("inner");
- if (nm.isQualified()) {
- Identifier rhead = resolveInnerClass(env, nm.getHead());
- try {
- return env.getClassDefinition(rhead).
- resolveInnerClass(env, nm.getTail());
- } catch (ClassNotFound ee) {
- // return partially-resolved name someone else can fail on
- return Identifier.lookupInner(rhead, nm.getTail());
- }
- } else {
- try {
- MemberDefinition f = getInnerClass(env, nm);
- if (f != null) {
- return f.getInnerClass().getName();
- }
- } catch (ClassNotFound ee) {
- // a missing superclass, or something catastrophic
- }
- // Fake a good name for a diagnostic.
- return Identifier.lookupInner(this.getName(), nm);
- }
- }
-
- /**
- * While resolving import directives, the question has arisen:
- * does a given inner class exist? If the top-level class exists,
- * we ask it about an inner class via this method.
- * This method looks only at the literal name of the class,
- * and does not attempt to follow inheritance links.
- * This is necessary, since at the time imports are being
- * processed, inheritance links have not been resolved yet.
- * (Thus, an import directive must always spell a class
- * name exactly.)
- */
- public boolean innerClassExists(Identifier nm) {
- for (MemberDefinition field = getFirstMatch(nm.getHead()) ; field != null ; field = field.getNextMatch()) {
- if (field.isInnerClass()) {
- if (field.getInnerClass().isLocal()) {
- continue; // ignore this name; it is internally generated
- }
- return !nm.isQualified() ||
- field.getInnerClass().innerClassExists(nm.getTail());
- }
- }
- return false;
- }
-
- /**
- * Find any method with a given name.
- */
- public MemberDefinition findAnyMethod(Environment env, Identifier nm) throws ClassNotFound {
- MemberDefinition f;
- for (f = getFirstMatch(nm) ; f != null ; f = f.getNextMatch()) {
- if (f.isMethod()) {
- return f;
- }
- }
-
- // look in the super class
- ClassDeclaration sup = getSuperClass();
- if (sup == null)
- return null;
- return sup.getClassDefinition(env).findAnyMethod(env, nm);
- }
-
- /**
- * Given the fact that this class has no method "nm" matching "argTypes",
- * find out if the mismatch can be blamed on a particular actual argument
- * which disagrees with all of the overloadings.
- * If so, return the code (i<<2)+(castOK<<1)+ambig, where
- * "i" is the number of the offending argument, and
- * "castOK" is 1 if a cast could fix the problem.
- * The target type for the argument is returned in margTypeResult[0].
- * If not all methods agree on this type, "ambig" is 1.
- * If there is more than one method, the choice of target type is
- * arbitrary.
- * Return -1 if every argument is acceptable to at least one method.
- * Return -2 if there are no methods of the required arity.
- * The value "start" gives the index of the first argument to begin
- * checking.
- */
- public int diagnoseMismatch(Environment env, Identifier nm, Type argTypes[],
- int start, Type margTypeResult[]) throws ClassNotFound {
- int haveMatch[] = new int[argTypes.length];
- Type margType[] = new Type[argTypes.length];
- if (!diagnoseMismatch(env, nm, argTypes, start, haveMatch, margType))
- return -2;
- for (int i = start; i < argTypes.length; i++) {
- if (haveMatch[i] < 4) {
- margTypeResult[0] = margType[i];
- return (i<<2) | haveMatch[i];
- }
- }
- return -1;
- }
-
- private boolean diagnoseMismatch(Environment env, Identifier nm, Type argTypes[], int start,
- int haveMatch[], Type margType[]) throws ClassNotFound {
- // look in the current class
- boolean haveOne = false;
- MemberDefinition f;
- for (f = getFirstMatch(nm) ; f != null ; f = f.getNextMatch()) {
- if (!f.isMethod()) {
- continue;
- }
- Type fArgTypes[] = f.getType().getArgumentTypes();
- if (fArgTypes.length == argTypes.length) {
- haveOne = true;
- for (int i = start; i < argTypes.length; i++) {
- Type at = argTypes[i];
- Type ft = fArgTypes[i];
- if (env.implicitCast(at, ft)) {
- haveMatch[i] = 4;
- continue;
- } else if (haveMatch[i] <= 2 && env.explicitCast(at, ft)) {
- if (haveMatch[i] < 2) margType[i] = null;
- haveMatch[i] = 2;
- } else if (haveMatch[i] > 0) {
- continue;
- }
- if (margType[i] == null)
- margType[i] = ft;
- else if (margType[i] != ft)
- haveMatch[i] |= 1;
- }
- }
- }
-
- // constructors are not inherited
- if (nm.equals(idInit)) {
- return haveOne;
- }
-
- // look in the super class
- ClassDeclaration sup = getSuperClass();
- if (sup != null) {
- if (sup.getClassDefinition(env).diagnoseMismatch(env, nm, argTypes, start,
- haveMatch, margType))
- haveOne = true;
- }
- return haveOne;
- }
-
- /**
- * Add a field (no checks)
- */
- public void addMember(MemberDefinition field) {
- //System.out.println("ADD = " + field);
- if (firstMember == null) {
- firstMember = lastMember = field;
- } else if (field.isSynthetic() && field.isFinal()
- && field.isVariable()) {
- // insert this at the front, because of initialization order
- field.nextMember = firstMember;
- firstMember = field;
- field.nextMatch = fieldHash.get(field.name);
- } else {
- lastMember.nextMember = field;
- lastMember = field;
- field.nextMatch = fieldHash.get(field.name);
- }
- fieldHash.put(field.name, field);
- }
-
- /**
- * Add a field (subclasses make checks)
- */
- public void addMember(Environment env, MemberDefinition field) {
- addMember(field);
- if (resolved) {
- // a late addition
- field.resolveTypeStructure(env);
- }
- }
-
- /**
- * Find or create an uplevel reference for the given target.
- */
- public UplevelReference getReference(LocalMember target) {
- for (UplevelReference r = references; r != null; r = r.getNext()) {
- if (r.getTarget() == target) {
- return r;
- }
- }
- return addReference(target);
- }
-
- protected UplevelReference addReference(LocalMember target) {
- if (target.getClassDefinition() == this) {
- throw new CompilerError("addReference "+target);
- }
- referencesMustNotBeFrozen();
- UplevelReference r = new UplevelReference(this, target);
- references = r.insertInto(references);
- return r;
- }
-
- /**
- * Return the list of all uplevel references.
- */
- public UplevelReference getReferences() {
- return references;
- }
-
- /**
- * Return the same value as getReferences.
- * Also, mark the set of references frozen.
- * After that, it is an error to add new references.
- */
- public UplevelReference getReferencesFrozen() {
- referencesFrozen = true;
- return references;
- }
-
- /**
- * assertion check
- */
- public final void referencesMustNotBeFrozen() {
- if (referencesFrozen) {
- throw new CompilerError("referencesMustNotBeFrozen "+this);
- }
- }
-
- /**
- * Get helper method for class literal lookup.
- */
- public MemberDefinition getClassLiteralLookup(long fwhere) {
- throw new CompilerError("binary class");
- }
-
- /**
- * Add a dependency
- */
- public void addDependency(ClassDeclaration c) {
- throw new CompilerError("addDependency");
- }
-
- /**
- * Maintain a hash table of local and anonymous classes
- * whose internal names are prefixed by the current class.
- * The key is the simple internal name, less the prefix.
- */
-
- public ClassDefinition getLocalClass(String name) {
- if (localClasses == null) {
- return null;
- } else {
- return localClasses.get(name);
- }
- }
-
- public void addLocalClass(ClassDefinition c, String name) {
- if (localClasses == null) {
- localClasses = new Hashtable<>(LOCAL_CLASSES_SIZE);
- }
- localClasses.put(name, c);
- }
-
-
- /**
- * Print for debugging
- */
- public void print(PrintStream out) {
- if (isPublic()) {
- out.print("public ");
- }
- if (isInterface()) {
- out.print("interface ");
- } else {
- out.print("class ");
- }
- out.print(getName() + " ");
- if (getSuperClass() != null) {
- out.print("extends " + getSuperClass().getName() + " ");
- }
- if (interfaces.length > 0) {
- out.print("implements ");
- for (int i = 0 ; i < interfaces.length ; i++) {
- if (i > 0) {
- out.print(", ");
- }
- out.print(interfaces[i].getName());
- out.print(" ");
- }
- }
- out.println("{");
-
- for (MemberDefinition f = getFirstMember() ; f != null ; f = f.getNextMember()) {
- out.print(" ");
- f.print(out);
- }
-
- out.println("}");
- }
-
- /**
- * Convert to String
- */
- public String toString() {
- return getClassDeclaration().toString();
- }
-
- /**
- * After the class has been written to disk, try to free up
- * some storage.
- */
- public void cleanup(Environment env) {
- if (env.dump()) {
- env.output("[cleanup " + getName() + "]");
- }
- for (MemberDefinition f = getFirstMember() ; f != null ; f = f.getNextMember()) {
- f.cleanup(env);
- }
- // keep "references" around, for the sake of local subclasses
- documentation = null;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassFile.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassFile.java
deleted file mode 100644
index eacea99552a..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassFile.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 1995, 2004, 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 sun.tools.java;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.zip.*;
-
-/**
- * Abstract class to represent a class file.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public
-abstract class ClassFile {
- /**
- * Factory method to create a ClassFile backed by a File.
- *
- * @param file a File object
- * @return a new ClassFile
- */
- public static ClassFile newClassFile(File file) {
- return new FileClassFile(file);
- }
-
- /**
- * Factory method to create a ClassFile backed by a ZipEntry.
- *
- * @param zf a ZipFile
- * @param ze a ZipEntry within the zip file
- * @return a new ClassFile
- */
- public static ClassFile newClassFile(ZipFile zf, ZipEntry ze) {
- return new ZipClassFile(zf, ze);
- }
-
- /**
- * Factory method to create a ClassFile backed by a nio Path.
- *
- * @param path nio Path object
- * @return a new ClassFile
- */
- public static ClassFile newClassFile(Path path) {
- return Files.exists(path)? new PathClassFile(path) : null;
- }
-
- /**
- * Returns true if this is zip file entry
- */
- public abstract boolean isZipped();
-
- /**
- * Returns input stream to either regular file or zip file entry
- */
- public abstract InputStream getInputStream() throws IOException;
-
- /**
- * Returns true if file exists.
- */
- public abstract boolean exists();
-
- /**
- * Returns true if this is a directory.
- */
- public abstract boolean isDirectory();
-
- /**
- * Return last modification time
- */
- public abstract long lastModified();
-
- /**
- * Get file path. The path for a zip file entry will also include
- * the zip file name.
- */
- public abstract String getPath();
-
- /**
- * Get name of file entry excluding directory name
- */
- public abstract String getName();
-
- /**
- * Get absolute name of file entry
- */
- public abstract String getAbsoluteName();
-
- /**
- * Get length of file
- */
- public abstract long length();
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassNotFound.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassNotFound.java
deleted file mode 100644
index 5d58bfbae13..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassNotFound.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.java;
-
-/**
- * This exception is thrown when a class definition is needed
- * and the class can't be found.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("serial") // JDK implementation class
-public
-class ClassNotFound extends Exception {
- /**
- * The class that was not found
- */
- public Identifier name;
-
- /**
- * Create a ClassNotFound exception
- */
- public ClassNotFound(Identifier nm) {
- super(nm.toString());
- name = nm;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassPath.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassPath.java
deleted file mode 100644
index 48e37ab0eaa..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassPath.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * Copyright (c) 1994, 2012, 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 sun.tools.java;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.util.zip.*;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.net.URI;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.nio.file.ProviderNotFoundException;
-import java.nio.file.spi.FileSystemProvider;
-
-/**
- * This class is used to represent a class path, which can contain both
- * directories and zip files.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public
-class ClassPath {
- private FileSystem getJrtFileSystem() {
- return FileSystems.getFileSystem(URI.create("jrt:/"));
- }
-
- static final char dirSeparator = File.pathSeparatorChar;
-
- /**
- * The original class path string
- */
- String pathstr;
-
- /**
- * List of class path entries
- */
- private ClassPathEntry[] path;
-
- /**
- * Build a class path from the specified path string
- */
- public ClassPath(String pathstr) {
- init(pathstr);
- }
-
- /**
- * Build a class path from the specified array of class path
- * element strings. This constructor, and the corresponding
- * "init" method, were added as part of the fix for 6473331, which
- * adds support for Class-Path manifest entries in JAR files to
- * rmic. It is conceivable that the value of a Class-Path
- * manifest entry will contain a path separator, which would cause
- * incorrect behavior if the expanded path were passed to the
- * previous constructor as a single path-separator-delimited
- * string; use of this constructor avoids that problem.
- */
- public ClassPath(String[] patharray) {
- init(patharray);
- }
-
- /**
- * Build a default class path from the path strings specified by
- * the properties sun.boot.class.path and env.class.path, in that
- * order.
- */
- public ClassPath() {
- // though this property is removed. Check for null and use only
- // if it is not null (when bootstrap JDK is used).
- String syscp = System.getProperty("sun.boot.class.path");
- String envcp = System.getProperty("env.class.path");
- if (envcp == null) envcp = ".";
-
- // add syscp only if not null!
- String cp = syscp == null? envcp : (syscp + File.pathSeparator + envcp);
- init(cp);
- }
-
- private void init(String pathstr) {
- int i, j, n;
- // Save original class path string
- this.pathstr = pathstr;
-
- if (pathstr.length() == 0) {
- this.path = new ClassPathEntry[0];
- }
-
- // Count the number of path separators
- i = n = 0;
- while ((i = pathstr.indexOf(dirSeparator, i)) != -1) {
- n++; i++;
- }
- // Build the class path
- ClassPathEntry[] path = new ClassPathEntry[n+1];
-
- int len = pathstr.length();
- for (i = n = 0; i < len; i = j + 1) {
- if ((j = pathstr.indexOf(dirSeparator, i)) == -1) {
- j = len;
- }
- if (i == j) {
- path[n++] = new DirClassPathEntry(new File("."));
- } else {
- String filename = pathstr.substring(i, j);
- File file = new File(filename);
- if (file.isFile()) {
- try {
- ZipFile zip = new ZipFile(file);
- path[n++] = new ZipClassPathEntry(zip);
- } catch (ZipException e) {
- } catch (IOException e) {
- // Ignore exceptions, at least for now...
- }
- } else {
- path[n++] = new DirClassPathEntry(file);
- }
- }
- }
-
- // add jrt file system at the end
- try {
- FileSystem fs = getJrtFileSystem();
- path[n++] = new JrtClassPathEntry(fs);
- } catch (ProviderNotFoundException ignored) {
- // this could happen during jdk build with earlier JDK as bootstrap
- }
-
- // Trim class path to exact size
- this.path = new ClassPathEntry[n];
- System.arraycopy((Object)path, 0, (Object)this.path, 0, n);
- }
-
- private void init(String[] patharray) {
- // Save original class path string
- if (patharray.length == 0) {
- this.pathstr = "";
- } else {
- StringBuilder sb = new StringBuilder(patharray[0]);
- for (int i = 1; i < patharray.length; i++) {
- sb.append(File.pathSeparatorChar);
- sb.append(patharray[i]);
- }
- this.pathstr = sb.toString();
- }
-
- // Build the class path
- ClassPathEntry[] path = new ClassPathEntry[patharray.length + 1];
- int n = 0;
- for (String name : patharray) {
- File file = new File(name);
- if (file.isFile()) {
- try {
- ZipFile zip = new ZipFile(file);
- path[n++] = new ZipClassPathEntry(zip);
- } catch (ZipException e) {
- } catch (IOException e) {
- // Ignore exceptions, at least for now...
- }
- } else {
- path[n++] = new DirClassPathEntry(file);
- }
- }
-
- // add jrt file system at the end
- try {
- FileSystem fs = getJrtFileSystem();
- path[n++] = new JrtClassPathEntry(fs);
- } catch (ProviderNotFoundException ignored) {
- // this could happen with earlier version of JDK used as bootstrap
- }
-
- // Trim class path to exact size
- this.path = new ClassPathEntry[n];
- System.arraycopy((Object)path, 0, (Object)this.path, 0, n);
- }
-
- /**
- * Find the specified directory in the class path
- */
- public ClassFile getDirectory(String name) {
- return getFile(name, true);
- }
-
- /**
- * Load the specified file from the class path
- */
- public ClassFile getFile(String name) {
- return getFile(name, false);
- }
-
- private final String fileSeparatorChar = "" + File.separatorChar;
-
- private ClassFile getFile(String name, boolean isDirectory) {
- String subdir = name;
- String basename = "";
- if (!isDirectory) {
- int i = name.lastIndexOf(File.separatorChar);
- subdir = name.substring(0, i + 1);
- basename = name.substring(i + 1);
- } else if (!subdir.isEmpty()
- && !subdir.endsWith(fileSeparatorChar)) {
- // zip files are picky about "foo" vs. "foo/".
- // also, the getFiles caches are keyed with a trailing /
- subdir = subdir + File.separatorChar;
- name = subdir; // Note: isDirectory==true & basename==""
- }
- for (int i = 0; i < path.length; i++) {
- ClassFile cf = path[i].getFile(name, subdir, basename, isDirectory);
- if (cf != null) {
- return cf;
- }
- }
- return null;
- }
-
- /**
- * Returns list of files given a package name and extension.
- */
- public Enumeration getFiles(String pkg, String ext) {
- Hashtable files = new Hashtable<>();
- for (int i = path.length; --i >= 0; ) {
- path[i].fillFiles(pkg, ext, files);
- }
- return files.elements();
- }
-
- /**
- * Release resources.
- */
- public void close() throws IOException {
- for (int i = path.length; --i >= 0; ) {
- path[i].close();
- }
- }
-
- /**
- * Returns original class path string
- */
- public String toString() {
- return pathstr;
- }
-}
-
-/**
- * A class path entry, which can either be a directory or an open zip file or an open jimage filesystem.
- */
-abstract class ClassPathEntry {
- abstract ClassFile getFile(String name, String subdir, String basename, boolean isDirectory);
- abstract void fillFiles(String pkg, String ext, Hashtable files);
- abstract void close() throws IOException;
-}
-
-// a ClassPathEntry that represents a directory
-final class DirClassPathEntry extends ClassPathEntry {
- private final File dir;
-
- DirClassPathEntry(File dir) {
- this.dir = dir;
- }
-
- private final Hashtable subdirs = new Hashtable<>(29); // cache of sub-directory listings:
- private String[] getFiles(String subdir) {
- String files[] = subdirs.get(subdir);
- if (files == null) {
- files = computeFiles(subdir);
- subdirs.put(subdir, files);
- }
- return files;
- }
-
- private String[] computeFiles(String subdir) {
- File sd = new File(dir.getPath(), subdir);
- String[] files = null;
- if (sd.isDirectory()) {
- files = sd.list();
- if (files == null) {
- // should not happen, but just in case, fail silently
- files = new String[0];
- }
- if (files.length == 0) {
- String nonEmpty[] = { "" };
- files = nonEmpty;
- }
- } else {
- files = new String[0];
- }
- return files;
- }
-
- ClassFile getFile(String name, String subdir, String basename, boolean isDirectory) {
- File file = new File(dir.getPath(), name);
- String list[] = getFiles(subdir);
- if (isDirectory) {
- if (list.length > 0) {
- return ClassFile.newClassFile(file);
- }
- } else {
- for (int j = 0; j < list.length; j++) {
- if (basename.equals(list[j])) {
- // Don't bother checking !file.isDir,
- // since we only look for names which
- // cannot already be packages (foo.java, etc).
- return ClassFile.newClassFile(file);
- }
- }
- }
- return null;
- }
-
- void fillFiles(String pkg, String ext, Hashtable files) {
- String[] list = getFiles(pkg);
- for (int j = 0; j < list.length; j++) {
- String name = list[j];
- if (name.endsWith(ext)) {
- name = pkg + File.separatorChar + name;
- File file = new File(dir.getPath(), name);
- files.put(name, ClassFile.newClassFile(file));
- }
- }
- }
-
- void close() throws IOException {
- }
-}
-
-// a ClassPathEntry that represents a .zip or a .jar file
-final class ZipClassPathEntry extends ClassPathEntry {
- private final ZipFile zip;
-
- ZipClassPathEntry(ZipFile zip) {
- this.zip = zip;
- }
-
- void close() throws IOException {
- zip.close();
- }
-
- ClassFile getFile(String name, String subdir, String basename, boolean isDirectory) {
- String newname = name.replace(File.separatorChar, '/');
- ZipEntry entry = zip.getEntry(newname);
- return entry != null? ClassFile.newClassFile(zip, entry) : null;
- }
-
- void fillFiles(String pkg, String ext, Hashtable files) {
- Enumeration extends ZipEntry> e = zip.entries();
- while (e.hasMoreElements()) {
- ZipEntry entry = (ZipEntry)e.nextElement();
- String name = entry.getName();
- name = name.replace('/', File.separatorChar);
- if (name.startsWith(pkg) && name.endsWith(ext)) {
- files.put(name, ClassFile.newClassFile(zip, entry));
- }
- }
- }
-}
-
-// a ClassPathEntry that represents jrt file system
-final class JrtClassPathEntry extends ClassPathEntry {
- private final FileSystem fs;
- // package name to package directory path mapping (lazily filled)
- private final Map pkgDirs;
-
- JrtClassPathEntry(FileSystem fs) {
- this.fs = fs;
- this.pkgDirs = new HashMap<>();
- }
-
- void close() throws IOException {
- }
-
- // from pkgName (internal separator '/') to it's Path in jrtfs
- synchronized Path getPackagePath(String pkgName) throws IOException {
- // check the cache first
- if (pkgDirs.containsKey(pkgName)) {
- return pkgDirs.get(pkgName);
- }
-
- Path pkgLink = fs.getPath("/packages/" + pkgName.replace('/', '.'));
- // check if /packages/$PACKAGE directory exists
- if (Files.isDirectory(pkgLink)) {
- try (DirectoryStream stream = Files.newDirectoryStream(pkgLink)) {
- for (Path p : stream) {
- // find first symbolic link to module directory
- if (Files.isSymbolicLink(p)) {
- Path modDir = Files.readSymbolicLink(p);
- if (Files.isDirectory(modDir)) {
- // get package subdirectory under /modules/$MODULE/
- Path pkgDir = fs.getPath(modDir.toString() + "/" + pkgName);
- if (Files.isDirectory(pkgDir)) {
- // it is a package directory only if contains
- // at least one .class file
- try (DirectoryStream pstream =
- Files.newDirectoryStream(pkgDir)) {
- for (Path f : pstream) {
- if (Files.isRegularFile(f)
- && f.toString().endsWith(".class")) {
- pkgDirs.put(pkgName, pkgDir);
- return pkgDir;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- return null;
- }
-
- // fully qualified (internal) class name to it's Path in jrtfs
- Path getClassPath(String clsName) throws IOException {
- int index = clsName.lastIndexOf('/');
- if (index == -1) {
- return null;
- }
- Path pkgPath = getPackagePath(clsName.substring(0, index));
- return pkgPath == null? null : fs.getPath(pkgPath + "/" + clsName.substring(index + 1));
- }
-
- ClassFile getFile(String name, String subdir, String basename, boolean isDirectory) {
- try {
- name = name.replace(File.separatorChar, '/');
- Path cp = getClassPath(name);
- return cp == null? null : ClassFile.newClassFile(cp);
- } catch (IOException ioExp) {
- throw new UncheckedIOException(ioExp);
- }
- }
-
- void fillFiles(String pkg, String ext, Hashtable files) {
- Path dir;
- try {
- dir = getPackagePath(pkg);
- if (dir == null) {
- return;
- }
- } catch (IOException ioExp) {
- throw new UncheckedIOException(ioExp);
- }
-
- try (DirectoryStream stream = Files.newDirectoryStream(dir)) {
- for (Path p : stream) {
- String name = p.toString();
- name = name.replace('/', File.separatorChar);
- if (name.startsWith(pkg) && name.endsWith(ext)) {
- files.put(name, ClassFile.newClassFile(p));
- }
- }
- } catch (IOException ioExp) {
- throw new UncheckedIOException(ioExp);
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ClassType.java b/src/jdk.rmic/share/classes/sun/tools/java/ClassType.java
deleted file mode 100644
index 9d10d7bddf4..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ClassType.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-/**
- * This class represents an Java class type.
- * It overrides the relevant methods in class Type.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-public final
-class ClassType extends Type {
- /**
- * The fully qualified class name.
- */
- Identifier className;
-
- /**
- * Construct a class type. Use Type.tClass to create
- * a new class type.
- */
- ClassType(String typeSig, Identifier className) {
- super(TC_CLASS, typeSig);
- this.className = className;
- }
-
- public Identifier getClassName() {
- return className;
- }
-
- public String typeString(String id, boolean abbrev, boolean ret) {
- String s = (abbrev ? getClassName().getFlatName() :
- Identifier.lookup(getClassName().getQualifier(),
- getClassName().getFlatName())).toString();
- return (id.length() > 0) ? s + " " + id : s;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/CompilerError.java b/src/jdk.rmic/share/classes/sun/tools/java/CompilerError.java
deleted file mode 100644
index 1a25fbe6690..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/CompilerError.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.java;
-
-/**
- * This exception is thrown when an internal compiler error occurs
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("serial") // JDK implementation class
-public
-class CompilerError extends Error {
- Throwable e;
-
- /**
- * Constructor
- */
- public CompilerError(String msg) {
- super(msg);
- this.e = this;
- }
-
- /**
- * Create an exception given another exception.
- */
- public CompilerError(Exception e) {
- super(e.getMessage());
- this.e = e;
- }
-
- public void printStackTrace() {
- if (e == this)
- super.printStackTrace();
- else
- e.printStackTrace();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Constants.java b/src/jdk.rmic/share/classes/sun/tools/java/Constants.java
deleted file mode 100644
index 4589f263b30..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Constants.java
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.java;
-
-/**
- * This interface defines constant that are used
- * throughout the compiler. It inherits from RuntimeConstants,
- * which is an autogenerated class that contains contstants
- * defined in the interpreter.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-public
-interface Constants extends RuntimeConstants {
-
- /*
- * Enable/disable inclusion of certain debug tracing code in the
- * compiler. When included, the tracing code may be selectively
- * enabled at runtime, otherwise we save the space/time overhead.
- * Should normally be 'false' for a release version.
- */
- public static final boolean tracing = true;
-
- /*
- * Frequently used identifiers
- */
- Identifier idAppend = Identifier.lookup("append");
- Identifier idClassInit = Identifier.lookup("");
- Identifier idCode = Identifier.lookup("Code");
- Identifier idInit = Identifier.lookup("");
- Identifier idLength = Identifier.lookup("length");
- Identifier idNull = Identifier.lookup("");
- Identifier idStar = Identifier.lookup("*");
- Identifier idSuper = Identifier.lookup("super");
- Identifier idThis = Identifier.lookup("this");
- Identifier idClass = Identifier.lookup("class");
- Identifier idToString = Identifier.lookup("toString");
- Identifier idValueOf = Identifier.lookup("valueOf");
- Identifier idNew = Identifier.lookup("new");
- Identifier idGetClass = Identifier.lookup("getClass");
- Identifier idTYPE = Identifier.lookup("TYPE");
- Identifier idFinallyReturnValue = Identifier.lookup("");
-
- Identifier idJavaLang = Identifier.lookup("java.lang");
-
- Identifier idJavaLangCloneable = Identifier.lookup("java.lang.Cloneable");
-
- Identifier idJavaLangError = Identifier.lookup("java.lang.Error");
- Identifier idJavaLangException = Identifier.lookup("java.lang.Exception");
- Identifier idJavaLangObject = Identifier.lookup("java.lang.Object");
- Identifier idJavaLangClass = Identifier.lookup("java.lang.Class");
- Identifier idJavaLangRuntimeException =
- Identifier.lookup("java.lang.RuntimeException");
- Identifier idJavaLangString = Identifier.lookup("java.lang.String");
- Identifier idJavaLangStringBuffer =
- Identifier.lookup("java.lang.StringBuffer");
- Identifier idJavaLangThrowable = Identifier.lookup("java.lang.Throwable");
-
- Identifier idJavaIoSerializable = Identifier.lookup("java.io.Serializable");
-
-
- Identifier idConstantValue = Identifier.lookup("ConstantValue");
- Identifier idLocalVariableTable = Identifier.lookup("LocalVariableTable");
- Identifier idLineNumberTable = Identifier.lookup("LineNumberTable");
-// JCOV
- Identifier idCoverageTable = Identifier.lookup("CoverageTable");
-// end JCOV
- Identifier idSourceFile = Identifier.lookup("SourceFile");
- Identifier idDocumentation = Identifier.lookup("Documentation");
- Identifier idDeprecated = Identifier.lookup("Deprecated");
- Identifier idSynthetic = Identifier.lookup("Synthetic");
- Identifier idExceptions = Identifier.lookup("Exceptions");
- Identifier idInnerClasses = Identifier.lookup("InnerClasses");
-
- /* methods we need to know about */
- Identifier idClone = Identifier.lookup("clone");
-
-
- /* This is not a real signature marker, since it is also
- * an identifier constituent character.
- */
- char SIGC_INNERCLASS = '$';
- String SIG_INNERCLASS = "$";
-
- String prefixThis = "this$";
- String prefixVal = "val$";
- String prefixLoc = "loc$";
- String prefixAccess = "access$";
- String prefixClass = "class$";
- String prefixArray = "array$";
-
- /*
- * Flags
- */
- int F_VERBOSE = 1 << 0;
- int F_DUMP = 1 << 1;
- int F_WARNINGS = 1 << 2;
-
- // The meaning of -g has changed, so F_DEBUG flag is removed.
- // public static final int F_DEBUG = 1 << 3;
- int F_DEBUG_LINES = 1 << 12;
- int F_DEBUG_VARS = 1 << 13;
- int F_DEBUG_SOURCE = 1 << 18;
-
- // The meaning of -O has changed, so F_OPTIMIZE flag is removed.
- // public static final int F_OPTIMIZE = 1 << 4;
- int F_OPT = 1 << 14;
- int F_OPT_INTERCLASS = 1 << 15;
-
- int F_DEPENDENCIES = 1 << 5;
-
-// JCOV
- int F_COVERAGE = 1 << 6;
- int F_COVDATA = 1 << 7;
-// end JCOV
-
- int F_DEPRECATION = 1 << 9;
- int F_PRINT_DEPENDENCIES = 1 << 10;
- int F_VERSION12 = 1 << 11;
-
-
- int F_ERRORSREPORTED = 1 << 16;
-
- int F_STRICTDEFAULT = 1 << 17;
-
- /*
- * Modifiers.
- *
- * There has been much confusion regarding modifiers. There
- * are a number of distinct usages:
- *
- * - in classfiles to annotate classes, as per JVM pg. 102.
- * - in classfiles to annotate methods, as per JVM pg. 104.
- * - in classfiles to annotate InnerClass attributes, as per
- * http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses
- * - in the compiler to record java source level modifiers,
- * as per JLS pg. 157 et al., plus misc. info such as whether
- * a method is deprecated
- * - in the JVM to record misc. info, such as whether a method has
- * has been compiled
- *
- * To make matters worse, the terms "access flags" and "modifiers"
- * are often used interchangably, and some information that might
- * make sense as a flag is expressed using attributes (ie. Synthetic).
- *
- * The constants defined herein have been divided by whether they
- * make sense only within the compiler (M_* and MM_*) or whether
- * they only make sense to the JVM (ACC_* and ACCM_*). At an earlier
- * time these were all lumped together. Future maintenance should
- * strive to keep the distinction clear.
- *
- * Note that modifier M_STRICTFP is not in general recoverable from
- * the ACC_STRICT bit in classfiles.
- *
- * Note also that the modifiers M_LOCAL and M_ANONYMOUS do not appear
- * in the InnerClass attribute, as they are above the first 16 bits.
- */
-
- // Modifiers meaningful to both Java source and the JVM. These
- // have been kept the same bit in the M_* and ACC_* forms
- // to avoid destabilizing the compiler.
- int M_PUBLIC = ACC_PUBLIC;
- int M_PRIVATE = ACC_PRIVATE;
- int M_PROTECTED = ACC_PROTECTED;
- int M_STATIC = ACC_STATIC;
- int M_TRANSIENT = ACC_TRANSIENT;
- int M_SYNCHRONIZED = ACC_SYNCHRONIZED; // collides with ACC_SUPER
- int M_ABSTRACT = ACC_ABSTRACT;
- int M_NATIVE = ACC_NATIVE;
- int M_FINAL = ACC_FINAL;
- int M_VOLATILE = ACC_VOLATILE;
- int M_INTERFACE = ACC_INTERFACE;
-
- // Modifiers not meaningful to the JVM. The JVM only allows 16 bits
- // for modifiers, so keeping these in the unusable bits after the first
- // 16 is a good idea.
- int M_ANONYMOUS = 0x00010000;
- int M_LOCAL = 0x00020000;
- int M_DEPRECATED = 0x00040000;
- int M_SYNTHETIC = 0x00080000;
- int M_INLINEABLE = 0x00100000;
-
- int M_STRICTFP = 0x00200000;
-
- String paraDeprecated = "@deprecated";
-
- // Masks for modifiers that apply to Java source code
- int MM_CLASS = M_PUBLIC
- | M_INTERFACE
- | M_FINAL
- | M_ABSTRACT
- | M_STRICTFP;
- int MM_MEMBER = M_PUBLIC
- | M_PRIVATE
- | M_PROTECTED
- | M_FINAL
- | M_STATIC;
- int MM_FIELD = MM_MEMBER
- | M_TRANSIENT
- | M_VOLATILE;
- int MM_METHOD = MM_MEMBER
- | M_SYNCHRONIZED
- | M_ABSTRACT
- | M_NATIVE
- | M_STRICTFP;
-
- // Masks for modifiers that apply to class files.
- // Note that the M_SYNTHETIC modifier is never written out to a class file.
- // Synthetic members are indicated using the "Synthetic" attribute.
- int ACCM_CLASS = ACC_PUBLIC
- | ACC_INTERFACE
- | ACC_FINAL
- | ACC_ABSTRACT
- | ACC_SUPER
- | ACC_STRICT;
- int ACCM_MEMBER = ACC_PUBLIC
- | ACC_PRIVATE
- | ACC_PROTECTED
- | ACC_FINAL
- | ACC_STATIC;
- // The M_ANONYMOUS and M_LOCAL modifiers are not mentioned in the
- // inner classes specification and are never written to classfiles.
- // Also note that ACC_SUPER should never be set in an InnerClass
- // attribute.
- int ACCM_INNERCLASS = ACC_PUBLIC
- | ACC_PRIVATE
- | ACC_PROTECTED
- | ACC_STATIC
- | ACC_ABSTRACT
- | ACC_FINAL
- | ACC_INTERFACE
- | ACC_STRICT;
- int ACCM_FIELD = ACCM_MEMBER
- | ACC_TRANSIENT
- | ACC_VOLATILE;
- int ACCM_METHOD = ACCM_MEMBER
- | ACC_SYNCHRONIZED
- | ACC_ABSTRACT
- | ACC_NATIVE
- | ACC_STRICT;
-
- /*
- * Type codes
- */
- int TC_BOOLEAN = 0;
- int TC_BYTE = 1;
- int TC_CHAR = 2;
- int TC_SHORT = 3;
- int TC_INT = 4;
- int TC_LONG = 5;
- int TC_FLOAT = 6;
- int TC_DOUBLE = 7;
- int TC_NULL = 8;
- int TC_ARRAY = 9;
- int TC_CLASS = 10;
- int TC_VOID = 11;
- int TC_METHOD = 12;
- int TC_ERROR = 13;
-
-// JCOV
- /*
- * Cover's types
- */
- int CT_FIRST_KIND = 1;
- int CT_METHOD = 1;
- int CT_FIKT_METHOD = 2;
- int CT_BLOCK = 3;
- int CT_FIKT_RET = 4;
- int CT_CASE = 5;
- int CT_SWITH_WO_DEF = 6;
- int CT_BRANCH_TRUE = 7;
- int CT_BRANCH_FALSE = 8;
- int CT_LAST_KIND = 8;
-// end JCOV
-
- /*
- * Type Masks
- */
- int TM_NULL = 1 << TC_NULL;
- int TM_VOID = 1 << TC_VOID;
- int TM_BOOLEAN = 1 << TC_BOOLEAN;
- int TM_BYTE = 1 << TC_BYTE;
- int TM_CHAR = 1 << TC_CHAR;
- int TM_SHORT = 1 << TC_SHORT;
- int TM_INT = 1 << TC_INT;
- int TM_LONG = 1 << TC_LONG;
- int TM_FLOAT = 1 << TC_FLOAT;
- int TM_DOUBLE = 1 << TC_DOUBLE;
- int TM_ARRAY = 1 << TC_ARRAY;
- int TM_CLASS = 1 << TC_CLASS;
- int TM_METHOD = 1 << TC_METHOD;
- int TM_ERROR = 1 << TC_ERROR;
-
- int TM_INT32 = TM_BYTE | TM_SHORT | TM_CHAR | TM_INT;
- int TM_NUM32 = TM_INT32 | TM_FLOAT;
- int TM_NUM64 = TM_LONG | TM_DOUBLE;
- int TM_INTEGER = TM_INT32 | TM_LONG;
- int TM_REAL = TM_FLOAT | TM_DOUBLE;
- int TM_NUMBER = TM_INTEGER | TM_REAL;
- int TM_REFERENCE = TM_ARRAY | TM_CLASS | TM_NULL;
-
- /*
- * Class status
- */
- int CS_UNDEFINED = 0;
- int CS_UNDECIDED = 1;
- int CS_BINARY = 2;
- int CS_SOURCE = 3;
- int CS_PARSED = 4;
- int CS_CHECKED = 5;
- int CS_COMPILED = 6;
- int CS_NOTFOUND = 7;
-
-
- /*
- * Attributes
- */
- int ATT_ALL = 0xFFFFFFFF;
- int ATT_CODE = 1 << 1;
- int ATT_ALLCLASSES = 1 << 2;
-
- /*
- * Number of bits used in file offsets. The line number and
- * file offset are concatenated into a long, with enough room
- * for other information to be added later if desired (such as
- * token lengths). For the moment explicit bit manipulations
- * are used to modify the fields. This makes sense for efficiency
- * but at some point these ought to be better encapsulated.
- */
- int WHEREOFFSETBITS = 32;
- long MAXFILESIZE = (1L << WHEREOFFSETBITS) - 1;
- long MAXLINENUMBER = (1L << (64 - WHEREOFFSETBITS)) - 1;
-
- /*
- * Operators
- */
- int COMMA = 0;
- int ASSIGN = 1;
-
- int ASGMUL = 2;
- int ASGDIV = 3;
- int ASGREM = 4;
- int ASGADD = 5;
- int ASGSUB = 6;
- int ASGLSHIFT = 7;
- int ASGRSHIFT = 8;
- int ASGURSHIFT = 9;
- int ASGBITAND = 10;
- int ASGBITOR = 11;
- int ASGBITXOR = 12;
-
- int COND = 13;
- int OR = 14;
- int AND = 15;
- int BITOR = 16;
- int BITXOR = 17;
- int BITAND = 18;
- int NE = 19;
- int EQ = 20;
- int GE = 21;
- int GT = 22;
- int LE = 23;
- int LT = 24;
- int INSTANCEOF = 25;
- int LSHIFT = 26;
- int RSHIFT = 27;
- int URSHIFT = 28;
- int ADD = 29;
- int SUB = 30;
- int DIV = 31;
- int REM = 32;
- int MUL = 33;
- int CAST = 34; // (x)y
- int POS = 35; // +x
- int NEG = 36; // -x
- int NOT = 37;
- int BITNOT = 38;
- int PREINC = 39; // ++x
- int PREDEC = 40; // --x
- int NEWARRAY = 41;
- int NEWINSTANCE = 42;
- int NEWFROMNAME = 43;
- int POSTINC = 44; // x++
- int POSTDEC = 45; // x--
- int FIELD = 46;
- int METHOD = 47; // x(y)
- int ARRAYACCESS = 48; // x[y]
- int NEW = 49;
- int INC = 50;
- int DEC = 51;
-
- int CONVERT = 55; // implicit conversion
- int EXPR = 56; // (x)
- int ARRAY = 57; // {x, y, ...}
- int GOTO = 58;
-
- /*
- * Value tokens
- */
- int IDENT = 60;
- int BOOLEANVAL = 61;
- int BYTEVAL = 62;
- int CHARVAL = 63;
- int SHORTVAL = 64;
- int INTVAL = 65;
- int LONGVAL = 66;
- int FLOATVAL = 67;
- int DOUBLEVAL = 68;
- int STRINGVAL = 69;
-
- /*
- * Type keywords
- */
- int BYTE = 70;
- int CHAR = 71;
- int SHORT = 72;
- int INT = 73;
- int LONG = 74;
- int FLOAT = 75;
- int DOUBLE = 76;
- int VOID = 77;
- int BOOLEAN = 78;
-
- /*
- * Expression keywords
- */
- int TRUE = 80;
- int FALSE = 81;
- int THIS = 82;
- int SUPER = 83;
- int NULL = 84;
-
- /*
- * Statement keywords
- */
- int IF = 90;
- int ELSE = 91;
- int FOR = 92;
- int WHILE = 93;
- int DO = 94;
- int SWITCH = 95;
- int CASE = 96;
- int DEFAULT = 97;
- int BREAK = 98;
- int CONTINUE = 99;
- int RETURN = 100;
- int TRY = 101;
- int CATCH = 102;
- int FINALLY = 103;
- int THROW = 104;
- int STAT = 105;
- int EXPRESSION = 106;
- int DECLARATION = 107;
- int VARDECLARATION = 108;
-
- /*
- * Declaration keywords
- */
- int IMPORT = 110;
- int CLASS = 111;
- int EXTENDS = 112;
- int IMPLEMENTS = 113;
- int INTERFACE = 114;
- int PACKAGE = 115;
-
- /*
- * Modifier keywords
- */
- int PRIVATE = 120;
- int PUBLIC = 121;
- int PROTECTED = 122;
- int CONST = 123;
- int STATIC = 124;
- int TRANSIENT = 125;
- int SYNCHRONIZED = 126;
- int NATIVE = 127;
- int FINAL = 128;
- int VOLATILE = 129;
- int ABSTRACT = 130;
- int STRICTFP = 131;
-
- /*
- * Punctuation
- */
- int SEMICOLON = 135;
- int COLON = 136;
- int QUESTIONMARK = 137;
- int LBRACE = 138;
- int RBRACE = 139;
- int LPAREN = 140;
- int RPAREN = 141;
- int LSQBRACKET = 142;
- int RSQBRACKET = 143;
- int THROWS = 144;
-
- /*
- * Special tokens
- */
- int ERROR = 145; // an error
- int COMMENT = 146; // not used anymore.
- int TYPE = 147;
- int LENGTH = 148;
- int INLINERETURN = 149;
- int INLINEMETHOD = 150;
- int INLINENEWINSTANCE = 151;
-
- /*
- * Operator precedence
- */
- int opPrecedence[] = {
- 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 12, 13, 14, 15, 16, 17, 18,
- 18, 19, 19, 19, 19, 19, 20, 20, 20, 21,
- 21, 22, 22, 22, 23, 24, 24, 24, 24, 24,
- 24, 25, 25, 26, 26, 26, 26, 26, 26
- };
-
- /*
- * Operator names
- */
- String opNames[] = {
- ",", "=", "*=", "/=", "%=",
- "+=", "-=", "<<=", ">>=", ">>>=",
- "&=", "|=", "^=", "?:", "||",
- "&&", "|", "^", "&", "!=",
- "==", ">=", ">", "<=", "<",
- "instanceof", "<<", ">>", ">>>", "+",
- "-", "/", "%", "*", "cast",
- "+", "-", "!", "~", "++",
- "--", "new", "new", "new", "++",
- "--", "field","method","[]", "new",
- "++", "--", null, null, null,
-
- "convert", "expr", "array", "goto", null,
-
- "Identifier", "boolean", "byte", "char", "short",
- "int", "long", "float", "double", "string",
-
- "byte", "char", "short", "int", "long",
- "float", "double", "void", "boolean", null,
-
- "true", "false", "this", "super", "null",
- null, null, null, null, null,
-
- "if", "else", "for", "while","do",
- "switch", "case", "default", "break", "continue",
- "return", "try", "catch", "finally", "throw",
- "stat", "expression", "declaration", "declaration", null,
-
- "import", "class", "extends", "implements", "interface",
- "package", null, null, null, null,
-
- "private", "public", "protected", "const", "static",
- "transient", "synchronized", "native", "final", "volatile",
- "abstract", "strictfp", null, null, null,
-
- ";", ":", "?", "{", "}",
- "(", ")", "[", "]", "throws",
- "error", "comment", "type", "length", "inline-return",
- "inline-method", "inline-new"
- };
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Environment.java b/src/jdk.rmic/share/classes/sun/tools/java/Environment.java
deleted file mode 100644
index 76f9c01e9a7..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Environment.java
+++ /dev/null
@@ -1,999 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-import java.util.Stack;
-import java.io.IOException;
-import sun.tools.tree.Context;
-//JCOV
-import java.io.File;
-//end JCOV
-
-/**
- * This class defines the environment for a compilation.
- * It is used to load classes, resolve class names and
- * report errors. It is an abstract class, a subclass
- * must define implementations for some of the functions.
- *
- * An environment has a source object associated with it.
- * This is the thing against which errors are reported, it
- * is usually a file name, a field or a class.
- *
- * Environments can be nested to change the source object.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-public class Environment implements Constants {
- /**
- * The actual environment to which everything is forwarded.
- */
- Environment env;
-
- /**
- * External character encoding name
- */
- String encoding;
-
- /**
- * The object that is currently being parsed/compiled.
- * It is either a file name (String) or a field (MemberDefinition)
- * or a class (ClassDeclaration or ClassDefinition).
- */
- Object source;
-
- public Environment(Environment env, Object source) {
- if (env != null && env.env != null && env.getClass() == this.getClass())
- env = env.env; // a small optimization
- this.env = env;
- this.source = source;
- }
- public Environment() {
- this(null, null);
- }
-
- /**
- * Tells whether an Identifier refers to a package which should be
- * exempt from the "exists" check in Imports#resolve().
- */
- public boolean isExemptPackage(Identifier id) {
- return env.isExemptPackage(id);
- }
-
- /**
- * Return a class declaration given a fully qualified class name.
- */
- public ClassDeclaration getClassDeclaration(Identifier nm) {
- return env.getClassDeclaration(nm);
- }
-
- /**
- * Return a class definition given a fully qualified class name.
- *
- * Should be called only with 'internal' class names, i.e., the result
- * of a call to 'resolveName' or a synthetic class name.
- */
- public final ClassDefinition getClassDefinition(Identifier nm) throws ClassNotFound {
- if (nm.isInner()) {
- ClassDefinition c = getClassDefinition(nm.getTopName());
- Identifier tail = nm.getFlatName();
- walkTail:
- while (tail.isQualified()) {
- tail = tail.getTail();
- Identifier head = tail.getHead();
- //System.out.println("CLASS: " + c + " HEAD: " + head + " TAIL: " + tail);
- String hname = head.toString();
- // If the name is of the form 'ClassName.N$localName', where N is
- // a number, the field 'N$localName' may not necessarily be a member
- // of the class named by 'ClassName', but might be a member of some
- // inaccessible class contained within it. We use 'getLocalClass'
- // to do the lookup in this case. This is part of a fix for bugid
- // 4054523 and 4030421. See also 'BatchEnvironment.makeClassDefinition'.
- // This should also work for anonymous class names of the form
- // 'ClassName.N'. Note that the '.' qualifications get converted to
- // '$' characters when determining the external name of the class and
- // the name of the class file.
- if (hname.length() > 0
- && Character.isDigit(hname.charAt(0))) {
- ClassDefinition localClass = c.getLocalClass(hname);
- if (localClass != null) {
- c = localClass;
- continue walkTail;
- }
- } else {
- for (MemberDefinition f = c.getFirstMatch(head);
- f != null; f = f.getNextMatch()) {
- if (f.isInnerClass()) {
- c = f.getInnerClass();
- continue walkTail;
- }
- }
- }
- throw new ClassNotFound(Identifier.lookupInner(c.getName(), head));
- }
- //System.out.println("FOUND " + c + " FOR " + nm);
- return c;
- }
- return getClassDeclaration(nm).getClassDefinition(this);
- }
-
-
- /**
- * Return a class declaration given a type. Only works for
- * class types.
- */
- public ClassDeclaration getClassDeclaration(Type t) {
- return getClassDeclaration(t.getClassName());
- }
-
- /**
- * Return a class definition given a type. Only works for
- * class types.
- */
- public final ClassDefinition getClassDefinition(Type t) throws ClassNotFound {
- return getClassDefinition(t.getClassName());
- }
-
- /**
- * Check if a class exists (without actually loading it).
- * (Since inner classes cannot in general be examined without
- * loading source, this method does not accept inner names.)
- */
- public boolean classExists(Identifier nm) {
- return env.classExists(nm);
- }
-
- public final boolean classExists(Type t) {
- return !t.isType(TC_CLASS) || classExists(t.getClassName());
- }
-
- /**
- * Get the package path for a package
- */
- public Package getPackage(Identifier pkg) throws IOException {
- return env.getPackage(pkg);
- }
-
- /**
- * Load the definition of a class.
- */
- public void loadDefinition(ClassDeclaration c) {
- env.loadDefinition(c);
- }
-
- /**
- * Return the source of the environment (ie: the thing being compiled/parsed).
- */
- public final Object getSource() {
- return source;
- }
-
- /**
- * Resolve a type. Make sure that all the classes referred to by
- * the type have a definition. Report errors. Return true if
- * the type is well-formed. Presently used for types appearing
- * in member declarations, which represent named types internally as
- * qualified identifiers. Type names appearing in local variable
- * declarations and within expressions are represented as identifier
- * or field expressions, and are resolved by 'toType', which delegates
- * handling of the non-inner portion of the name to this method.
- *
- * In 'toType', the various stages of qualification are represented by
- * separate AST nodes. Here, we are given a single identifier which
- * contains the entire qualification structure. It is not possible in
- * general to set the error location to the exact position of a component
- * that is in error, so an error message must refer to the entire qualified
- * name. An attempt to keep track of the string length of the components of
- * the name and to offset the location accordingly fails because the initial
- * prefix of the name may have been rewritten by an earlier call to
- * 'resolveName'. See 'SourceMember.resolveTypeStructure'. The situation
- * is actually even worse than this, because only a single location is
- * passed in for an entire declaration, which may contain many type names.
- * All error messages are thus poorly localized. These checks should be
- * done while traversing the parse tree for the type, not the type descriptor.
- *
- * DESIGN NOTE:
- * As far as I can tell, the two-stage resolution of names represented in
- * string form is an artifact of the late implementation of inner classes
- * and the use of mangled names internally within the compiler. All
- * qualified names should have their hiearchical structure made explicit
- * in the parse tree at the phase at which they are presented for static
- * semantic checking. This would affect class names appearing in 'extends',
- * 'implements', and 'throws' clauses, as well as in member declarations.
- */
- public boolean resolve(long where, ClassDefinition c, Type t) {
- switch (t.getTypeCode()) {
- case TC_CLASS: {
- ClassDefinition def;
- try {
- Identifier nm = t.getClassName();
- if (!nm.isQualified() && !nm.isInner() && !classExists(nm)) {
- resolve(nm); // elicit complaints about ambiguity
- }
- def = getQualifiedClassDefinition(where, nm, c, false);
- if (!c.canAccess(this, def.getClassDeclaration())) {
- // Reported error location may be imprecise
- // if the name is qualified.
- error(where, "cant.access.class", def);
- return true; // return false later
- }
- def.noteUsedBy(c, where, env);
- } catch (AmbiguousClass ee) {
- error(where, "ambig.class", ee.name1, ee.name2);
- return false;
- } catch (ClassNotFound e) {
- // For now, report "class.and.package" only when the code
- // is going to fail anyway.
- try {
- if (e.name.isInner() &&
- getPackage(e.name.getTopName()).exists()) {
- env.error(where, "class.and.package",
- e.name.getTopName());
- }
- } catch (IOException ee) {
- env.error(where, "io.exception", "package check");
- }
- // This error message is also emitted for 'new' expressions.
- // error(where, "class.not.found", e.name, "declaration");
- error(where, "class.not.found.no.context", e.name);
- return false;
- }
- return true;
- }
-
- case TC_ARRAY:
- return resolve(where, c, t.getElementType());
-
- case TC_METHOD:
- boolean ok = resolve(where, c, t.getReturnType());
- Type args[] = t.getArgumentTypes();
- for (int i = args.length ; i-- > 0 ; ) {
- ok &= resolve(where, c, args[i]);
- }
- return ok;
- }
- return true;
- }
-
- /**
- * Given its fully-qualified name, verify that a class is defined and accessible.
- * Used to check components of qualified names in contexts where a class is expected.
- * Like 'resolve', but is given a single type name, not a type descriptor.
- */
- public boolean resolveByName(long where, ClassDefinition c, Identifier nm) {
- return resolveByName(where, c, nm, false);
- }
-
- public boolean resolveExtendsByName(long where, ClassDefinition c, Identifier nm) {
- return resolveByName(where, c, nm, true);
- }
-
- private boolean resolveByName(long where, ClassDefinition c,
- Identifier nm, boolean isExtends) {
- ClassDefinition def;
- try {
- if (!nm.isQualified() && !nm.isInner() && !classExists(nm)) {
- resolve(nm); // elicit complaints about ambiguity
- }
- def = getQualifiedClassDefinition(where, nm, c, isExtends);
- ClassDeclaration decl = def.getClassDeclaration();
- if (!((!isExtends && c.canAccess(this, decl))
- ||
- (isExtends && c.extendsCanAccess(this, decl)))) {
- error(where, "cant.access.class", def);
- return true; // return false later
- }
- } catch (AmbiguousClass ee) {
- error(where, "ambig.class", ee.name1, ee.name2);
- return false;
- } catch (ClassNotFound e) {
- // For now, report "class.and.package" only when the code
- // is going to fail anyway.
- try {
- if (e.name.isInner() &&
- getPackage(e.name.getTopName()).exists()) {
- env.error(where, "class.and.package",
- e.name.getTopName());
- }
- } catch (IOException ee) {
- env.error(where, "io.exception", "package check");
- }
- error(where, "class.not.found", e.name, "type name");
- return false;
- }
- return true;
- }
-
- /**
- * Like 'getClassDefinition(env)', but check access on each component.
- * Currently called only by 'resolve' above. It is doubtful that calls
- * to 'getClassDefinition(env)' are appropriate now.
- */
- public final ClassDefinition
- getQualifiedClassDefinition(long where,
- Identifier nm,
- ClassDefinition ctxClass,
- boolean isExtends) throws ClassNotFound {
- if (nm.isInner()) {
- ClassDefinition c = getClassDefinition(nm.getTopName());
- Identifier tail = nm.getFlatName();
- walkTail:
- while (tail.isQualified()) {
- tail = tail.getTail();
- Identifier head = tail.getHead();
- // System.out.println("CLASS: " + c + " HEAD: " + head + " TAIL: " + tail);
- String hname = head.toString();
- // Handle synthesized names of local and anonymous classes.
- // See 'getClassDefinition(env)' above.
- if (hname.length() > 0
- && Character.isDigit(hname.charAt(0))) {
- ClassDefinition localClass = c.getLocalClass(hname);
- if (localClass != null) {
- c = localClass;
- continue walkTail;
- }
- } else {
- for (MemberDefinition f = c.getFirstMatch(head);
- f != null; f = f.getNextMatch()) {
- if (f.isInnerClass()) {
- ClassDeclaration rdecl = c.getClassDeclaration();
- c = f.getInnerClass();
- ClassDeclaration fdecl = c.getClassDeclaration();
- // This check is presumably applicable even if the
- // original source-code name (expanded by 'resolveNames')
- // was a simple, unqualified name. Hopefully, JLS 2e
- // will clarify the matter.
- if ((!isExtends
- && !ctxClass.canAccess(env, fdecl))
- ||
- (isExtends
- && !ctxClass.extendsCanAccess(env, fdecl))) {
- // Reported error location is imprecise.
- env.error(where, "no.type.access", head, rdecl, ctxClass);
- }
- // The JLS 6.6.2 restrictions on access to protected members
- // depend in an essential way upon the syntactic form of the name.
- // Since the compiler has previously expanded the class names
- // here into fully-qualified form ('resolveNames'), this check
- // cannot be performed here. Unfortunately, the original names
- // are clobbered during 'basicCheck', which is also the phase that
- // resolves the inheritance structure, required to implement the
- // access restrictions. Pending a large-scale revision of the
- // name-resolution machinery, we forgo this check, with the result
- // that the JLS 6.6.2 restrictions are not enforced for some cases
- // of qualified access to inner classes. Some qualified names are
- // resolved elsewhere via a different mechanism, and will be
- // treated correctly -- see 'FieldExpression.checkCommon'.
- /*---------------------------------------*
- if (f.isProtected()) {
- Type rty = Type.tClass(rdecl.getName()); // hack
- if (!ctxClass.protectedAccess(env, f, rty)) {
- // Reported error location is imprecise.
- env.error(where, "invalid.protected.type.use",
- head, ctxClass, rty);
- }
- }
- *---------------------------------------*/
- continue walkTail;
- }
- }
- }
- throw new ClassNotFound(Identifier.lookupInner(c.getName(), head));
- }
- //System.out.println("FOUND " + c + " FOR " + nm);
- return c;
- }
- return getClassDeclaration(nm).getClassDefinition(this);
- }
-
- /**
- * Resolve the names within a type, returning the adjusted type.
- * Adjust class names to reflect scoping.
- * Do not report errors.
- *
- * NOTE: It would be convenient to check for errors here, such as
- * verifying that each component of a qualified name exists and is
- * accessible. Why must this be done in a separate phase?
- *
- * If the 'synth' argument is true, indicating that the member whose
- * type is being resolved is synthetic, names are resolved with respect
- * to the package scope. (Fix for 4097882)
- */
- public Type resolveNames(ClassDefinition c, Type t, boolean synth) {
- if (tracing) dtEvent("Environment.resolveNames: " + c + ", " + t);
- switch (t.getTypeCode()) {
- case TC_CLASS: {
- Identifier name = t.getClassName();
- Identifier rname;
- if (synth) {
- rname = resolvePackageQualifiedName(name);
- } else {
- rname = c.resolveName(this, name);
- }
- if (name != rname) {
- t = Type.tClass(rname);
- }
- break;
- }
-
- case TC_ARRAY:
- t = Type.tArray(resolveNames(c, t.getElementType(), synth));
- break;
-
- case TC_METHOD: {
- Type ret = t.getReturnType();
- Type rret = resolveNames(c, ret, synth);
- Type args[] = t.getArgumentTypes();
- Type rargs[] = new Type[args.length];
- boolean changed = (ret != rret);
- for (int i = args.length ; i-- > 0 ; ) {
- Type arg = args[i];
- Type rarg = resolveNames(c, arg, synth);
- rargs[i] = rarg;
- if (arg != rarg) {
- changed = true;
- }
- }
- if (changed) {
- t = Type.tMethod(rret, rargs);
- }
- break;
- }
- }
- return t;
- }
-
- /**
- * Resolve a class name, using only package and import directives.
- * Report no errors.
- *
- */
- public Identifier resolveName(Identifier name) {
- // This logic is pretty exactly parallel to that of
- // ClassDefinition.resolveName().
- if (name.isQualified()) {
- // Try to resolve the first identifier component,
- // because inner class names take precedence over
- // package prefixes. (Cf. ClassDefinition.resolveName.)
- Identifier rhead = resolveName(name.getHead());
-
- if (rhead.hasAmbigPrefix()) {
- // The first identifier component refers to an
- // ambiguous class. Limp on. We throw away the
- // rest of the classname as it is irrelevant.
- // (part of solution for 4059855).
- return rhead;
- }
-
- if (!this.classExists(rhead)) {
- return this.resolvePackageQualifiedName(name);
- }
- try {
- return this.getClassDefinition(rhead).
- resolveInnerClass(this, name.getTail());
- } catch (ClassNotFound ee) {
- // return partially-resolved name someone else can fail on
- return Identifier.lookupInner(rhead, name.getTail());
- }
- }
- try {
- return resolve(name);
- } catch (AmbiguousClass ee) {
- // Don't force a resolution of the name if it is ambiguous.
- // Forcing the resolution would tack the current package
- // name onto the front of the class, which would be wrong.
- // Instead, mark the name as ambiguous and let a later stage
- // find the error by calling env.resolve(name).
- // (part of solution for 4059855).
-
- if (name.hasAmbigPrefix()) {
- return name;
- } else {
- return name.addAmbigPrefix();
- }
- } catch (ClassNotFound ee) {
- // last chance to make something halfway sensible
- Imports imports = getImports();
- if (imports != null)
- return imports.forceResolve(this, name);
- }
- return name;
- }
-
- /**
- * Discover if name consists of a package prefix, followed by the
- * name of a class (that actually exists), followed possibly by
- * some inner class names. If we can't find a class that exists,
- * return the name unchanged.
- *
- * This routine is used after a class name fails to
- * be resolved by means of imports or inner classes.
- * However, import processing uses this routine directly,
- * since import names must be exactly qualified to start with.
- */
- public final Identifier resolvePackageQualifiedName(Identifier name) {
- Identifier tail = null;
- for (;;) {
- if (classExists(name)) {
- break;
- }
- if (!name.isQualified()) {
- name = (tail == null) ? name : Identifier.lookup(name, tail);
- tail = null;
- break;
- }
- Identifier nm = name.getName();
- tail = (tail == null)? nm: Identifier.lookup(nm, tail);
- name = name.getQualifier();
- }
- if (tail != null)
- name = Identifier.lookupInner(name, tail);
- return name;
- }
-
- /**
- * Resolve a class name, using only package and import directives.
- */
- public Identifier resolve(Identifier nm) throws ClassNotFound {
- if (env == null) return nm; // a pretty useless no-op
- return env.resolve(nm);
- }
-
- /**
- * Get the imports used to resolve class names.
- */
- public Imports getImports() {
- if (env == null) return null; // lame default
- return env.getImports();
- }
-
- /**
- * Create a new class.
- */
- public ClassDefinition makeClassDefinition(Environment origEnv, long where,
- IdentifierToken name,
- String doc, int modifiers,
- IdentifierToken superClass,
- IdentifierToken interfaces[],
- ClassDefinition outerClass) {
- if (env == null) return null; // lame default
- return env.makeClassDefinition(origEnv, where, name,
- doc, modifiers,
- superClass, interfaces, outerClass);
- }
-
- /**
- * Create a new field.
- */
- public MemberDefinition makeMemberDefinition(Environment origEnv, long where,
- ClassDefinition clazz,
- String doc, int modifiers,
- Type type, Identifier name,
- IdentifierToken argNames[],
- IdentifierToken expIds[],
- Object value) {
- if (env == null) return null; // lame default
- return env.makeMemberDefinition(origEnv, where, clazz, doc, modifiers,
- type, name, argNames, expIds, value);
- }
-
- /**
- * Returns true if the given method is applicable to the given arguments
- */
-
- public boolean isApplicable(MemberDefinition m, Type args[]) throws ClassNotFound {
- Type mType = m.getType();
- if (!mType.isType(TC_METHOD))
- return false;
- Type mArgs[] = mType.getArgumentTypes();
- if (args.length != mArgs.length)
- return false;
- for (int i = args.length ; --i >= 0 ;)
- if (!isMoreSpecific(args[i], mArgs[i]))
- return false;
- return true;
- }
-
-
- /**
- * Returns true if "best" is in every argument at least as good as "other"
- */
- public boolean isMoreSpecific(MemberDefinition best, MemberDefinition other)
- throws ClassNotFound {
- Type bestType = best.getClassDeclaration().getType();
- Type otherType = other.getClassDeclaration().getType();
- boolean result = isMoreSpecific(bestType, otherType)
- && isApplicable(other, best.getType().getArgumentTypes());
- // System.out.println("isMoreSpecific: " + best + "/" + other
- // + " => " + result);
- return result;
- }
-
- /**
- * Returns true if "from" is a more specific type than "to"
- */
-
- public boolean isMoreSpecific(Type from, Type to) throws ClassNotFound {
- return implicitCast(from, to);
- }
-
- /**
- * Return true if an implicit cast from this type to
- * the given type is allowed.
- */
- @SuppressWarnings("fallthrough")
- public boolean implicitCast(Type from, Type to) throws ClassNotFound {
- if (from == to)
- return true;
-
- int toTypeCode = to.getTypeCode();
-
- switch(from.getTypeCode()) {
- case TC_BYTE:
- if (toTypeCode == TC_SHORT)
- return true;
- case TC_SHORT:
- case TC_CHAR:
- if (toTypeCode == TC_INT) return true;
- case TC_INT:
- if (toTypeCode == TC_LONG) return true;
- case TC_LONG:
- if (toTypeCode == TC_FLOAT) return true;
- case TC_FLOAT:
- if (toTypeCode == TC_DOUBLE) return true;
- case TC_DOUBLE:
- default:
- return false;
-
- case TC_NULL:
- return to.inMask(TM_REFERENCE);
-
- case TC_ARRAY:
- if (!to.isType(TC_ARRAY)) {
- return (to == Type.tObject || to == Type.tCloneable
- || to == Type.tSerializable);
- } else {
- // both are arrays. recurse down both until one isn't an array
- do {
- from = from.getElementType();
- to = to.getElementType();
- } while (from.isType(TC_ARRAY) && to.isType(TC_ARRAY));
- if ( from.inMask(TM_ARRAY|TM_CLASS)
- && to.inMask(TM_ARRAY|TM_CLASS)) {
- return isMoreSpecific(from, to);
- } else {
- return (from.getTypeCode() == to.getTypeCode());
- }
- }
-
- case TC_CLASS:
- if (toTypeCode == TC_CLASS) {
- ClassDefinition fromDef = getClassDefinition(from);
- ClassDefinition toDef = getClassDefinition(to);
- return toDef.implementedBy(this,
- fromDef.getClassDeclaration());
- } else {
- return false;
- }
- }
- }
-
-
- /**
- * Return true if an explicit cast from this type to
- * the given type is allowed.
- */
- public boolean explicitCast(Type from, Type to) throws ClassNotFound {
- if (implicitCast(from, to)) {
- return true;
- }
- if (from.inMask(TM_NUMBER)) {
- return to.inMask(TM_NUMBER);
- }
- if (from.isType(TC_CLASS) && to.isType(TC_CLASS)) {
- ClassDefinition fromClass = getClassDefinition(from);
- ClassDefinition toClass = getClassDefinition(to);
- if (toClass.isFinal()) {
- return fromClass.implementedBy(this,
- toClass.getClassDeclaration());
- }
- if (fromClass.isFinal()) {
- return toClass.implementedBy(this,
- fromClass.getClassDeclaration());
- }
-
- // The code here used to omit this case. If both types
- // involved in a cast are interfaces, then JLS 5.5 requires
- // that we do a simple test -- make sure none of the methods
- // in toClass and fromClass have the same signature but
- // different return types. (bug number 4028359)
- if (toClass.isInterface() && fromClass.isInterface()) {
- return toClass.couldImplement(fromClass);
- }
-
- return toClass.isInterface() ||
- fromClass.isInterface() ||
- fromClass.superClassOf(this, toClass.getClassDeclaration());
- }
- if (to.isType(TC_ARRAY)) {
- if (from.isType(TC_ARRAY)) {
- Type t1 = from.getElementType();
- Type t2 = to.getElementType();
- while ((t1.getTypeCode() == TC_ARRAY)
- && (t2.getTypeCode() == TC_ARRAY)) {
- t1 = t1.getElementType();
- t2 = t2.getElementType();
- }
- if (t1.inMask(TM_ARRAY|TM_CLASS) &&
- t2.inMask(TM_ARRAY|TM_CLASS)) {
- return explicitCast(t1, t2);
- }
- } else if (from == Type.tObject || from == Type.tCloneable
- || from == Type.tSerializable)
- return true;
- }
- return false;
- }
-
- /**
- * Flags.
- */
- public int getFlags() {
- return env.getFlags();
- }
-
- /**
- * Debugging flags. There used to be a method debug()
- * that has been replaced because -g has changed meaning
- * (it now cooperates with -O and line number, variable
- * range and source file info can be toggled separately).
- */
- public final boolean debug_lines() {
- return (getFlags() & F_DEBUG_LINES) != 0;
- }
- public final boolean debug_vars() {
- return (getFlags() & F_DEBUG_VARS) != 0;
- }
- public final boolean debug_source() {
- return (getFlags() & F_DEBUG_SOURCE) != 0;
- }
-
- /**
- * Optimization flags. There used to be a method optimize()
- * that has been replaced because -O has changed meaning in
- * javac to be replaced with -O and -O:interclass.
- */
- public final boolean opt() {
- return (getFlags() & F_OPT) != 0;
- }
- public final boolean opt_interclass() {
- return (getFlags() & F_OPT_INTERCLASS) != 0;
- }
-
- /**
- * Verbose
- */
- public final boolean verbose() {
- return (getFlags() & F_VERBOSE) != 0;
- }
-
- /**
- * Dump debugging stuff
- */
- public final boolean dump() {
- return (getFlags() & F_DUMP) != 0;
- }
-
- /**
- * Verbose
- */
- public final boolean warnings() {
- return (getFlags() & F_WARNINGS) != 0;
- }
-
- /**
- * Dependencies
- */
- public final boolean dependencies() {
- return (getFlags() & F_DEPENDENCIES) != 0;
- }
-
- /**
- * Print Dependencies to stdout
- */
- public final boolean print_dependencies() {
- return (getFlags() & F_PRINT_DEPENDENCIES) != 0;
- }
-
- /**
- * Deprecation warnings are enabled.
- */
- public final boolean deprecation() {
- return (getFlags() & F_DEPRECATION) != 0;
- }
-
- /**
- * Do not support virtual machines before version 1.2.
- * This option is not supported and is only here for testing purposes.
- */
- public final boolean version12() {
- return (getFlags() & F_VERSION12) != 0;
- }
-
- /**
- * Floating point is strict by default
- */
- public final boolean strictdefault() {
- return (getFlags() & F_STRICTDEFAULT) != 0;
- }
-
- /**
- * Release resources, if any.
- */
- public void shutdown() {
- if (env != null) {
- env.shutdown();
- }
- }
-
- /**
- * Issue an error.
- * source - the input source, usually a file name string
- * offset - the offset in the source of the error
- * err - the error number (as defined in this interface)
- * arg1 - an optional argument to the error (null if not applicable)
- * arg2 - a second optional argument to the error (null if not applicable)
- * arg3 - a third optional argument to the error (null if not applicable)
- */
- public void error(Object source, long where, String err, Object arg1, Object arg2, Object arg3) {
- env.error(source, where, err, arg1, arg2, arg3);
- }
- public final void error(long where, String err, Object arg1, Object arg2, Object arg3) {
- error(source, where, err, arg1, arg2, arg3);
- }
- public final void error(long where, String err, Object arg1, Object arg2) {
- error(source, where, err, arg1, arg2, null);
- }
- public final void error(long where, String err, Object arg1) {
- error(source, where, err, arg1, null, null);
- }
- public final void error(long where, String err) {
- error(source, where, err, null, null, null);
- }
-
- /**
- * Output a string. This can either be an error message or something
- * for debugging. This should be used instead of println.
- */
- public void output(String msg) {
- env.output(msg);
- }
-
- private static boolean debugging = (System.getProperty("javac.debug") != null);
-
- public static void debugOutput(Object msg) {
- if (Environment.debugging)
- System.out.println(msg.toString());
- }
-
- /**
- * set character encoding name
- */
- public void setCharacterEncoding(String encoding) {
- this.encoding = encoding;
- }
-
- /**
- * Return character encoding name
- */
- public String getCharacterEncoding() {
- return encoding;
- }
-
- /**
- * Return major version to use in generated class files.
- */
- public short getMajorVersion() {
- if (env==null) return JAVA_DEFAULT_VERSION; // needed for javah
- return env.getMajorVersion();
- }
-
- /**
- * Return minor version to use in generated class files.
- */
- public short getMinorVersion() {
- if (env==null) return JAVA_DEFAULT_MINOR_VERSION; // needed for javah
- return env.getMinorVersion();
- }
-
-// JCOV
- /**
- * get coverage flag
- */
- public final boolean coverage() {
- return (getFlags() & F_COVERAGE) != 0;
- }
-
- /**
- * get flag of generation the coverage data file
- */
- public final boolean covdata() {
- return (getFlags() & F_COVDATA) != 0;
- }
-
- /**
- * Return the coverage data file
- */
- public File getcovFile() {
- return env.getcovFile();
- }
-
-// end JCOV
-
- /**
- * Debug tracing.
- * Currently, this code is used only for tracing the loading and
- * checking of classes, particularly the demand-driven aspects.
- * This code should probably be integrated with 'debugOutput' above,
- * but we need to give more thought to the issue of classifying debugging
- * messages and allowing those only those of interest to be enabled.
- *
- * Calls to these methods are generally conditioned on the final variable
- * 'Constants.tracing', which allows the calls to be completely omitted
- * in a production release to avoid space and time overhead.
- */
-
- private static boolean dependtrace =
- (System.getProperty("javac.trace.depend") != null);
-
- public void dtEnter(String s) {
- if (dependtrace) System.out.println(">>> " + s);
- }
-
- public void dtExit(String s) {
- if (dependtrace) System.out.println("<<< " + s);
- }
-
- public void dtEvent(String s) {
- if (dependtrace) System.out.println(s);
- }
-
- /**
- * Enable diagnostic dump of class modifier bits, including those
- * in InnerClasses attributes, as they are written to the classfile.
- * In the future, may also enable dumping field and method modifiers.
- */
-
- private static boolean dumpmodifiers =
- (System.getProperty("javac.dump.modifiers") != null);
-
- public boolean dumpModifiers() { return dumpmodifiers; }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/FileClassFile.java b/src/jdk.rmic/share/classes/sun/tools/java/FileClassFile.java
deleted file mode 100644
index df8bb40d4a7..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/FileClassFile.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2014, 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 sun.tools.java;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- * This class is used to represent a file loaded from the class path, and
- * is a regular file.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class FileClassFile extends ClassFile {
- private final File file;
-
- /**
- * Constructor for instance representing a regular file
- */
- public FileClassFile(File file) {
- this.file = file;
- }
-
- @Override
- public boolean isZipped() {
- return false;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return new FileInputStream(file);
- }
-
- @Override
- public boolean exists() {
- return file.exists();
- }
-
- @Override
- public boolean isDirectory() {
- return file.isDirectory();
- }
-
- @Override
- public long lastModified() {
- return file.lastModified();
- }
-
- @Override
- public String getPath() {
- return file.getPath();
- }
-
- @Override
- public String getName() {
- return file.getName();
- }
-
-//JCOV
- @Override
- public String getAbsoluteName() {
- String absoluteName;
- try {
- absoluteName = file.getCanonicalPath();
- } catch (IOException e) {
- absoluteName = file.getAbsolutePath();
- }
- return absoluteName;
- }
-// end JCOV
-
- @Override
- public long length() {
- return file.length();
- }
-
- @Override
- public String toString() {
- return file.toString();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Identifier.java b/src/jdk.rmic/share/classes/sun/tools/java/Identifier.java
deleted file mode 100644
index ff29b2de89e..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Identifier.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-import java.util.Hashtable;
-import java.io.PrintStream;
-import java.util.Enumeration;
-
-/**
- * A class to represent identifiers.
- *
- * An identifier instance is very similar to a String. The difference
- * is that identifier can't be instanciated directly, instead they are
- * looked up in a hash table. This means that identifiers with the same
- * name map to the same identifier object. This makes comparisons of
- * identifiers much faster.
- *
- * A lot of identifiers are qualified, that is they have '.'s in them.
- * Each qualified identifier is chopped up into the qualifier and the
- * name. The qualifier is cached in the value field.
- *
- * Unqualified identifiers can have a type. This type is an integer that
- * can be used by a scanner as a token value. This value has to be set
- * using the setType method.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-public final
-class Identifier implements Constants {
- /**
- * The hashtable of identifiers
- */
- static Hashtable hash = new Hashtable<>(3001, 0.5f);
-
- /**
- * The name of the identifier
- */
- String name;
-
- /**
- * The value of the identifier, for keywords this is an
- * instance of class Integer, for qualified names this is
- * another identifier (the qualifier).
- */
- Object value;
-
- /**
- * The Type which corresponds to this Identifier. This is used as
- * cache for Type.tClass() and shouldn't be used outside of that
- * context.
- */
- Type typeObject = null;
-
- /**
- * The index of INNERCLASS_PREFIX in the name, or -1 if none.
- */
- private int ipos;
-
- /**
- * Construct an identifier. Don't call this directly,
- * use lookup instead.
- * @see Identifier.lookup
- */
- private Identifier(String name) {
- this.name = name;
- this.ipos = name.indexOf(INNERCLASS_PREFIX);
- }
-
- /**
- * Get the type of the identifier.
- */
- int getType() {
- return ((value != null) && (value instanceof Integer)) ?
- ((Integer)value).intValue() : IDENT;
- }
-
- /**
- * Set the type of the identifier.
- */
- void setType(int t) {
- value = t;
- //System.out.println("type(" + this + ")=" + t);
- }
-
- /**
- * Lookup an identifier.
- */
- public static synchronized Identifier lookup(String s) {
- //System.out.println("lookup(" + s + ")");
- Identifier id = hash.get(s);
- if (id == null) {
- hash.put(s, id = new Identifier(s));
- }
- return id;
- }
-
- /**
- * Lookup a qualified identifier.
- */
- public static Identifier lookup(Identifier q, Identifier n) {
- // lookup("", x) => x
- if (q == idNull) return n;
- // lookup(lookupInner(c, ""), n) => lookupInner(c, lookup("", n))
- if (q.name.charAt(q.name.length()-1) == INNERCLASS_PREFIX)
- return lookup(q.name+n.name);
- Identifier id = lookup(q + "." + n);
- if (!n.isQualified() && !q.isInner())
- id.value = q;
- return id;
- }
-
- /**
- * Lookup an inner identifier.
- * (Note: n can be idNull.)
- */
- public static Identifier lookupInner(Identifier c, Identifier n) {
- Identifier id;
- if (c.isInner()) {
- if (c.name.charAt(c.name.length()-1) == INNERCLASS_PREFIX)
- id = lookup(c.name+n);
- else
- id = lookup(c, n);
- } else {
- id = lookup(c + "." + INNERCLASS_PREFIX + n);
- }
- id.value = c.value;
- return id;
- }
-
- /**
- * Convert to a string.
- */
- public String toString() {
- return name;
- }
-
- /**
- * Check if the name is qualified (ie: it contains a '.').
- */
- public boolean isQualified() {
- if (value == null) {
- int idot = ipos;
- if (idot <= 0)
- idot = name.length();
- else
- idot -= 1; // back up over previous dot
- int index = name.lastIndexOf('.', idot-1);
- value = (index < 0) ? idNull : Identifier.lookup(name.substring(0, index));
- }
- return (value instanceof Identifier) && (value != idNull);
- }
-
- /**
- * Return the qualifier. The null identifier is returned if
- * the name was not qualified. The qualifier does not include
- * any inner part of the name.
- */
- public Identifier getQualifier() {
- return isQualified() ? (Identifier)value : idNull;
- }
-
- /**
- * Return the unqualified name.
- * In the case of an inner name, the unqualified name
- * will itself contain components.
- */
- public Identifier getName() {
- return isQualified() ?
- Identifier.lookup(name.substring(((Identifier)value).name.length() + 1)) : this;
- }
-
- /** A space character, which precedes the first inner class
- * name in a qualified name, and thus marks the qualification
- * as involving inner classes, instead of merely packages.
- * Ex: {@code java.util.Vector. Enumerator}.
- */
- public static final char INNERCLASS_PREFIX = ' ';
-
- /* Explanation:
- * Since much of the compiler's low-level name resolution code
- * operates in terms of Identifier objects. This includes the
- * code which walks around the file system and reports what
- * classes are where. It is important to get nesting information
- * right as early as possible, since it affects the spelling of
- * signatures. Thus, the low-level import and resolve code must
- * be able Identifier type must be able to report the nesting
- * of types, which implied that that information must be carried
- * by Identifiers--or that the low-level interfaces be significantly
- * changed.
- */
-
- /**
- * Check if the name is inner (ie: it contains a ' ').
- */
- public boolean isInner() {
- return (ipos > 0);
- }
-
- /**
- * Return the class name, without its qualifier,
- * and with any nesting flattened into a new qualfication structure.
- * If the original identifier is inner,
- * the result will be qualified, and can be further
- * decomposed by means of {@code getQualifier} and {@code getName}.
- *
- * For example:
- *
- * Identifier id = Identifier.lookup("pkg.Foo. Bar");
- * id.getName().name => "Foo. Bar"
- * id.getFlatName().name => "Foo.Bar"
- *
- */
- public Identifier getFlatName() {
- if (isQualified()) {
- return getName().getFlatName();
- }
- if (ipos > 0 && name.charAt(ipos-1) == '.') {
- if (ipos+1 == name.length()) {
- // last component is idNull
- return Identifier.lookup(name.substring(0,ipos-1));
- }
- String n = name.substring(ipos+1);
- String t = name.substring(0,ipos);
- return Identifier.lookup(t+n);
- }
- // Not inner. Just return the same as getName()
- return this;
- }
-
- public Identifier getTopName() {
- if (!isInner()) return this;
- return Identifier.lookup(getQualifier(), getFlatName().getHead());
- }
-
- /**
- * Yet another way to slice qualified identifiers:
- * The head of an identifier is its first qualifier component,
- * and the tail is the rest of them.
- */
- public Identifier getHead() {
- Identifier id = this;
- while (id.isQualified())
- id = id.getQualifier();
- return id;
- }
-
- /**
- * @see getHead
- */
- public Identifier getTail() {
- Identifier id = getHead();
- if (id == this)
- return idNull;
- else
- return Identifier.lookup(name.substring(id.name.length() + 1));
- }
-
- // Unfortunately, the current structure of the compiler requires
- // that the resolveName() family of methods (which appear in
- // Environment.java, Context.java, and ClassDefinition.java) raise
- // no exceptions and emit no errors. When we are in resolveName()
- // and we find a method that is ambiguous, we need to
- // unambiguously mark it as such, so that later stages of the
- // compiler realize that they should give an ambig.class rather than
- // a class.not.found error. To mark it we add a special prefix
- // which cannot occur in the program source. The routines below
- // are used to check, add, and remove this prefix.
- // (part of solution for 4059855).
-
- /**
- * A special prefix to add to ambiguous names.
- */
- private static final String ambigPrefix = "<>";
-
- /**
- * Determine whether an Identifier has been marked as ambiguous.
- */
- public boolean hasAmbigPrefix() {
- return (name.startsWith(ambigPrefix));
- }
-
- /**
- * Add ambigPrefix to `this' to make a new Identifier marked as
- * ambiguous. It is important that this new Identifier not refer
- * to an existing class.
- */
- public Identifier addAmbigPrefix() {
- return Identifier.lookup(ambigPrefix + name);
- }
-
- /**
- * Remove the ambigPrefix from `this' to get the original identifier.
- */
- public Identifier removeAmbigPrefix() {
- if (hasAmbigPrefix()) {
- return Identifier.lookup(name.substring(ambigPrefix.length()));
- } else {
- return this;
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/IdentifierToken.java b/src/jdk.rmic/share/classes/sun/tools/java/IdentifierToken.java
deleted file mode 100644
index 056686ba158..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/IdentifierToken.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, 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 sun.tools.java;
-
-/**
- * Information about the occurrence of an identifier.
- * The parser produces these to represent name which cannot yet be
- * bound to field definitions.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @see
- */
-
-public
-class IdentifierToken {
- long where;
- int modifiers;
- Identifier id;
-
- public IdentifierToken(long where, Identifier id) {
- this.where = where;
- this.id = id;
- }
-
- /** Use this constructor when the identifier is synthesized.
- * The location will be 0.
- */
- public IdentifierToken(Identifier id) {
- this.where = 0;
- this.id = id;
- }
-
- public IdentifierToken(long where, Identifier id, int modifiers) {
- this.where = where;
- this.id = id;
- this.modifiers = modifiers;
- }
-
- /** The source location of this identifier occurrence. */
- public long getWhere() {
- return where;
- }
-
- /** The identifier itself (possibly qualified). */
- public Identifier getName() {
- return id;
- }
-
- /** The modifiers associated with the occurrence, if any. */
- public int getModifiers() {
- return modifiers;
- }
-
- public String toString() {
- return id.toString();
- }
-
- /**
- * Return defaultWhere if id is null or id.where is missing (0).
- * Otherwise, return id.where.
- */
- public static long getWhere(IdentifierToken id, long defaultWhere) {
- return (id != null && id.where != 0) ? id.where : defaultWhere;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Imports.java b/src/jdk.rmic/share/classes/sun/tools/java/Imports.java
deleted file mode 100644
index e2b038bdb58..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Imports.java
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (c) 1994, 2003, 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 sun.tools.java;
-
-import java.util.Hashtable;
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Collections;
-import java.io.IOException;
-
-/**
- * This class describes the classes and packages imported
- * from a source file. A Hashtable called bindings is maintained
- * to quickly map symbol names to classes. This table is flushed
- * everytime a new import is added.
- *
- * A class name is resolved as follows:
- * - if it is a qualified name then return the corresponding class
- * - if the name corresponds to an individually imported class then return that class
- * - check if the class is defined in any of the imported packages,
- * if it is then return it, make sure it is defined in only one package
- * - assume that the class is defined in the current package
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-public
-class Imports implements Constants {
- /**
- * The current package, which is implicitly imported,
- * and has precedence over other imported packages.
- */
- Identifier currentPackage = idNull;
-
- /**
- * A location for the current package declaration. Used to
- * report errors against the current package.
- */
- long currentPackageWhere = 0;
-
- /**
- * The imported classes, including memoized imports from packages.
- */
- Hashtable classes = new Hashtable<>();
-
- /**
- * The imported package identifiers. This will not contain duplicate
- * imports for the same package. It will also not contain the
- * current package.
- */
- Vector packages = new Vector<>();
-
- /**
- * The (originally) imported classes.
- * A vector of IdentifierToken.
- */
- Vector singles = new Vector<>();
-
- /**
- * Are the import names checked yet?
- */
- protected int checked;
-
- /**
- * Constructor, always import java.lang.
- */
- public Imports(Environment env) {
- addPackage(idJavaLang);
- }
-
- /**
- * Check the names of the imports.
- */
- public synchronized void resolve(Environment env) {
- if (checked != 0) {
- return;
- }
- checked = -1;
-
- // After all class information has been read, now we can
- // safely inspect import information for errors.
- // If we did this before all parsing was finished,
- // we could get vicious circularities, since files can
- // import each others' classes.
-
- // A note: the resolution of the package java.lang takes place
- // in the sun.tools.javac.BatchEnvironment#setExemptPackages().
-
- // Make sure that the current package's name does not collide
- // with the name of an existing class. (bug 4101529)
- //
- // This change has been backed out because, on WIN32, it
- // failed to distinguish between java.awt.event and
- // java.awt.Event when looking for a directory. We will
- // add this back in later.
- //
- // if (currentPackage != idNull) {
- // Identifier resolvedName =
- // env.resolvePackageQualifiedName(currentPackage);
- //
- // Identifier className = resolvedName.getTopName();
- //
- // if (importable(className, env)) {
- // // The name of the current package is also the name
- // // of a class.
- // env.error(currentPackageWhere, "package.class.conflict",
- // currentPackage, className);
- // }
- // }
-
- Vector resolvedPackages = new Vector<>();
- for (Enumeration e = packages.elements() ; e.hasMoreElements() ;) {
- IdentifierToken t = e.nextElement();
- Identifier nm = t.getName();
- long where = t.getWhere();
-
- // Check to see if this package is exempt from the "exists"
- // check. See the note in
- // sun.tools.javac.BatchEnvironment#setExemptPackages()
- // for more information.
- if (env.isExemptPackage(nm)) {
- resolvedPackages.addElement(t);
- continue;
- }
-
- // (Note: This code is moved from BatchParser.importPackage().)
- try {
- Identifier rnm = env.resolvePackageQualifiedName(nm);
- if (importable(rnm, env)) {
- // This name is a real class; better not be a package too.
- if (env.getPackage(rnm.getTopName()).exists()) {
- env.error(where, "class.and.package",
- rnm.getTopName());
- }
- // Pass an "inner" name to the imports.
- if (!rnm.isInner())
- rnm = Identifier.lookupInner(rnm, idNull);
- nm = rnm;
- } else if (!env.getPackage(nm).exists()) {
- env.error(where, "package.not.found", nm, "import");
- } else if (rnm.isInner()) {
- // nm exists, and rnm.getTopName() is a parent package
- env.error(where, "class.and.package", rnm.getTopName());
- }
- resolvedPackages.addElement(new IdentifierToken(where, nm));
- } catch (IOException ee) {
- env.error(where, "io.exception", "import");
- }
- }
- packages = resolvedPackages;
-
- for (Enumeration e = singles.elements() ; e.hasMoreElements() ;) {
- IdentifierToken t = e.nextElement();
- Identifier nm = t.getName();
- long where = t.getWhere();
- Identifier pkg = nm.getQualifier();
-
- // (Note: This code is moved from BatchParser.importClass().)
- nm = env.resolvePackageQualifiedName(nm);
- if (!env.classExists(nm.getTopName())) {
- env.error(where, "class.not.found", nm, "import");
- }
-
- // (Note: This code is moved from Imports.addClass().)
- Identifier snm = nm.getFlatName().getName();
-
- // make sure it isn't already imported explicitly
- Identifier className = classes.get(snm);
- if (className != null) {
- Identifier f1 = Identifier.lookup(className.getQualifier(),
- className.getFlatName());
- Identifier f2 = Identifier.lookup(nm.getQualifier(),
- nm.getFlatName());
- if (!f1.equals(f2)) {
- env.error(where, "ambig.class", nm, className);
- }
- }
- classes.put(snm, nm);
-
-
- // The code here needs to check to see, if we
- // are importing an inner class, that all of its
- // enclosing classes are visible to us. To check this,
- // we need to construct a definition for the class.
- // The code here used to call...
- //
- // ClassDefinition def = env.getClassDefinition(nm);
- //
- // ...but that interfered with the basicCheck()'ing of
- // interfaces in certain cases (bug no. 4086139). Never
- // fear. Instead we load the class with a call to the
- // new getClassDefinitionNoCheck() which does no basicCheck() and
- // lets us answer the questions we are interested in w/o
- // interfering with the demand-driven nature of basicCheck().
-
- try {
- // Get a declaration
- ClassDeclaration decl = env.getClassDeclaration(nm);
-
- // Get the definition (no env argument)
- ClassDefinition def = decl.getClassDefinitionNoCheck(env);
-
- // Get the true name of the package containing this class.
- // `pkg' from above is insufficient. It includes the
- // names of our enclosing classes. Fix for 4086815.
- Identifier importedPackage = def.getName().getQualifier();
-
- // Walk out the outerClass chain, ensuring that each level
- // is visible from our perspective.
- for (; def != null; def = def.getOuterClass()) {
- if (def.isPrivate()
- || !(def.isPublic()
- || importedPackage.equals(currentPackage))) {
- env.error(where, "cant.access.class", def);
- break;
- }
- }
- } catch (AmbiguousClass ee) {
- env.error(where, "ambig.class", ee.name1, ee.name2);
- } catch (ClassNotFound ee) {
- env.error(where, "class.not.found", ee.name, "import");
- }
- }
- checked = 1;
- }
-
- /**
- * Lookup a class, given the current set of imports,
- * AmbiguousClass exception is thrown if the name can be
- * resolved in more than one way. A ClassNotFound exception
- * is thrown if the class is not found in the imported classes
- * and packages.
- */
- public synchronized Identifier resolve(Environment env, Identifier nm) throws ClassNotFound {
- if (tracing) env.dtEnter("Imports.resolve: " + nm);
-
- // If the class has the special ambiguous prefix, then we will
- // get the original AmbiguousClass exception by removing the
- // prefix and proceeding in the normal fashion.
- // (part of solution for 4059855)
- if (nm.hasAmbigPrefix()) {
- nm = nm.removeAmbigPrefix();
- }
-
- if (nm.isQualified()) {
- // Don't bother it is already qualified
- if (tracing) env.dtExit("Imports.resolve: QUALIFIED " + nm);
- return nm;
- }
-
- if (checked <= 0) {
- checked = 0;
- resolve(env);
- }
-
- // Check if it was imported before
- Identifier className = classes.get(nm);
- if (className != null) {
- if (tracing) env.dtExit("Imports.resolve: PREVIOUSLY IMPORTED " + nm);
- return className;
- }
-
- // Note: the section below has changed a bit during the fix
- // for bug 4093217. The current package is no longer grouped
- // with the rest of the import-on-demands; it is now checked
- // separately. Also, the list of import-on-demands is now
- // guarranteed to be duplicate-free, so the code below can afford
- // to be a bit simpler.
-
- // First we look in the current package. The current package
- // is given precedence over the rest of the import-on-demands,
- // which means, among other things, that a class in the current
- // package cannot be ambiguous.
- Identifier id = Identifier.lookup(currentPackage, nm);
- if (importable(id, env)) {
- className = id;
- } else {
- // If it isn't in the current package, try to find it in
- // our import-on-demands.
- Enumeration e = packages.elements();
- while (e.hasMoreElements()) {
- IdentifierToken t = e.nextElement();
- id = Identifier.lookup(t.getName(), nm);
-
- if (importable(id, env)) {
- if (className == null) {
- // We haven't found any other matching classes yet.
- // Set className to what we've found and continue
- // looking for an ambiguity.
- className = id;
- } else {
- if (tracing)
- env.dtExit("Imports.resolve: AMBIGUOUS " + nm);
-
- // We've found an ambiguity.
- throw new AmbiguousClass(className, id);
- }
- }
- }
- }
-
- // Make sure a class was found
- if (className == null) {
- if (tracing) env.dtExit("Imports.resolve: NOT FOUND " + nm);
- throw new ClassNotFound(nm);
- }
-
- // Remember the binding
- classes.put(nm, className);
- if (tracing) env.dtExit("Imports.resolve: FIRST IMPORT " + nm);
- return className;
- }
-
- /**
- * Check to see if 'id' names an importable class in `env'.
- * This method was made public and static for utility.
- */
- static public boolean importable(Identifier id, Environment env) {
- if (!id.isInner()) {
- return env.classExists(id);
- } else if (!env.classExists(id.getTopName())) {
- return false;
- } else {
- // load the top class and look inside it
- try {
- // There used to be a call to...
- // env.getClassDeclaration(id.getTopName());
- // ...here. It has been replaced with the
- // two statements below. These should be functionally
- // the same except for the fact that
- // getClassDefinitionNoCheck() does not call
- // basicCheck(). This allows us to avoid a circular
- // need to do basicChecking that can arise with
- // certain patterns of importing and inheritance.
- // This is a fix for a variant of bug 4086139.
- //
- // Note: the special case code in env.getClassDefinition()
- // which handles inner class names is not replicated below.
- // This should be okay, as we are looking up id.getTopName(),
- // not id.
- ClassDeclaration decl =
- env.getClassDeclaration(id.getTopName());
- ClassDefinition c =
- decl.getClassDefinitionNoCheck(env);
-
- return c.innerClassExists(id.getFlatName().getTail());
- } catch (ClassNotFound ee) {
- return false;
- }
- }
- }
-
- /**
- * Suppose a resolve() call has failed.
- * This routine can be used silently to give a reasonable
- * default qualification (the current package) to the identifier.
- * This decision is recorded for future reference.
- */
- public synchronized Identifier forceResolve(Environment env, Identifier nm) {
- if (nm.isQualified())
- return nm;
-
- Identifier className = classes.get(nm);
- if (className != null) {
- return className;
- }
-
- className = Identifier.lookup(currentPackage, nm);
-
- classes.put(nm, className);
- return className;
- }
-
- /**
- * Add a class import
- */
- public synchronized void addClass(IdentifierToken t) {
- singles.addElement(t);
- }
- // for compatibility
- public void addClass(Identifier nm) throws AmbiguousClass {
- addClass(new IdentifierToken(nm));
- }
-
- /**
- * Add a package import, or perhaps an inner class scope.
- * Ignore any duplicate imports.
- */
- public synchronized void addPackage(IdentifierToken t) {
- final Identifier name = t.getName();
-
- // If this is a duplicate import for the current package,
- // ignore it.
- if (name == currentPackage) {
- return;
- }
-
- // If this is a duplicate of a package which has already been
- // added to the list, ignore it.
- final int size = packages.size();
- for (int i = 0; i < size; i++) {
- if (name == (packages.elementAt(i)).getName()) {
- return;
- }
- }
-
- // Add the package to the list.
- packages.addElement(t);
- }
- // for compatibility
- public void addPackage(Identifier id) {
- addPackage(new IdentifierToken(id));
- }
-
- /**
- * Specify the current package with an IdentifierToken.
- */
- public synchronized void setCurrentPackage(IdentifierToken t) {
- currentPackage = t.getName();
- currentPackageWhere = t.getWhere();
- }
-
- /**
- * Specify the current package
- */
- public synchronized void setCurrentPackage(Identifier id) {
- currentPackage = id;
- }
-
- /**
- * Report the current package
- */
- public Identifier getCurrentPackage() {
- return currentPackage;
- }
-
- /**
- * Return an unmodifiable list of IdentifierToken representing
- * packages specified as imports.
- */
- public List getImportedPackages() {
- return Collections.unmodifiableList(packages);
- }
-
- /**
- * Return an unmodifiable list of IdentifierToken representing
- * classes specified as imports.
- */
- public List getImportedClasses() {
- return Collections.unmodifiableList(singles);
- }
-
- /**
- * Extend an environment with my resolve() method.
- */
- public Environment newEnvironment(Environment env) {
- return new ImportEnvironment(env, this);
- }
-}
-
-final
-class ImportEnvironment extends Environment {
- Imports imports;
-
- ImportEnvironment(Environment env, Imports imports) {
- super(env, env.getSource());
- this.imports = imports;
- }
-
- public Identifier resolve(Identifier nm) throws ClassNotFound {
- return imports.resolve(this, nm);
- }
-
- public Imports getImports() {
- return imports;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/MemberDefinition.java b/src/jdk.rmic/share/classes/sun/tools/java/MemberDefinition.java
deleted file mode 100644
index c426e9e66ac..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/MemberDefinition.java
+++ /dev/null
@@ -1,1008 +0,0 @@
-/*
- * Copyright (c) 1994, 2015, 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 sun.tools.java;
-
-import sun.tools.tree.Node;
-import sun.tools.tree.Vset;
-import sun.tools.tree.Expression;
-import sun.tools.tree.Statement;
-import sun.tools.tree.Context;
-import sun.tools.asm.Assembler;
-import java.io.PrintStream;
-import java.util.Vector;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * This class defines a member of a Java class:
- * a variable, a method, or an inner class.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("deprecation")
-public
-class MemberDefinition implements Constants {
- protected long where;
- protected int modifiers;
- protected Type type;
- protected String documentation;
- protected IdentifierToken expIds[];
- protected ClassDeclaration exp[];
- protected Node value;
- protected ClassDefinition clazz;
- protected Identifier name;
- protected ClassDefinition innerClass;
- protected MemberDefinition nextMember;
- protected MemberDefinition nextMatch;
- protected MemberDefinition accessPeer;
- protected boolean superAccessMethod;
-
- /**
- * Constructor
- */
- public MemberDefinition(long where, ClassDefinition clazz, int modifiers,
- Type type, Identifier name,
- IdentifierToken expIds[], Node value) {
- if (expIds == null) {
- expIds = new IdentifierToken[0];
- }
- this.where = where;
- this.clazz = clazz;
- this.modifiers = modifiers;
- this.type = type;
- this.name = name;
- this.expIds = expIds;
- this.value = value;
- }
-
- /**
- * Constructor for an inner class.
- * Inner classes are represented as fields right along with
- * variables and methods for simplicity of data structure,
- * and to reflect properly the textual declaration order.
- *
- * This constructor calls the generic constructor for this
- * class, extracting all necessary values from the innerClass.
- */
- public MemberDefinition(ClassDefinition innerClass) {
- this(innerClass.getWhere(),
- innerClass.getOuterClass(),
- innerClass.getModifiers(),
- innerClass.getType(),
- innerClass.getName().getFlatName().getName(),
- null, null);
- this.innerClass = innerClass;
- }
-
- /**
- * A cache of previously created proxy members. Used to ensure
- * uniqueness of proxy objects. See the makeProxyMember method
- * defined below.
- */
- static private Map proxyCache;
-
- /**
- * Create a member which is externally the same as `field' but
- * is defined in class `classDef'. This is used by code
- * in sun.tools.tree.(MethodExpression,FieldExpression) as
- * part of the fix for bug 4135692.
- *
- * Proxy members should not be added, ala addMember(), to classes.
- * They are merely "stand-ins" to produce modified MethodRef
- * constant pool entries during code generation.
- *
- * We keep a cache of previously created proxy members not to
- * save time or space, but to ensure uniqueness of the proxy
- * member for any (field,classDef) pair. If these are not made
- * unique then we can end up generating duplicate MethodRef
- * constant pool entries during code generation.
- */
- public static MemberDefinition makeProxyMember(MemberDefinition field,
- ClassDefinition classDef,
- Environment env) {
-
- if (proxyCache == null) {
- proxyCache = new HashMap<>();
- }
-
- String key = field.toString() + "@" + classDef.toString();
- // System.out.println("Key is : " + key);
- MemberDefinition proxy = proxyCache.get(key);
-
- if (proxy != null)
- return proxy;
-
- proxy = new MemberDefinition(field.getWhere(), classDef,
- field.getModifiers(), field.getType(),
- field.getName(), field.getExceptionIds(),
- null);
- proxy.exp = field.getExceptions(env);
- proxyCache.put(key, proxy);
-
- return proxy;
- }
-
- /**
- * Get the position in the input
- */
- public final long getWhere() {
- return where;
- }
-
- /**
- * Get the class declaration
- */
- public final ClassDeclaration getClassDeclaration() {
- return clazz.getClassDeclaration();
- }
-
- /**
- * A stub. Subclasses can do more checking.
- */
- public void resolveTypeStructure(Environment env) {
- }
-
- /**
- * Get the class declaration in which the field is actually defined
- */
- public ClassDeclaration getDefiningClassDeclaration() {
- return getClassDeclaration();
- }
-
- /**
- * Get the class definition
- */
- public final ClassDefinition getClassDefinition() {
- return clazz;
- }
-
- /**
- * Get the field's top-level enclosing class
- */
- public final ClassDefinition getTopClass() {
- return clazz.getTopClass();
- }
-
- /**
- * Get the field's modifiers
- */
- public final int getModifiers() {
- return modifiers;
- }
- public final void subModifiers(int mod) {
- modifiers &= ~mod;
- }
- public final void addModifiers(int mod) {
- modifiers |= mod;
- }
-
- /**
- * Get the field's type
- */
- public final Type getType() {
- return type;
- }
-
- /**
- * Get the field's name
- */
- public final Identifier getName() {
- return name;
- }
-
- /**
- * Get arguments (a vector of LocalMember)
- */
- public Vector getArguments() {
- return isMethod() ? new Vector<>() : null;
- }
-
- /**
- * Get the exceptions that are thrown by this method.
- */
- public ClassDeclaration[] getExceptions(Environment env) {
- if (expIds != null && exp == null) {
- if (expIds.length == 0)
- exp = new ClassDeclaration[0];
- else
- // we should have translated this already!
- throw new CompilerError("getExceptions "+this);
- }
- return exp;
- }
-
- public final IdentifierToken[] getExceptionIds() {
- return expIds;
- }
-
- /**
- * Get an inner class.
- */
- public ClassDefinition getInnerClass() {
- return innerClass;
- }
-
- /**
- * Is this a synthetic field which holds a copy of,
- * or reference to, a local variable or enclosing instance?
- */
- public boolean isUplevelValue() {
- if (!isSynthetic() || !isVariable() || isStatic()) {
- return false;
- }
- String name = this.name.toString();
- return name.startsWith(prefixVal)
- || name.startsWith(prefixLoc)
- || name.startsWith(prefixThis);
- }
-
- public boolean isAccessMethod() {
- // This no longer works, because access methods
- // for constructors do not use the standard naming
- // scheme.
- // return isSynthetic() && isMethod()
- // && name.toString().startsWith(prefixAccess);
- // Assume that a method is an access method if it has
- // an access peer. NOTE: An access method will not be
- // recognized as such until 'setAccessMethodTarget' has
- // been called on it.
- return isSynthetic() && isMethod() && (accessPeer != null);
- }
-
- /**
- * Is this a synthetic method which provides access to a
- * visible private member?
- */
- public MemberDefinition getAccessMethodTarget() {
- if (isAccessMethod()) {
- for (MemberDefinition f = accessPeer; f != null; f = f.accessPeer) {
- // perhaps skip over another access for the same field
- if (!f.isAccessMethod()) {
- return f;
- }
- }
- }
- return null;
- }
-
-
- public void setAccessMethodTarget(MemberDefinition target) {
- if (getAccessMethodTarget() != target) {
- /*-------------------*
- if (!isAccessMethod() || accessPeer != null ||
- target.accessPeer != null) {
- throw new CompilerError("accessPeer");
- }
- *-------------------*/
- if (accessPeer != null || target.accessPeer != null) {
- throw new CompilerError("accessPeer");
- }
- accessPeer = target;
- }
- }
-
- /**
- * If this method is a getter for a private field, return the setter.
- */
- public MemberDefinition getAccessUpdateMember() {
- if (isAccessMethod()) {
- for (MemberDefinition f = accessPeer; f != null; f = f.accessPeer) {
- if (f.isAccessMethod()) {
- return f;
- }
- }
- }
- return null;
- }
-
- public void setAccessUpdateMember(MemberDefinition updater) {
- if (getAccessUpdateMember() != updater) {
- if (!isAccessMethod() ||
- updater.getAccessMethodTarget() != getAccessMethodTarget()) {
- throw new CompilerError("accessPeer");
- }
- updater.accessPeer = accessPeer;
- accessPeer = updater;
- }
- }
-
- /**
- * Is this an access method for a field selection or method call
- * of the form '...super.foo' or '...super.foo()'?
- */
- public final boolean isSuperAccessMethod() {
- return superAccessMethod;
- }
-
- /**
- * Mark this member as an access method for a field selection
- * or method call via the 'super' keyword.
- */
- public final void setIsSuperAccessMethod(boolean b) {
- superAccessMethod = b;
- }
-
- /**
- * Tell if this is a final variable without an initializer.
- * Such variables are subject to definite single assignment.
- */
- public final boolean isBlankFinal() {
- return isFinal() && !isSynthetic() && getValue() == null;
- }
-
- public boolean isNeverNull() {
- if (isUplevelValue()) {
- // loc$x and this$C are never null
- return !name.toString().startsWith(prefixVal);
- }
- return false;
- }
-
- /**
- * Get the field's final value (may return null)
- */
- public Node getValue(Environment env) throws ClassNotFound {
- return value;
- }
- public final Node getValue() {
- return value;
- }
- public final void setValue(Node value) {
- this.value = value;
- }
- public Object getInitialValue() {
- return null;
- }
-
- /**
- * Get the next field or the next match
- */
- public final MemberDefinition getNextMember() {
- return nextMember;
- }
- public final MemberDefinition getNextMatch() {
- return nextMatch;
- }
-
- /**
- * Get the field's documentation
- */
- public String getDocumentation() {
- return documentation;
- }
-
- /**
- * Request a check of the field definition.
- */
- public void check(Environment env) throws ClassNotFound {
- }
-
- /**
- * Really check the field definition.
- */
- public Vset check(Environment env, Context ctx, Vset vset) throws ClassNotFound {
- return vset;
- }
-
- /**
- * Generate code
- */
- public void code(Environment env, Assembler asm) throws ClassNotFound {
- throw new CompilerError("code");
- }
- public void codeInit(Environment env, Context ctx, Assembler asm) throws ClassNotFound {
- throw new CompilerError("codeInit");
- }
-
- /**
- * Tells whether to report a deprecation error for this field.
- */
- public boolean reportDeprecated(Environment env) {
- return (isDeprecated() || clazz.reportDeprecated(env));
- }
-
- /**
- * Check if a field can reach another field (only considers
- * forward references, not the access modifiers).
- */
- public final boolean canReach(Environment env, MemberDefinition f) {
- if (f.isLocal() || !f.isVariable() || !(isVariable() || isInitializer()))
- return true;
- if ((getClassDeclaration().equals(f.getClassDeclaration())) &&
- (isStatic() == f.isStatic())) {
- // They are located in the same class, and are either both
- // static or both non-static. Check the initialization order.
- while (((f = f.getNextMember()) != null) && (f != this));
- return f != null;
- }
- return true;
- }
-
- //-----------------------------------------------------------------
- // The code in this section is intended to test certain kinds of
- // compatibility between methods. There are two kinds of compatibility
- // that the compiler may need to test. The first is whether one
- // method can legally override another. The second is whether two
- // method definitions can legally coexist. We use the word `meet'
- // to mean the intersection of two legally coexisting methods.
- // For more information on these kinds of compatibility, see the
- // comments/code for checkOverride() and checkMeet() below.
-
- /**
- * Constants used by getAccessLevel() to represent the access
- * modifiers as numbers.
- */
- static final int PUBLIC_ACCESS = 1;
- static final int PROTECTED_ACCESS = 2;
- static final int PACKAGE_ACCESS = 3;
- static final int PRIVATE_ACCESS = 4;
-
- /**
- * Return the access modifier of this member as a number. The idea
- * is that this number may be used to check properties like "the
- * access modifier of x is more restrictive than the access
- * modifier of y" with a simple inequality test:
- * "x.getAccessLevel() > y.getAccessLevel.
- *
- * This is an internal utility method.
- */
- private int getAccessLevel() {
- // Could just compute this once instead of recomputing.
- // Check to see if this is worth it.
- if (isPublic()) {
- return PUBLIC_ACCESS;
- } else if (isProtected()) {
- return PROTECTED_ACCESS;
- } else if (isPackagePrivate()) {
- return PACKAGE_ACCESS;
- } else if (isPrivate()) {
- return PRIVATE_ACCESS;
- } else {
- throw new CompilerError("getAccessLevel()");
- }
- }
-
- /**
- * Munge our error message to report whether the override conflict
- * came from an inherited method or a declared method.
- */
- private void reportError(Environment env, String errorString,
- ClassDeclaration clazz,
- MemberDefinition method) {
-
- if (clazz == null) {
- // For example:
- // "Instance method BLAH inherited from CLASSBLAH1 cannot be
- // overridden by the static method declared in CLASSBLAH2."
- env.error(getWhere(), errorString,
- this, getClassDeclaration(),
- method.getClassDeclaration());
- } else {
- // For example:
- // "In CLASSBLAH1, instance method BLAH inherited from CLASSBLAH2
- // cannot be overridden by the static method inherited from
- // CLASSBLAH3."
- env.error(clazz.getClassDefinition().getWhere(),
- //"inherit." + errorString,
- errorString,
- //clazz,
- this, getClassDeclaration(),
- method.getClassDeclaration());
- }
- }
-
- /**
- * Convenience method to see if two methods return the same type
- */
- public boolean sameReturnType(MemberDefinition method) {
- // Make sure both are methods.
- if (!isMethod() || !method.isMethod()) {
- throw new CompilerError("sameReturnType: not method");
- }
-
- Type myReturnType = getType().getReturnType();
- Type yourReturnType = method.getType().getReturnType();
-
- return (myReturnType == yourReturnType);
- }
-
- /**
- * Check to see if `this' can override/hide `method'. Caller is
- * responsible for verifying that `method' has the same signature
- * as `this'. Caller is also responsible for verifying that
- * `method' is visible to the class where this override is occurring.
- * This method is called for the case when class B extends A and both
- * A and B define some method.
- *
- * A - void foo() throws e1
- * |
- * |
- * B - void foo() throws e2
- *
- */
- public boolean checkOverride(Environment env, MemberDefinition method) {
- return checkOverride(env, method, null);
- }
-
- /**
- * Checks whether `this' can override `method'. It `clazz' is
- * null, it reports the errors in the class where `this' is
- * declared. If `clazz' is not null, it reports the error in `clazz'.
- */
- private boolean checkOverride(Environment env,
- MemberDefinition method,
- ClassDeclaration clazz) {
- // This section of code is largely based on section 8.4.6.3
- // of the JLS.
-
- boolean success = true;
-
- // Sanity
- if (!isMethod()) {
- throw new CompilerError("checkOverride(), expected method");
- }
-
- // Suppress checks for synthetic methods, as the compiler presumably
- // knows what it is doing, e.g., access methods.
- if (isSynthetic()) {
- // Sanity check: We generally do not intend for one synthetic
- // method to override another, though hiding of static members
- // is expected. This check may need to be changed if new uses
- // of synthetic methods are devised.
- //
- // Query: this code was copied from elsewhere. What
- // exactly is the role of the !isStatic() in the test?
- if (method.isFinal() ||
- (!method.isConstructor() &&
- !method.isStatic() && !isStatic())) {
- ////////////////////////////////////////////////////////////
- // NMG 2003-01-28 removed the following test because it is
- // invalidated by bridge methods inserted by the "generic"
- // (1.5) Java compiler. In 1.5, this code is used,
- // indirectly, by rmic
- ////////////////////////////////////////////////////////////
- // throw new CompilerError("checkOverride() synthetic");
- ////////////////////////////////////////////////////////////
- }
-
- // We trust the compiler. (Ha!) We're done checking.
- return true;
- }
-
- // Our caller should have verified that the method had the
- // same signature.
- if (getName() != method.getName() ||
- !getType().equalArguments(method.getType())) {
-
- throw new CompilerError("checkOverride(), signature mismatch");
- }
-
- // It is forbidden to `override' a static method with an instance
- // method.
- if (method.isStatic() && !isStatic()) {
- reportError(env, "override.static.with.instance", clazz, method);
- success = false;
- }
-
- // It is forbidden to `hide' an instance method with a static
- // method.
- if (!method.isStatic() && isStatic()) {
- reportError(env, "hide.instance.with.static", clazz, method);
- success = false;
- }
-
- // We cannot override a final method.
- if (method.isFinal()) {
- reportError(env, "override.final.method", clazz, method);
- success = false;
- }
-
- // Give a warning when we override a deprecated method with
- // a non-deprecated one.
- //
- // We bend over backwards to suppress this warning if
- // the `method' has not been already compiled or
- // `this' has been already compiled.
- if (method.reportDeprecated(env) && !isDeprecated()
- && this instanceof sun.tools.javac.SourceMember) {
- reportError(env, "warn.override.is.deprecated",
- clazz, method);
- }
-
- // Visibility may not be more restrictive
- if (getAccessLevel() > method.getAccessLevel()) {
- reportError(env, "override.more.restrictive", clazz, method);
- success = false;
- }
-
- // Return type equality
- if (!sameReturnType(method)) {
- ////////////////////////////////////////////////////////////
- // PCJ 2003-07-30 removed the following error because it is
- // invalidated by the covariant return type feature of the
- // 1.5 compiler. The resulting check is now much looser
- // than the actual 1.5 language spec, but that should be OK
- // because this code is only still used by rmic. See 4892308.
- ////////////////////////////////////////////////////////////
- // reportError(env, "override.different.return", clazz, method);
- // success = false;
- ////////////////////////////////////////////////////////////
- }
-
- // Exception agreeement
- if (!exceptionsFit(env, method)) {
- reportError(env, "override.incompatible.exceptions",
- clazz, method);
- success = false;
- }
-
- return success;
- }
-
- /**
- * Check to see if two method definitions are compatible, that is
- * do they have a `meet'. The meet of two methods is essentially
- * and `intersection' of
- * two methods. This method is called when some class C inherits
- * declarations for some method foo from two parents (superclass,
- * interfaces) but it does not, itself, have a declaration of foo.
- * Caller is responsible for making sure that both methods are
- * indeed visible in clazz.
- *
- * A - void foo() throws e1
- * \
- * \ B void foo() throws e2
- * \ /
- * \ /
- * C
- *
- */
- public boolean checkMeet(Environment env,
- MemberDefinition method,
- ClassDeclaration clazz) {
- // This section of code is largely based on Section 8.4.6
- // and 9.4.1 of the JLS.
-
- // Sanity
- if (!isMethod()) {
- throw new CompilerError("checkMeet(), expected method");
- }
-
- // Check for both non-abstract.
- if (!isAbstract() && !method.isAbstract()) {
- throw new CompilerError("checkMeet(), no abstract method");
- }
-
- // If either method is non-abstract, then we need to check that
- // the abstract method can be properly overridden. We call
- // the checkOverride method to check this and generate any errors.
- // This test must follow the previous test.
- else if (!isAbstract()) {
- return checkOverride(env, method, clazz);
- } else if (!method.isAbstract()) {
- return method.checkOverride(env, this, clazz);
- }
-
- // Both methods are abstract.
-
- // Our caller should have verified that the method has the
- // same signature.
- if (getName() != method.getName() ||
- !getType().equalArguments(method.getType())) {
-
- throw new CompilerError("checkMeet(), signature mismatch");
- }
-
- // Check for return type equality
- if (!sameReturnType(method)) {
- // More args?
- env.error(clazz.getClassDefinition().getWhere(),
- "meet.different.return",
- this, this.getClassDeclaration(),
- method.getClassDeclaration());
- return false;
- }
-
- // We don't have to check visibility -- there always
- // potentially exists a meet. Similarly with exceptions.
-
- // There does exist a meet.
- return true;
- }
-
- /**
- * This method is meant to be used to determine if one of two inherited
- * methods could override the other. Unlike checkOverride(), failure
- * is not an error. This method is only meant to be called after
- * checkMeet() has succeeded on the two methods.
- *
- * If you call couldOverride() without doing a checkMeet() first, then
- * you are on your own.
- */
- public boolean couldOverride(Environment env,
- MemberDefinition method) {
-
- // Sanity
- if (!isMethod()) {
- throw new CompilerError("coulcOverride(), expected method");
- }
-
- // couldOverride() is only called with `this' and `method' both
- // being inherited methods. Neither of them is defined in the
- // class which we are currently working on. Even though an
- // abstract method defined *in* a class can override a non-abstract
- // method defined in a superclass, an abstract method inherited
- // from an interface *never* can override a non-abstract method.
- // This comment may sound odd, but that's the way inheritance is.
- // The following check makes sure we aren't trying to override
- // an inherited non-abstract definition with an abstract definition
- // from an interface.
- if (!method.isAbstract()) {
- return false;
- }
-
- // Visibility should be less restrictive
- if (getAccessLevel() > method.getAccessLevel()) {
- return false;
- }
-
- // Exceptions
- if (!exceptionsFit(env, method)) {
- return false;
- }
-
- // Potentially some deprecation warnings could be given here
- // when we merge two abstract methods, one of which is deprecated.
- // This is not currently reported.
-
- return true;
- }
-
- /**
- * Check to see if the exceptions of `this' fit within the
- * exceptions of `method'.
- */
- private boolean exceptionsFit(Environment env,
- MemberDefinition method) {
- ClassDeclaration e1[] = getExceptions(env); // my exceptions
- ClassDeclaration e2[] = method.getExceptions(env); // parent's
-
- // This code is taken nearly verbatim from the old implementation
- // of checkOverride() in SourceClass.
- outer:
- for (int i = 0 ; i < e1.length ; i++) {
- try {
- ClassDefinition c1 = e1[i].getClassDefinition(env);
- for (int j = 0 ; j < e2.length ; j++) {
- if (c1.subClassOf(env, e2[j])) {
- continue outer;
- }
- }
- if (c1.subClassOf(env,
- env.getClassDeclaration(idJavaLangError)))
- continue outer;
- if (c1.subClassOf(env,
- env.getClassDeclaration(idJavaLangRuntimeException)))
- continue outer;
-
- // the throws was neither something declared by a parent,
- // nor one of the ignorables.
- return false;
-
- } catch (ClassNotFound ee) {
- // We were unable to find one of the exceptions.
- env.error(getWhere(), "class.not.found",
- ee.name, method.getClassDeclaration());
- }
- }
-
- // All of the exceptions `fit'.
- return true;
- }
-
- //-----------------------------------------------------------------
-
- /**
- * Checks
- */
- public final boolean isPublic() {
- return (modifiers & M_PUBLIC) != 0;
- }
- public final boolean isPrivate() {
- return (modifiers & M_PRIVATE) != 0;
- }
- public final boolean isProtected() {
- return (modifiers & M_PROTECTED) != 0;
- }
- public final boolean isPackagePrivate() {
- return (modifiers & (M_PUBLIC | M_PRIVATE | M_PROTECTED)) == 0;
- }
- public final boolean isFinal() {
- return (modifiers & M_FINAL) != 0;
- }
- public final boolean isStatic() {
- return (modifiers & M_STATIC) != 0;
- }
- public final boolean isSynchronized() {
- return (modifiers & M_SYNCHRONIZED) != 0;
- }
- public final boolean isAbstract() {
- return (modifiers & M_ABSTRACT) != 0;
- }
- public final boolean isNative() {
- return (modifiers & M_NATIVE) != 0;
- }
- public final boolean isVolatile() {
- return (modifiers & M_VOLATILE) != 0;
- }
- public final boolean isTransient() {
- return (modifiers & M_TRANSIENT) != 0;
- }
- public final boolean isMethod() {
- return type.isType(TC_METHOD);
- }
- public final boolean isVariable() {
- return !type.isType(TC_METHOD) && innerClass == null;
- }
- public final boolean isSynthetic() {
- return (modifiers & M_SYNTHETIC) != 0;
- }
- public final boolean isDeprecated() {
- return (modifiers & M_DEPRECATED) != 0;
- }
- public final boolean isStrict() {
- return (modifiers & M_STRICTFP) != 0;
- }
- public final boolean isInnerClass() {
- return innerClass != null;
- }
- public final boolean isInitializer() {
- return getName().equals(idClassInit);
- }
- public final boolean isConstructor() {
- return getName().equals(idInit);
- }
- public boolean isLocal() {
- return false;
- }
- public boolean isInlineable(Environment env, boolean fromFinal) throws ClassNotFound {
- return (isStatic() || isPrivate() || isFinal() || isConstructor() || fromFinal) &&
- !(isSynchronized() || isNative());
- }
-
- /**
- * Check if constant: Will it inline away to a constant?
- */
- public boolean isConstant() {
- if (isFinal() && isVariable() && value != null) {
- try {
- // If an infinite regress requeries this name,
- // deny that it is a constant.
- modifiers &= ~M_FINAL;
- return ((Expression)value).isConstant();
- } finally {
- modifiers |= M_FINAL;
- }
- }
- return false;
- }
-
- /**
- * toString
- */
- public String toString() {
- Identifier name = getClassDefinition().getName();
- if (isInitializer()) {
- return isStatic() ? "static {}" : "instance {}";
- } else if (isConstructor()) {
- StringBuilder sb = new StringBuilder();
- sb.append(name);
- sb.append('(');
- Type argTypes[] = getType().getArgumentTypes();
- for (int i = 0 ; i < argTypes.length ; i++) {
- if (i > 0) {
- sb.append(',');
- }
- sb.append(argTypes[i].toString());
- }
- sb.append(')');
- return sb.toString();
- } else if (isInnerClass()) {
- return getInnerClass().toString();
- }
- return type.typeString(getName().toString());
- }
-
- /**
- * Print for debugging
- */
- public void print(PrintStream out) {
- if (isPublic()) {
- out.print("public ");
- }
- if (isPrivate()) {
- out.print("private ");
- }
- if (isProtected()) {
- out.print("protected ");
- }
- if (isFinal()) {
- out.print("final ");
- }
- if (isStatic()) {
- out.print("static ");
- }
- if (isSynchronized()) {
- out.print("synchronized ");
- }
- if (isAbstract()) {
- out.print("abstract ");
- }
- if (isNative()) {
- out.print("native ");
- }
- if (isVolatile()) {
- out.print("volatile ");
- }
- if (isTransient()) {
- out.print("transient ");
- }
- out.println(toString() + ";");
- }
-
- public void cleanup(Environment env) {
- documentation = null;
- if (isMethod() && value != null) {
- int cost = 0;
- if (isPrivate() || isInitializer()) {
- value = Statement.empty;
- } else if ((cost =
- ((Statement)value)
- .costInline(Statement.MAXINLINECOST, null, null))
- >= Statement.MAXINLINECOST) {
- // will never be inlined
- value = Statement.empty;
- } else {
- try {
- if (!isInlineable(null, true)) {
- value = Statement.empty;
- }
- }
- catch (ClassNotFound ee) { }
- }
- if (value != Statement.empty && env.dump()) {
- env.output("[after cleanup of " + getName() + ", " +
- cost + " expression cost units remain]");
- }
- } else if (isVariable()) {
- if (isPrivate() || !isFinal() || type.isType(TC_ARRAY)) {
- value = null;
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/MethodSet.java b/src/jdk.rmic/share/classes/sun/tools/java/MethodSet.java
deleted file mode 100644
index c62eb00d167..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/MethodSet.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 1997, 2003, 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 sun.tools.java;
-
-import java.util.*;
-
-/**
- * The MethodSet structure is used to store methods for a class.
- * It maintains the invariant that it never stores two methods
- * with the same signature. MethodSets are able to lookup
- * all methods with a given name and the unique method with a given
- * signature (name, args).
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-
-public
-class MethodSet {
-
- /**
- * A Map containing Lists of MemberDefinitions. The Lists
- * contain methods which share the same name.
- */
- private final Map> lookupMap;
-
- /**
- * The number of methods stored in the MethodSet.
- */
- private int count;
-
- /**
- * Is this MethodSet currently frozen? See freeze() for more details.
- */
- private boolean frozen;
-
- /**
- * Creates a brand new MethodSet
- */
- public MethodSet() {
- frozen = false;
- lookupMap = new HashMap<>();
- count = 0;
- }
-
- /**
- * Returns the number of distinct methods stored in the MethodSet.
- */
- public int size() {
- return count;
- }
-
- /**
- * Adds `method' to the MethodSet. No method of the same signature
- * should be already defined.
- */
- public void add(MemberDefinition method) {
- // Check for late additions.
- if (frozen) {
- throw new CompilerError("add()");
- }
-
- // todo: Check for method??
-
- Identifier name = method.getName();
-
- // Get a List containing all methods of this name.
- List methodList = lookupMap.get(name);
-
- if (methodList == null) {
- // There is no method with this name already.
- // Create a List, and insert it into the hash.
- methodList = new ArrayList<>();
- lookupMap.put(name, methodList);
- }
-
- // Make sure that no method with the same signature has already
- // been added to the MethodSet.
- int size = methodList.size();
- for (int i = 0; i < size; i++) {
- if ((methodList.get(i))
- .getType().equalArguments(method.getType())) {
- throw new CompilerError("duplicate addition");
- }
- }
-
- // We add the method to the appropriate list.
- methodList.add(method);
- count++;
- }
-
- /**
- * Adds `method' to the MethodSet, replacing any previous definition
- * with the same signature.
- */
- public void replace(MemberDefinition method) {
- // Check for late additions.
- if (frozen) {
- throw new CompilerError("replace()");
- }
-
- // todo: Check for method??
-
- Identifier name = method.getName();
-
- // Get a List containing all methods of this name.
- List methodList = lookupMap.get(name);
-
- if (methodList == null) {
- // There is no method with this name already.
- // Create a List, and insert it into the hash.
- methodList = new ArrayList<>();
- lookupMap.put(name, methodList);
- }
-
- // Replace the element which has the same signature as
- // `method'.
- int size = methodList.size();
- for (int i = 0; i < size; i++) {
- if ((methodList.get(i))
- .getType().equalArguments(method.getType())) {
- methodList.set(i, method);
- return;
- }
- }
-
- // We add the method to the appropriate list.
- methodList.add(method);
- count++;
- }
-
- /**
- * If the MethodSet contains a method with the same signature
- * then lookup() returns it. Otherwise, this method returns null.
- */
- public MemberDefinition lookupSig(Identifier name, Type type) {
- // Go through all methods of the same name and see if any
- // have the right signature.
- Iterator matches = lookupName(name);
- MemberDefinition candidate;
-
- while (matches.hasNext()) {
- candidate = matches.next();
- if (candidate.getType().equalArguments(type)) {
- return candidate;
- }
- }
-
- // No match.
- return null;
- }
-
- /**
- * Returns an Iterator of all methods contained in the
- * MethodSet which have a given name.
- */
- public Iterator lookupName(Identifier name) {
- // Find the List containing all methods of this name, and
- // return that List's Iterator.
- List methodList = lookupMap.get(name);
- if (methodList == null) {
- // If there is no method of this name, return a bogus, empty
- // Iterator.
- return Collections.emptyIterator();
- }
- return methodList.iterator();
- }
-
- /**
- * Returns an Iterator of all methods in the MethodSet
- */
- public Iterator iterator() {
-
- //----------------------------------------------------------
- // The inner class MethodIterator is used to create our
- // Iterator of all methods in the MethodSet.
- class MethodIterator implements Iterator {
- Iterator> hashIter = lookupMap.values().iterator();
- Iterator listIter = Collections.emptyIterator();
-
- public boolean hasNext() {
- if (listIter.hasNext()) {
- return true;
- } else {
- if (hashIter.hasNext()) {
- listIter = hashIter.next().iterator();
-
- // The following should be always true.
- if (listIter.hasNext()) {
- return true;
- } else {
- throw new
- CompilerError("iterator() in MethodSet");
- }
- }
- }
-
- // We've run out of Lists.
- return false;
- }
-
- public MemberDefinition next() {
- return listIter.next();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
- // end MethodIterator
- //----------------------------------------------------------
-
- // A one-liner.
- return new MethodIterator();
- }
-
- /**
- * After freeze() is called, the MethodSet becomes (mostly)
- * immutable. Any calls to add() or addMeet() lead to
- * CompilerErrors. Note that the entries themselves are still
- * (unfortunately) open for mischievous and wanton modification.
- */
- public void freeze() {
- frozen = true;
- }
-
- /**
- * Tells whether freeze() has been called on this MethodSet.
- */
- public boolean isFrozen() {
- return frozen;
- }
-
- /**
- * Returns a (big) string representation of this MethodSet
- */
- public String toString() {
- int len = size();
- StringBuilder sb = new StringBuilder();
- Iterator all = iterator();
- sb.append("{");
-
- while (all.hasNext()) {
- sb.append(all.next().toString());
- len--;
- if (len > 0) {
- sb.append(", ");
- }
- }
- sb.append("}");
- return sb.toString();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/MethodType.java b/src/jdk.rmic/share/classes/sun/tools/java/MethodType.java
deleted file mode 100644
index 609c35d31ba..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/MethodType.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-/**
- * This class represents an Java method type.
- * It overrides the relevant methods in class Type.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-public final
-class MethodType extends Type {
- /**
- * The return type.
- */
- Type returnType;
-
- /**
- * The argument types.
- */
- Type argTypes[];
-
- /**
- * Construct a method type. Use Type.tMethod to create
- * a new method type.
- * @see Type.tMethod
- */
- MethodType(String typeSig, Type returnType, Type argTypes[]) {
- super(TC_METHOD, typeSig);
- this.returnType = returnType;
- this.argTypes = argTypes;
- }
-
- public Type getReturnType() {
- return returnType;
- }
-
- public Type[] getArgumentTypes() {
- return argTypes;
- }
-
- public boolean equalArguments(Type t) {
- if (t.typeCode != TC_METHOD) {
- return false;
- }
- MethodType m = (MethodType)t;
- if (argTypes.length != m.argTypes.length) {
- return false;
- }
- for (int i = argTypes.length - 1 ; i >= 0 ; i--) {
- if (argTypes[i] != m.argTypes[i]) {
- return false;
- }
- }
- return true;
- }
-
- public int stackSize() {
- int n = 0;
- for (int i = 0 ; i < argTypes.length ; i++) {
- n += argTypes[i].stackSize();
- }
- return n;
- }
-
- public String typeString(String id, boolean abbrev, boolean ret) {
- StringBuilder sb = new StringBuilder();
- sb.append(id);
- sb.append('(');
- for (int i = 0 ; i < argTypes.length ; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append(argTypes[i].typeString("", abbrev, ret));
- }
- sb.append(')');
-
- return ret ? getReturnType().typeString(sb.toString(), abbrev, ret) : sb.toString();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Package.java b/src/jdk.rmic/share/classes/sun/tools/java/Package.java
deleted file mode 100644
index 1a7c077f7bd..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Package.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1995, 2004, 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 sun.tools.java;
-
-import java.util.Enumeration;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * This class is used to represent the classes in a package.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public
-class Package {
- /**
- * The path which we use to locate source files.
- */
- ClassPath sourcePath;
-
- /**
- * The path which we use to locate class (binary) files.
- */
- ClassPath binaryPath;
-
- /**
- * The path name of the package.
- */
- String pkg;
-
- /**
- * Create a package given a class path, and package name.
- */
- public Package(ClassPath path, Identifier pkg) throws IOException {
- this(path, path, pkg);
- }
-
- /**
- * Create a package given a source path, binary path, and package
- * name.
- */
- public Package(ClassPath sourcePath,
- ClassPath binaryPath,
- Identifier pkg)
- throws IOException {
- if (pkg.isInner())
- pkg = Identifier.lookup(pkg.getQualifier(), pkg.getFlatName());
- this.sourcePath = sourcePath;
- this.binaryPath = binaryPath;
- this.pkg = pkg.toString().replace('.', File.separatorChar);
- }
-
- /**
- * Check if a class is defined in this package.
- * (If it is an inner class name, it is assumed to exist
- * only if its binary file exists. This is somewhat pessimistic.)
- */
- public boolean classExists(Identifier className) {
- return getBinaryFile(className) != null ||
- !className.isInner() &&
- getSourceFile(className) != null;
- }
-
- /**
- * Check if the package exists
- */
- public boolean exists() {
- // Look for the directory on our binary path.
- ClassFile dir = binaryPath.getDirectory(pkg);
- if (dir != null && dir.isDirectory()) {
- return true;
- }
-
- if (sourcePath != binaryPath) {
- // Look for the directory on our source path.
- dir = sourcePath.getDirectory(pkg);
- if (dir != null && dir.isDirectory()) {
- return true;
- }
- }
-
- /* Accommodate ZIP files without CEN entries for directories
- * (packages): look on class path for at least one binary
- * file or one source file with the right package prefix
- */
- String prefix = pkg + File.separator;
-
- return binaryPath.getFiles(prefix, ".class").hasMoreElements()
- || sourcePath.getFiles(prefix, ".java").hasMoreElements();
- }
-
- private String makeName(String fileName) {
- return pkg.isEmpty() ? fileName : pkg + File.separator + fileName;
- }
-
- /**
- * Get the .class file of a class
- */
- public ClassFile getBinaryFile(Identifier className) {
- className = Type.mangleInnerType(className);
- String fileName = className.toString() + ".class";
- return binaryPath.getFile(makeName(fileName));
- }
-
- /**
- * Get the .java file of a class
- */
- public ClassFile getSourceFile(Identifier className) {
- // The source file of an inner class is that of its outer class.
- className = className.getTopName();
- String fileName = className.toString() + ".java";
- return sourcePath.getFile(makeName(fileName));
- }
-
- public ClassFile getSourceFile(String fileName) {
- if (fileName.endsWith(".java")) {
- return sourcePath.getFile(makeName(fileName));
- }
- return null;
- }
-
- public Enumeration getSourceFiles() {
- return sourcePath.getFiles(pkg, ".java");
- }
-
- public Enumeration getBinaryFiles() {
- return binaryPath.getFiles(pkg, ".class");
- }
-
- public String toString() {
- if (pkg.isEmpty()) {
- return "unnamed package";
- }
- return "package " + pkg;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Parser.java b/src/jdk.rmic/share/classes/sun/tools/java/Parser.java
deleted file mode 100644
index 8a962ef2b60..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Parser.java
+++ /dev/null
@@ -1,2130 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-import sun.tools.tree.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * This class is used to parse Java statements and expressions.
- * The result is a parse tree.
- *
- * This class implements an operator precedence parser. Errors are
- * reported to the Environment object, if the error can't be
- * resolved immediately, a SyntaxError exception is thrown.
- *
- * Error recovery is implemented by catching SyntaxError exceptions
- * and discarding input tokens until an input token is reached that
- * is possibly a legal continuation.
- *
- * The parse tree that is constructed represents the input
- * exactly (no rewrites to simpler forms). This is important
- * if the resulting tree is to be used for code formatting in
- * a programming environment. Currently only documentation comments
- * are retained.
- *
- * The parsing algorithm does NOT use any type information. Changes
- * in the type system do not affect the structure of the parse tree.
- * This restriction does introduce an ambiguity an expression of the
- * form: (e1) e2 is assumed to be a cast if e2 does not start with
- * an operator. That means that (a) - b is interpreted as subtract
- * b from a and not cast negative b to type a. However, if a is a
- * simple type (byte, int, ...) then it is assumed to be a cast.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-public
-class Parser extends Scanner implements ParserActions, Constants {
- /**
- * Create a parser
- */
- protected Parser(Environment env, InputStream in) throws IOException {
- super(env, in);
- this.scanner = this;
- this.actions = this;
- }
-
- /**
- * Create a parser, given a scanner.
- */
- protected Parser(Scanner scanner) throws IOException {
- super(scanner.env);
- this.scanner = scanner;
- ((Scanner)this).env = scanner.env;
- ((Scanner)this).token = scanner.token;
- ((Scanner)this).pos = scanner.pos;
- this.actions = this;
- }
-
- /**
- * Create a parser, given a scanner and the semantic callback.
- */
- public Parser(Scanner scanner, ParserActions actions) throws IOException {
- this(scanner);
- this.actions = actions;
- }
-
- /**
- * Usually this.actions == (ParserActions)this.
- * However, a delegate scanner can produce tokens for this parser,
- * in which case (Scanner)this is unused,
- * except for this.token and this.pos
- * instance variables which are filled from the real scanner
- * by this.scan() and the constructor.
- */
- ParserActions actions;
-
- // Note: The duplication of methods allows pre-1.1 classes to
- // be binary compatible with the new version of the parser,
- // which now passes IdentifierTokens to the semantics phase,
- // rather than just Identifiers. This change is necessary,
- // since the parser is no longer responsible for managing the
- // resolution of type names. (That caused the "Vector" bug.)
- //
- // In a future release, the old "plain-Identifier" methods will
- // go away, and the corresponding "IdentifierToken" methods
- // may become abstract.
-
- /**
- * package declaration
- * @deprecated
- */
- @Deprecated
- public void packageDeclaration(long off, IdentifierToken nm) {
- // By default, call the deprecated version.
- // Any application must override one of the packageDeclaration methods.
- packageDeclaration(off, nm.id);
- }
- /**
- * @deprecated
- */
- @Deprecated
- protected void packageDeclaration(long off, Identifier nm) {
- throw new RuntimeException("beginClass method is abstract");
- }
-
- /**
- * import class
- * @deprecated
- */
- @Deprecated
- public void importClass(long off, IdentifierToken nm) {
- // By default, call the deprecated version.
- // Any application must override one of the packageDeclaration methods.
- importClass(off, nm.id);
- }
- /**
- * @deprecated Use the version with the IdentifierToken arguments.
- */
- @Deprecated
- protected void importClass(long off, Identifier nm) {
- throw new RuntimeException("importClass method is abstract");
- }
-
- /**
- * import package
- * @deprecated
- */
- @Deprecated
- public void importPackage(long off, IdentifierToken nm) {
- // By default, call the deprecated version.
- // Any application must override one of the importPackage methods.
- importPackage(off, nm.id);
- }
- /**
- * @deprecated Use the version with the IdentifierToken arguments.
- */
- @Deprecated
- protected void importPackage(long off, Identifier nm) {
- throw new RuntimeException("importPackage method is abstract");
- }
-
- /**
- * Define class
- * @deprecated
- */
- @Deprecated
- public ClassDefinition beginClass(long off, String doc,
- int mod, IdentifierToken nm,
- IdentifierToken sup,
- IdentifierToken impl[]) {
- // By default, call the deprecated version.
- // Any application must override one of the beginClass methods.
- Identifier supId = (sup == null) ? null : sup.id;
- Identifier implIds[] = null;
- if (impl != null) {
- implIds = new Identifier[impl.length];
- for (int i = 0; i < impl.length; i++) {
- implIds[i] = impl[i].id;
- }
- }
- beginClass(off, doc, mod, nm.id, supId, implIds);
- return getCurrentClass();
- }
- /**
- * @deprecated Use the version with the IdentifierToken arguments.
- */
- @Deprecated
- protected void beginClass(long off, String doc, int mod, Identifier nm,
- Identifier sup, Identifier impl[]) {
- throw new RuntimeException("beginClass method is abstract");
- }
-
- /**
- * Report the current class under construction.
- * By default, it's a no-op which returns null.
- * It may only be called before the corresponding endClass().
- */
- protected ClassDefinition getCurrentClass() {
- return null;
- }
-
- /**
- * End class
- * @deprecated
- */
- @Deprecated
- public void endClass(long off, ClassDefinition c) {
- // By default, call the deprecated version.
- // Any application must override one of the beginClass methods.
- endClass(off, c.getName().getFlatName().getName());
- }
- /**
- * @deprecated Use the version with the IdentifierToken arguments.
- */
- @Deprecated
- protected void endClass(long off, Identifier nm) {
- throw new RuntimeException("endClass method is abstract");
- }
-
- /**
- * Define a field
- * @deprecated
- */
- @Deprecated
- public void defineField(long where, ClassDefinition c,
- String doc, int mod, Type t,
- IdentifierToken nm, IdentifierToken args[],
- IdentifierToken exp[], Node val) {
- // By default, call the deprecated version.
- // Any application must override one of the defineField methods.
- Identifier argIds[] = null;
- Identifier expIds[] = null;
- if (args != null) {
- argIds = new Identifier[args.length];
- for (int i = 0; i < args.length; i++) {
- argIds[i] = args[i].id;
- }
- }
- if (exp != null) {
- expIds = new Identifier[exp.length];
- for (int i = 0; i < exp.length; i++) {
- expIds[i] = exp[i].id;
- }
- }
- defineField(where, doc, mod, t, nm.id, argIds, expIds, val);
- }
-
- /**
- * @deprecated Use the version with the IdentifierToken arguments.
- */
- @Deprecated
- protected void defineField(long where, String doc, int mod, Type t,
- Identifier nm, Identifier args[],
- Identifier exp[], Node val) {
- throw new RuntimeException("defineField method is abstract");
- }
-
- /*
- * A growable array of nodes. It is used as a growable
- * buffer to hold argument lists and expression lists.
- * I'm not using Vector to make it more efficient.
- */
- private Node args[] = new Node[32];
- protected int argIndex = 0;
-
- protected final void addArgument(Node n) {
- if (argIndex == args.length) {
- Node newArgs[] = new Node[args.length * 2];
- System.arraycopy(args, 0, newArgs, 0, args.length);
- args = newArgs;
- }
- args[argIndex++] = n;
- }
- protected final Expression[] exprArgs(int index) {
- Expression e[] = new Expression[argIndex - index];
- System.arraycopy(args, index, e, 0, argIndex - index);
- argIndex = index;
- return e;
- }
- protected final Statement[] statArgs(int index) {
- Statement s[] = new Statement[argIndex - index];
- System.arraycopy(args, index, s, 0, argIndex - index);
- argIndex = index;
- return s;
- }
-
- /**
- * Expect a token, return its value, scan the next token or
- * throw an exception.
- */
- protected void expect(int t) throws SyntaxError, IOException {
- if (token != t) {
- switch (t) {
- case IDENT:
- env.error(scanner.prevPos, "identifier.expected");
- break;
- default:
- env.error(scanner.prevPos, "token.expected", opNames[t]);
- break;
- }
- throw new SyntaxError();
- }
- scan();
- }
-
- /**
- * Parse a type expression. Does not parse the []'s.
- */
- protected Expression parseTypeExpression() throws SyntaxError, IOException {
- switch (token) {
- case VOID:
- return new TypeExpression(scan(), Type.tVoid);
- case BOOLEAN:
- return new TypeExpression(scan(), Type.tBoolean);
- case BYTE:
- return new TypeExpression(scan(), Type.tByte);
- case CHAR:
- return new TypeExpression(scan(), Type.tChar);
- case SHORT:
- return new TypeExpression(scan(), Type.tShort);
- case INT:
- return new TypeExpression(scan(), Type.tInt);
- case LONG:
- return new TypeExpression(scan(), Type.tLong);
- case FLOAT:
- return new TypeExpression(scan(), Type.tFloat);
- case DOUBLE:
- return new TypeExpression(scan(), Type.tDouble);
- case IDENT:
- Expression e = new IdentifierExpression(pos, scanner.idValue);
- scan();
- while (token == FIELD) {
- e = new FieldExpression(scan(), e, scanner.idValue);
- expect(IDENT);
- }
- return e;
- }
-
- env.error(pos, "type.expected");
- throw new SyntaxError();
- }
-
- /**
- * Parse a method invocation. Should be called when the current
- * then is the '(' of the argument list.
- */
- protected Expression parseMethodExpression(Expression e, Identifier id) throws SyntaxError, IOException {
- long p = scan();
- int i = argIndex;
- if (token != RPAREN) {
- addArgument(parseExpression());
- while (token == COMMA) {
- scan();
- addArgument(parseExpression());
- }
- }
- expect(RPAREN);
- return new MethodExpression(p, e, id, exprArgs(i));
- }
-
- /**
- * Parse a new instance expression. Should be called when the current
- * token is the '(' of the argument list.
- */
- protected Expression parseNewInstanceExpression(long p, Expression outerArg, Expression type) throws SyntaxError, IOException {
- int i = argIndex;
- expect(LPAREN);
- if (token != RPAREN) {
- addArgument(parseExpression());
- while (token == COMMA) {
- scan();
- addArgument(parseExpression());
- }
- }
- expect(RPAREN);
- ClassDefinition body = null;
- if (token == LBRACE && !(type instanceof TypeExpression)) {
- long tp = pos;
- // x = new Type(arg) { subclass body ... }
- Identifier superName = FieldExpression.toIdentifier(type);
- if (superName == null) {
- env.error(type.getWhere(), "type.expected");
- }
- Vector ext = new Vector<>(1);
- Vector impl = new Vector<>(0);
- ext.addElement(new IdentifierToken(idNull));
- if (token == IMPLEMENTS || token == EXTENDS) {
- env.error(pos, "anonymous.extends");
- parseInheritance(ext, impl); // error recovery
- }
- body = parseClassBody(new IdentifierToken(tp, idNull),
- M_ANONYMOUS | M_LOCAL, EXPR, null,
- ext, impl, type.getWhere());
- }
- if (outerArg == null && body == null) {
- return new NewInstanceExpression(p, type, exprArgs(i));
- }
- return new NewInstanceExpression(p, type, exprArgs(i), outerArg, body);
- }
-
- /**
- * Parse a primary expression.
- */
- protected Expression parseTerm() throws SyntaxError, IOException {
- switch (token) {
- case CHARVAL: {
- char v = scanner.charValue;
- return new CharExpression(scan(), v);
- }
- case INTVAL: {
- int v = scanner.intValue;
- long q = scan();
- if (v < 0 && radix == 10) env.error(q, "overflow.int.dec");
- return new IntExpression(q, v);
- }
- case LONGVAL: {
- long v = scanner.longValue;
- long q = scan();
- if (v < 0 && radix == 10) env.error(q, "overflow.long.dec");
- return new LongExpression(q, v);
- }
- case FLOATVAL: {
- float v = scanner.floatValue;
- return new FloatExpression(scan(), v);
- }
- case DOUBLEVAL: {
- double v = scanner.doubleValue;
- return new DoubleExpression(scan(), v);
- }
- case STRINGVAL: {
- String v = scanner.stringValue;
- return new StringExpression(scan(), v);
- }
- case IDENT: {
- Identifier v = scanner.idValue;
- long p = scan();
- return (token == LPAREN) ?
- parseMethodExpression(null, v) : new IdentifierExpression(p, v);
- }
-
- case TRUE:
- return new BooleanExpression(scan(), true);
- case FALSE:
- return new BooleanExpression(scan(), false);
- case NULL:
- return new NullExpression(scan());
-
- case THIS: {
- Expression e = new ThisExpression(scan());
- return (token == LPAREN) ? parseMethodExpression(e, idInit) : e;
- }
- case SUPER: {
- Expression e = new SuperExpression(scan());
- return (token == LPAREN) ? parseMethodExpression(e, idInit) : e;
- }
-
- case VOID:
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case SHORT:
- case INT:
- case LONG:
- case FLOAT:
- case DOUBLE:
- return parseTypeExpression();
-
- case ADD: {
- long p = scan();
- switch (token) {
- case INTVAL: {
- int v = scanner.intValue;
- long q = scan();
- if (v < 0 && radix == 10) env.error(q, "overflow.int.dec");
- return new IntExpression(q, v);
- }
- case LONGVAL: {
- long v = scanner.longValue;
- long q = scan();
- if (v < 0 && radix == 10) env.error(q, "overflow.long.dec");
- return new LongExpression(q, v);
- }
- case FLOATVAL: {
- float v = scanner.floatValue;
- return new FloatExpression(scan(), v);
- }
- case DOUBLEVAL: {
- double v = scanner.doubleValue;
- return new DoubleExpression(scan(), v);
- }
- }
- return new PositiveExpression(p, parseTerm());
- }
- case SUB: {
- long p = scan();
- switch (token) {
- case INTVAL: {
- int v = -scanner.intValue;
- return new IntExpression(scan(), v);
- }
- case LONGVAL: {
- long v = -scanner.longValue;
- return new LongExpression(scan(), v);
- }
- case FLOATVAL: {
- float v = -scanner.floatValue;
- return new FloatExpression(scan(), v);
- }
- case DOUBLEVAL: {
- double v = -scanner.doubleValue;
- return new DoubleExpression(scan(), v);
- }
- }
- return new NegativeExpression(p, parseTerm());
- }
- case NOT:
- return new NotExpression(scan(), parseTerm());
- case BITNOT:
- return new BitNotExpression(scan(), parseTerm());
- case INC:
- return new PreIncExpression(scan(), parseTerm());
- case DEC:
- return new PreDecExpression(scan(), parseTerm());
-
- case LPAREN: {
- // bracketed-expr: (expr)
- long p = scan();
- Expression e = parseExpression();
- expect(RPAREN);
-
- if (e.getOp() == TYPE) {
- // cast-expr: (simple-type) expr
- return new CastExpression(p, e, parseTerm());
- }
-
- switch (token) {
-
- // We handle INC and DEC specially.
- // See the discussion in JLS section 15.14.1.
- // (Part of fix for 4044502.)
-
- case INC:
- // We know this must be a postfix increment.
- return new PostIncExpression(scan(), e);
-
- case DEC:
- // We know this must be a postfix decrement.
- return new PostDecExpression(scan(), e);
-
- case LPAREN:
- case CHARVAL:
- case INTVAL:
- case LONGVAL:
- case FLOATVAL:
- case DOUBLEVAL:
- case STRINGVAL:
- case IDENT:
- case TRUE:
- case FALSE:
- case NOT:
- case BITNOT:
- case THIS:
- case SUPER:
- case NULL:
- case NEW:
- // cast-expr: (expr) expr
- return new CastExpression(p, e, parseTerm());
- }
- return new ExprExpression(p, e);
- }
-
- case LBRACE: {
- // array initializer: {expr1, expr2, ... exprn}
- long p = scan();
- int i = argIndex;
- if (token != RBRACE) {
- addArgument(parseExpression());
- while (token == COMMA) {
- scan();
- if (token == RBRACE) {
- break;
- }
- addArgument(parseExpression());
- }
- }
- expect(RBRACE);
- return new ArrayExpression(p, exprArgs(i));
- }
-
- case NEW: {
- long p = scan();
- int i = argIndex;
-
- if (token == LPAREN) {
- scan();
- Expression e = parseExpression();
- expect(RPAREN);
- env.error(p, "not.supported", "new(...)");
- return new NullExpression(p);
- }
-
- Expression e = parseTypeExpression();
-
- if (token == LSQBRACKET) {
- while (token == LSQBRACKET) {
- scan();
- addArgument((token != RSQBRACKET) ? parseExpression() : null);
- expect(RSQBRACKET);
- }
- Expression[] dims = exprArgs(i);
- if (token == LBRACE) {
- return new NewArrayExpression(p, e, dims, parseTerm());
- }
- return new NewArrayExpression(p, e, dims);
- } else {
- return parseNewInstanceExpression(p, null, e);
- }
- }
- }
-
- // System.err.println("NEAR: " + opNames[token]);
- env.error(scanner.prevPos, "missing.term");
- return new IntExpression(pos, 0);
- }
-
- /**
- * Parse an expression.
- */
- protected Expression parseExpression() throws SyntaxError, IOException {
- for (Expression e = parseTerm() ; e != null ; e = e.order()) {
- Expression more = parseBinaryExpression(e);
- if (more == null)
- return e;
- e = more;
- }
- // this return is bogus
- return null;
- }
-
- /**
- * Given a left-hand term, parse an operator and right-hand term.
- */
- protected Expression parseBinaryExpression(Expression e) throws SyntaxError, IOException {
- if (e != null) {
- switch (token) {
- case LSQBRACKET: {
- // index: expr1[expr2]
- long p = scan();
- Expression index = (token != RSQBRACKET) ? parseExpression() : null;
- expect(RSQBRACKET);
- e = new ArrayAccessExpression(p, e, index);
- break;
- }
-
- case INC:
- e = new PostIncExpression(scan(), e);
- break;
- case DEC:
- e = new PostDecExpression(scan(), e);
- break;
- case FIELD: {
- long p = scan();
- if (token == THIS) {
- // class C { class N { ... C.this ... } }
- // class C { class N { N(C c){ ... c.this() ... } } }
- long q = scan();
- if (token == LPAREN) {
- e = new ThisExpression(q, e);
- e = parseMethodExpression(e, idInit);
- } else {
- e = new FieldExpression(p, e, idThis);
- }
- break;
- }
- if (token == SUPER) {
- // class D extends C.N { D(C.N n) { n.super(); } }
- // Also, 'C.super', as in:
- // class C extends CS { class N { ... C.super.foo ... } }
- // class C extends CS { class N { ... C.super.foo() ... } }
- long q = scan();
- if (token == LPAREN) {
- e = new SuperExpression(q, e);
- e = parseMethodExpression(e, idInit);
- } else {
- // We must check elsewhere that this expression
- // does not stand alone, but qualifies a member name.
- e = new FieldExpression(p, e, idSuper);
- }
- break;
- }
- if (token == NEW) {
- // new C().new N()
- scan();
- if (token != IDENT)
- expect(IDENT);
- e = parseNewInstanceExpression(p, e, parseTypeExpression());
- break;
- }
- if (token == CLASS) {
- // just class literals, really
- // Class c = C.class;
- scan();
- e = new FieldExpression(p, e, idClass);
- break;
- }
- Identifier id = scanner.idValue;
- expect(IDENT);
- if (token == LPAREN) {
- e = parseMethodExpression(e, id);
- } else {
- e = new FieldExpression(p, e, id);
- }
- break;
- }
- case INSTANCEOF:
- e = new InstanceOfExpression(scan(), e, parseTerm());
- break;
- case ADD:
- e = new AddExpression(scan(), e, parseTerm());
- break;
- case SUB:
- e = new SubtractExpression(scan(), e, parseTerm());
- break;
- case MUL:
- e = new MultiplyExpression(scan(), e, parseTerm());
- break;
- case DIV:
- e = new DivideExpression(scan(), e, parseTerm());
- break;
- case REM:
- e = new RemainderExpression(scan(), e, parseTerm());
- break;
- case LSHIFT:
- e = new ShiftLeftExpression(scan(), e, parseTerm());
- break;
- case RSHIFT:
- e = new ShiftRightExpression(scan(), e, parseTerm());
- break;
- case URSHIFT:
- e = new UnsignedShiftRightExpression(scan(), e, parseTerm());
- break;
- case LT:
- e = new LessExpression(scan(), e, parseTerm());
- break;
- case LE:
- e = new LessOrEqualExpression(scan(), e, parseTerm());
- break;
- case GT:
- e = new GreaterExpression(scan(), e, parseTerm());
- break;
- case GE:
- e = new GreaterOrEqualExpression(scan(), e, parseTerm());
- break;
- case EQ:
- e = new EqualExpression(scan(), e, parseTerm());
- break;
- case NE:
- e = new NotEqualExpression(scan(), e, parseTerm());
- break;
- case BITAND:
- e = new BitAndExpression(scan(), e, parseTerm());
- break;
- case BITXOR:
- e = new BitXorExpression(scan(), e, parseTerm());
- break;
- case BITOR:
- e = new BitOrExpression(scan(), e, parseTerm());
- break;
- case AND:
- e = new AndExpression(scan(), e, parseTerm());
- break;
- case OR:
- e = new OrExpression(scan(), e, parseTerm());
- break;
- case ASSIGN:
- e = new AssignExpression(scan(), e, parseTerm());
- break;
- case ASGMUL:
- e = new AssignMultiplyExpression(scan(), e, parseTerm());
- break;
- case ASGDIV:
- e = new AssignDivideExpression(scan(), e, parseTerm());
- break;
- case ASGREM:
- e = new AssignRemainderExpression(scan(), e, parseTerm());
- break;
- case ASGADD:
- e = new AssignAddExpression(scan(), e, parseTerm());
- break;
- case ASGSUB:
- e = new AssignSubtractExpression(scan(), e, parseTerm());
- break;
- case ASGLSHIFT:
- e = new AssignShiftLeftExpression(scan(), e, parseTerm());
- break;
- case ASGRSHIFT:
- e = new AssignShiftRightExpression(scan(), e, parseTerm());
- break;
- case ASGURSHIFT:
- e = new AssignUnsignedShiftRightExpression(scan(), e, parseTerm());
- break;
- case ASGBITAND:
- e = new AssignBitAndExpression(scan(), e, parseTerm());
- break;
- case ASGBITOR:
- e = new AssignBitOrExpression(scan(), e, parseTerm());
- break;
- case ASGBITXOR:
- e = new AssignBitXorExpression(scan(), e, parseTerm());
- break;
- case QUESTIONMARK: {
- long p = scan();
- Expression second = parseExpression();
- expect(COLON);
- Expression third = parseExpression();
-
- // The grammar in the JLS does not allow assignment
- // expressions as the third part of a ?: expression.
- // Even though javac has no trouble parsing this,
- // check for this case and signal an error.
- // (fix for bug 4092958)
- if (third instanceof AssignExpression
- || third instanceof AssignOpExpression) {
- env.error(third.getWhere(), "assign.in.conditionalexpr");
- }
-
- e = new ConditionalExpression(p, e, second, third);
- break;
- }
-
- default:
- return null; // mark end of binary expressions
- }
- }
- return e; // return more binary expression stuff
- }
-
- /**
- * Recover after a syntax error in a statement. This involves
- * discarding tokens until EOF or a possible continuation is
- * encountered.
- */
- protected boolean recoverStatement() throws SyntaxError, IOException {
- while (true) {
- switch (token) {
- case EOF:
- case RBRACE:
- case LBRACE:
- case IF:
- case FOR:
- case WHILE:
- case DO:
- case TRY:
- case CATCH:
- case FINALLY:
- case BREAK:
- case CONTINUE:
- case RETURN:
- // begin of a statement, return
- return true;
-
- case VOID:
- case STATIC:
- case PUBLIC:
- case PRIVATE:
- case SYNCHRONIZED:
- case INTERFACE:
- case CLASS:
- case TRANSIENT:
- // begin of something outside a statement, panic some more
- expect(RBRACE);
- return false;
-
- case LPAREN:
- match(LPAREN, RPAREN);
- scan();
- break;
-
- case LSQBRACKET:
- match(LSQBRACKET, RSQBRACKET);
- scan();
- break;
-
- default:
- // don't know what to do, skip
- scan();
- break;
- }
- }
- }
-
- /**
- * Parse declaration, called after the type expression
- * has been parsed and the current token is IDENT.
- */
- protected Statement parseDeclaration(long p, int mod, Expression type) throws SyntaxError, IOException {
- int i = argIndex;
- if (token == IDENT) {
- addArgument(new VarDeclarationStatement(pos, parseExpression()));
- while (token == COMMA) {
- scan();
- addArgument(new VarDeclarationStatement(pos, parseExpression()));
- }
- }
- return new DeclarationStatement(p, mod, type, statArgs(i));
- }
-
- /**
- * Check if an expression is a legal toplevel expression.
- * Only method, inc, dec, and new expression are allowed.
- */
- protected void topLevelExpression(Expression e) {
- switch (e.getOp()) {
- case ASSIGN:
- case ASGMUL:
- case ASGDIV:
- case ASGREM:
- case ASGADD:
- case ASGSUB:
- case ASGLSHIFT:
- case ASGRSHIFT:
- case ASGURSHIFT:
- case ASGBITAND:
- case ASGBITOR:
- case ASGBITXOR:
- case PREINC:
- case PREDEC:
- case POSTINC:
- case POSTDEC:
- case METHOD:
- case NEWINSTANCE:
- return;
- }
- env.error(e.getWhere(), "invalid.expr");
- }
-
- /**
- * Parse a statement.
- */
- protected Statement parseStatement() throws SyntaxError, IOException {
- switch (token) {
- case SEMICOLON:
- return new CompoundStatement(scan(), new Statement[0]);
-
- case LBRACE:
- return parseBlockStatement();
-
- case IF: {
- // if-statement: if (expr) stat
- // if-statement: if (expr) stat else stat
- long p = scan();
-
- expect(LPAREN);
- Expression c = parseExpression();
- expect(RPAREN);
- Statement t = parseStatement();
- if (token == ELSE) {
- scan();
- return new IfStatement(p, c, t, parseStatement());
- } else {
- return new IfStatement(p, c, t, null);
- }
- }
-
- case ELSE: {
- // else-statement: else stat
- env.error(scan(), "else.without.if");
- return parseStatement();
- }
-
- case FOR: {
- // for-statement: for (decl-expr? ; expr? ; expr?) stat
- long p = scan();
- Statement init = null;
- Expression cond = null, inc = null;
-
- expect(LPAREN);
- if (token != SEMICOLON) {
- long p2 = pos;
- int mod = parseModifiers(M_FINAL);
- Expression e = parseExpression();
-
- if (token == IDENT) {
- init = parseDeclaration(p2, mod, e);
- } else {
- if (mod != 0) {
- expect(IDENT); // should have been a declaration
- }
- topLevelExpression(e);
- while (token == COMMA) {
- long p3 = scan();
- Expression e2 = parseExpression();
- topLevelExpression(e2);
- e = new CommaExpression(p3, e, e2);
- }
- init = new ExpressionStatement(p2, e);
- }
- }
- expect(SEMICOLON);
- if (token != SEMICOLON) {
- cond = parseExpression();
- }
- expect(SEMICOLON);
- if (token != RPAREN) {
- inc = parseExpression();
- topLevelExpression(inc);
- while (token == COMMA) {
- long p2 = scan();
- Expression e2 = parseExpression();
- topLevelExpression(e2);
- inc = new CommaExpression(p2, inc, e2);
- }
- }
- expect(RPAREN);
- return new ForStatement(p, init, cond, inc, parseStatement());
- }
-
- case WHILE: {
- // while-statement: while (expr) stat
- long p = scan();
-
- expect(LPAREN);
- Expression cond = parseExpression();
- expect(RPAREN);
- return new WhileStatement(p, cond, parseStatement());
- }
-
- case DO: {
- // do-statement: do stat while (expr)
- long p = scan();
-
- Statement body = parseStatement();
- expect(WHILE);
- expect(LPAREN);
- Expression cond = parseExpression();
- expect(RPAREN);
- expect(SEMICOLON);
- return new DoStatement(p, body, cond);
- }
-
- case BREAK: {
- // break-statement: break ;
- long p = scan();
- Identifier label = null;
-
- if (token == IDENT) {
- label = scanner.idValue;
- scan();
- }
- expect(SEMICOLON);
- return new BreakStatement(p, label);
- }
-
- case CONTINUE: {
- // continue-statement: continue ;
- long p = scan();
- Identifier label = null;
-
- if (token == IDENT) {
- label = scanner.idValue;
- scan();
- }
- expect(SEMICOLON);
- return new ContinueStatement(p, label);
- }
-
- case RETURN: {
- // return-statement: return ;
- // return-statement: return expr ;
- long p = scan();
- Expression e = null;
-
- if (token != SEMICOLON) {
- e = parseExpression();
- }
- expect(SEMICOLON);
- return new ReturnStatement(p, e);
- }
-
- case SWITCH: {
- // switch statement: switch ( expr ) stat
- long p = scan();
- int i = argIndex;
-
- expect(LPAREN);
- Expression e = parseExpression();
- expect(RPAREN);
- expect(LBRACE);
-
- while ((token != EOF) && (token != RBRACE)) {
- int j = argIndex;
- try {
- switch (token) {
- case CASE:
- // case-statement: case expr:
- addArgument(new CaseStatement(scan(), parseExpression()));
- expect(COLON);
- break;
-
- case DEFAULT:
- // default-statement: default:
- addArgument(new CaseStatement(scan(), null));
- expect(COLON);
- break;
-
- default:
- addArgument(parseStatement());
- break;
- }
- } catch (SyntaxError ee) {
- argIndex = j;
- if (!recoverStatement()) {
- throw ee;
- }
- }
- }
- expect(RBRACE);
- return new SwitchStatement(p, e, statArgs(i));
- }
-
- case CASE: {
- // case-statement: case expr : stat
- env.error(pos, "case.without.switch");
- while (token == CASE) {
- scan();
- parseExpression();
- expect(COLON);
- }
- return parseStatement();
- }
-
- case DEFAULT: {
- // default-statement: default : stat
- env.error(pos, "default.without.switch");
- scan();
- expect(COLON);
- return parseStatement();
- }
-
- case TRY: {
- // try-statement: try stat catch (type-expr ident) stat finally stat
- long p = scan();
- Statement init = null; // try-object specification
- int i = argIndex;
- boolean catches = false;
-
- if (false && token == LPAREN) {
- expect(LPAREN);
- long p2 = pos;
- int mod = parseModifiers(M_FINAL);
- Expression e = parseExpression();
-
- if (token == IDENT) {
- init = parseDeclaration(p2, mod, e);
- // leave check for try (T x, y) for semantic phase
- } else {
- if (mod != 0) {
- expect(IDENT); // should have been a declaration
- }
- init = new ExpressionStatement(p2, e);
- }
- expect(RPAREN);
- }
-
- Statement s = parseBlockStatement();
-
- if (init != null) {
- // s = new FinallyStatement(p, init, s, 0);
- }
-
- while (token == CATCH) {
- long pp = pos;
- expect(CATCH);
- expect(LPAREN);
- int mod = parseModifiers(M_FINAL);
- Expression t = parseExpression();
- IdentifierToken id = scanner.getIdToken();
- expect(IDENT);
- id.modifiers = mod;
- // We only catch Throwable's, so this is no longer required
- // while (token == LSQBRACKET) {
- // t = new ArrayAccessExpression(scan(), t, null);
- // expect(RSQBRACKET);
- // }
- expect(RPAREN);
- addArgument(new CatchStatement(pp, t, id, parseBlockStatement()));
- catches = true;
- }
-
- if (catches)
- s = new TryStatement(p, s, statArgs(i));
-
- if (token == FINALLY) {
- scan();
- return new FinallyStatement(p, s, parseBlockStatement());
- } else if (catches || init != null) {
- return s;
- } else {
- env.error(pos, "try.without.catch.finally");
- return new TryStatement(p, s, null);
- }
- }
-
- case CATCH: {
- // catch-statement: catch (expr ident) stat finally stat
- env.error(pos, "catch.without.try");
-
- Statement s;
- do {
- scan();
- expect(LPAREN);
- parseModifiers(M_FINAL);
- parseExpression();
- expect(IDENT);
- expect(RPAREN);
- s = parseBlockStatement();
- } while (token == CATCH);
-
- if (token == FINALLY) {
- scan();
- s = parseBlockStatement();
- }
- return s;
- }
-
- case FINALLY: {
- // finally-statement: finally stat
- env.error(pos, "finally.without.try");
- scan();
- return parseBlockStatement();
- }
-
- case THROW: {
- // throw-statement: throw expr;
- long p = scan();
- Expression e = parseExpression();
- expect(SEMICOLON);
- return new ThrowStatement(p, e);
- }
-
- case GOTO: {
- long p = scan();
- expect(IDENT);
- expect(SEMICOLON);
- env.error(p, "not.supported", "goto");
- return new CompoundStatement(p, new Statement[0]);
- }
-
- case SYNCHRONIZED: {
- // synchronized-statement: synchronized (expr) stat
- long p = scan();
- expect(LPAREN);
- Expression e = parseExpression();
- expect(RPAREN);
- return new SynchronizedStatement(p, e, parseBlockStatement());
- }
-
- case INTERFACE:
- case CLASS:
- // Inner class.
- return parseLocalClass(0);
-
- case CONST:
- case ABSTRACT:
- case FINAL:
- case STRICTFP: {
- // a declaration of some sort
- long p = pos;
-
- // A class which is local to a block is not a member, and so
- // cannot be public, private, protected, or static. It is in
- // effect private to the block, since it cannot be used outside
- // its scope.
- //
- // However, any class (if it has a name) can be declared final,
- // abstract, or strictfp.
- int mod = parseModifiers(M_FINAL | M_ABSTRACT
- | M_STRICTFP );
-
- switch (token) {
- case INTERFACE:
- case CLASS:
- return parseLocalClass(mod);
-
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case SHORT:
- case INT:
- case LONG:
- case FLOAT:
- case DOUBLE:
- case IDENT: {
- if ((mod & (M_ABSTRACT | M_STRICTFP )) != 0) {
- mod &= ~ (M_ABSTRACT | M_STRICTFP );
- expect(CLASS);
- }
- Expression e = parseExpression();
- if (token != IDENT) {
- expect(IDENT);
- }
- // declaration: final expr expr
- Statement s = parseDeclaration(p, mod, e);
- expect(SEMICOLON);
- return s;
- }
-
- default:
- env.error(pos, "type.expected");
- throw new SyntaxError();
- }
- }
-
- case VOID:
- case STATIC:
- case PUBLIC:
- case PRIVATE:
- case TRANSIENT:
- // This is the start of something outside a statement
- env.error(pos, "statement.expected");
- throw new SyntaxError();
- }
-
- long p = pos;
- Expression e = parseExpression();
-
- if (token == IDENT) {
- // declaration: expr expr
- Statement s = parseDeclaration(p, 0, e);
- expect(SEMICOLON);
- return s;
- }
- if (token == COLON) {
- // label: id: stat
- scan();
- Statement s = parseStatement();
- s.setLabel(env, e);
- return s;
- }
-
- // it was just an expression...
- topLevelExpression(e);
- expect(SEMICOLON);
- return new ExpressionStatement(p, e);
- }
-
- protected Statement parseBlockStatement() throws SyntaxError, IOException {
- // compound statement: { stat1 stat2 ... statn }
- if (token != LBRACE) {
- // We're expecting a block statement. But we'll probably do the
- // least damage if we try to parse a normal statement instead.
- env.error(scanner.prevPos, "token.expected", opNames[LBRACE]);
- return parseStatement();
- }
- long p = scan();
- int i = argIndex;
- while ((token != EOF) && (token != RBRACE)) {
- int j = argIndex;
- try {
- addArgument(parseStatement());
- } catch (SyntaxError e) {
- argIndex = j;
- if (!recoverStatement()) {
- throw e;
- }
- }
- }
-
- expect(RBRACE);
- return new CompoundStatement(p, statArgs(i));
- }
-
-
- /**
- * Parse an identifier. ie: a.b.c returns "a.b.c"
- * If star is true then "a.b.*" is allowed.
- * The return value encodes both the identifier and its location.
- */
- protected IdentifierToken parseName(boolean star) throws SyntaxError, IOException {
- IdentifierToken res = scanner.getIdToken();
- expect(IDENT);
-
- if (token != FIELD) {
- return res;
- }
-
- StringBuilder sb = new StringBuilder(res.id.toString());
-
- while (token == FIELD) {
- scan();
- if ((token == MUL) && star) {
- scan();
- sb.append(".*");
- break;
- }
-
- sb.append('.');
- if (token == IDENT) {
- sb.append(scanner.idValue);
- }
- expect(IDENT);
- }
-
- res.id = Identifier.lookup(sb.toString());
- return res;
- }
- /**
- * @deprecated
- * @see #parseName
- */
- @Deprecated
- protected Identifier parseIdentifier(boolean star) throws SyntaxError, IOException {
- return parseName(star).id;
- }
-
- /**
- * Parse a type expression, this results in a Type.
- * The parse includes trailing array brackets.
- */
- protected Type parseType() throws SyntaxError, IOException {
- Type t;
-
- switch (token) {
- case IDENT:
- t = Type.tClass(parseName(false).id);
- break;
- case VOID:
- scan();
- t = Type.tVoid;
- break;
- case BOOLEAN:
- scan();
- t = Type.tBoolean;
- break;
- case BYTE:
- scan();
- t = Type.tByte;
- break;
- case CHAR:
- scan();
- t = Type.tChar;
- break;
- case SHORT:
- scan();
- t = Type.tShort;
- break;
- case INT:
- scan();
- t = Type.tInt;
- break;
- case FLOAT:
- scan();
- t = Type.tFloat;
- break;
- case LONG:
- scan();
- t = Type.tLong;
- break;
- case DOUBLE:
- scan();
- t = Type.tDouble;
- break;
- default:
- env.error(pos, "type.expected");
- throw new SyntaxError();
- }
- return parseArrayBrackets(t);
- }
-
- /**
- * Parse the tail of a type expression, which might be array brackets.
- * Return the given type, as possibly modified by the suffix.
- */
- protected Type parseArrayBrackets(Type t) throws SyntaxError, IOException {
-
- // Parse []'s
- while (token == LSQBRACKET) {
- scan();
- if (token != RSQBRACKET) {
- env.error(pos, "array.dim.in.decl");
- parseExpression();
- }
- expect(RSQBRACKET);
- t = Type.tArray(t);
- }
- return t;
- }
-
- /*
- * Dealing with argument lists, I'm not using
- * Vector for efficiency.
- */
-
- private int aCount = 0;
- private Type aTypes[] = new Type[8];
- private IdentifierToken aNames[] = new IdentifierToken[aTypes.length];
-
- private void addArgument(int mod, Type t, IdentifierToken nm) {
- nm.modifiers = mod;
- if (aCount >= aTypes.length) {
- Type newATypes[] = new Type[aCount * 2];
- System.arraycopy(aTypes, 0, newATypes, 0, aCount);
- aTypes = newATypes;
- IdentifierToken newANames[] = new IdentifierToken[aCount * 2];
- System.arraycopy(aNames, 0, newANames, 0, aCount);
- aNames = newANames;
- }
- aTypes[aCount] = t;
- aNames[aCount++] = nm;
- }
-
- /**
- * Parse a possibly-empty sequence of modifier keywords.
- * Return the resulting bitmask.
- * Diagnose repeated modifiers, but make no other checks.
- * Only modifiers mentioned in the given bitmask are scanned;
- * an unmatched modifier must be handled by the caller.
- */
- protected int parseModifiers(int mask) throws IOException {
- int mod = 0;
- while (true) {
- if (token==CONST) {
- // const isn't in java, but handle a common C++ usage gently
- env.error(pos, "not.supported", "const");
- scan();
- }
- int nextmod = 0;
- switch (token) {
- case PRIVATE: nextmod = M_PRIVATE; break;
- case PUBLIC: nextmod = M_PUBLIC; break;
- case PROTECTED: nextmod = M_PROTECTED; break;
- case STATIC: nextmod = M_STATIC; break;
- case TRANSIENT: nextmod = M_TRANSIENT; break;
- case FINAL: nextmod = M_FINAL; break;
- case ABSTRACT: nextmod = M_ABSTRACT; break;
- case NATIVE: nextmod = M_NATIVE; break;
- case VOLATILE: nextmod = M_VOLATILE; break;
- case SYNCHRONIZED: nextmod = M_SYNCHRONIZED; break;
- case STRICTFP: nextmod = M_STRICTFP; break;
- }
- if ((nextmod & mask) == 0) {
- break;
- }
- if ((nextmod & mod) != 0) {
- env.error(pos, "repeated.modifier");
- }
- mod |= nextmod;
- scan();
- }
- return mod;
- }
-
- private ClassDefinition curClass;
-
- /**
- * Parse a field.
- */
- protected void parseField() throws SyntaxError, IOException {
-
- // Empty fields are not allowed by the JLS but are accepted by
- // the compiler, and much code has come to rely on this. It has
- // been decided that the language will be extended to legitimize them.
- if (token == SEMICOLON) {
- // empty field
- scan();
- return;
- }
-
- // Optional doc comment
- String doc = scanner.docComment;
-
- // The start of the field
- long p = pos;
-
- // Parse the modifiers
- int mod = parseModifiers(MM_FIELD | MM_METHOD);
-
- // Check for static initializer
- // ie: static { ... }
- // or an instance initializer (w/o the static).
- if ((mod == (mod & M_STATIC)) && (token == LBRACE)) {
- // static initializer
- actions.defineField(p, curClass, doc, mod,
- Type.tMethod(Type.tVoid),
- new IdentifierToken(idClassInit), null, null,
- parseStatement());
- return;
- }
-
- // Check for inner class
- if (token == CLASS || token == INTERFACE) {
- parseNamedClass(mod, CLASS, doc);
- return;
- }
-
- // Parse the type
- p = pos;
- Type t = parseType();
- IdentifierToken id = null;
-
- // Check that the type is followed by an Identifier
- // (the name of the method or the first variable),
- // otherwise it is a constructor.
- switch (token) {
- case IDENT:
- id = scanner.getIdToken();
- p = scan();
- break;
-
- case LPAREN:
- // It is a constructor
- id = new IdentifierToken(idInit);
- if ((mod & M_STRICTFP) != 0)
- env.error(pos, "bad.constructor.modifier");
- break;
-
- default:
- expect(IDENT);
- }
-
- // If the next token is a left-bracket then we
- // are dealing with a method or constructor, otherwise it is
- // a list of variables
- if (token == LPAREN) {
- // It is a method or constructor declaration
- scan();
- aCount = 0;
-
- if (token != RPAREN) {
- // Parse argument type and identifier
- // (arguments (like locals) are allowed to be final)
- int am = parseModifiers(M_FINAL);
- Type at = parseType();
- IdentifierToken an = scanner.getIdToken();
- expect(IDENT);
-
- // Parse optional array specifier, ie: a[][]
- at = parseArrayBrackets(at);
- addArgument(am, at, an);
-
- // If the next token is a comma then there are
- // more arguments
- while (token == COMMA) {
- // Parse argument type and identifier
- scan();
- am = parseModifiers(M_FINAL);
- at = parseType();
- an = scanner.getIdToken();
- expect(IDENT);
-
- // Parse optional array specifier, ie: a[][]
- at = parseArrayBrackets(at);
- addArgument(am, at, an);
- }
- }
- expect(RPAREN);
-
- // Parse optional array sepecifier, ie: foo()[][]
- t = parseArrayBrackets(t);
-
- // copy arguments
- Type atypes[] = new Type[aCount];
- System.arraycopy(aTypes, 0, atypes, 0, aCount);
-
- IdentifierToken anames[] = new IdentifierToken[aCount];
- System.arraycopy(aNames, 0, anames, 0, aCount);
-
- // Construct the type signature
- t = Type.tMethod(t, atypes);
-
- // Parse and ignore throws clause
- IdentifierToken exp[] = null;
- if (token == THROWS) {
- Vector v = new Vector<>();
- scan();
- v.addElement(parseName(false));
- while (token == COMMA) {
- scan();
- v.addElement(parseName(false));
- }
-
- exp = new IdentifierToken[v.size()];
- v.copyInto(exp);
- }
-
- // Check if it is a method definition or a method declaration
- // ie: foo() {...} or foo();
- switch (token) {
- case LBRACE: // It's a method definition
-
- // Set the state of FP strictness for the body of the method
- int oldFPstate = FPstate;
- if ((mod & M_STRICTFP)!=0) {
- FPstate = M_STRICTFP;
- } else {
- mod |= FPstate & M_STRICTFP;
- }
-
- actions.defineField(p, curClass, doc, mod, t, id,
- anames, exp, parseStatement());
-
- FPstate = oldFPstate;
-
- break;
-
- case SEMICOLON:
- scan();
- actions.defineField(p, curClass, doc, mod, t, id,
- anames, exp, null);
- break;
-
- default:
- // really expected a statement body here
- if ((mod & (M_NATIVE | M_ABSTRACT)) == 0) {
- expect(LBRACE);
- } else {
- expect(SEMICOLON);
- }
- }
- return;
- }
-
- // It is a list of instance variables
- while (true) {
- p = pos; // get the current position
- // parse the array brackets (if any)
- // ie: var[][][]
- Type vt = parseArrayBrackets(t);
-
- // Parse the optional initializer
- Node init = null;
- if (token == ASSIGN) {
- scan();
- init = parseExpression();
- }
-
- // Define the variable
- actions.defineField(p, curClass, doc, mod, vt, id,
- null, null, init);
-
- // If the next token is a comma, then there is more
- if (token != COMMA) {
- expect(SEMICOLON);
- return;
- }
- scan();
-
- // The next token must be an identifier
- id = scanner.getIdToken();
- expect(IDENT);
- }
- }
-
- /**
- * Recover after a syntax error in a field. This involves
- * discarding tokens until an EOF or a possible legal
- * continuation is encountered.
- */
- protected void recoverField(ClassDefinition newClass) throws SyntaxError, IOException {
- while (true) {
- switch (token) {
- case EOF:
- case STATIC:
- case FINAL:
- case PUBLIC:
- case PRIVATE:
- case SYNCHRONIZED:
- case TRANSIENT:
-
- case VOID:
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case SHORT:
- case INT:
- case FLOAT:
- case LONG:
- case DOUBLE:
- // possible begin of a field, continue
- return;
-
- case LBRACE:
- match(LBRACE, RBRACE);
- scan();
- break;
-
- case LPAREN:
- match(LPAREN, RPAREN);
- scan();
- break;
-
- case LSQBRACKET:
- match(LSQBRACKET, RSQBRACKET);
- scan();
- break;
-
- case RBRACE:
- case INTERFACE:
- case CLASS:
- case IMPORT:
- case PACKAGE:
- // begin of something outside a class, panic more
- actions.endClass(pos, newClass);
- throw new SyntaxError();
-
- default:
- // don't know what to do, skip
- scan();
- break;
- }
- }
- }
-
- /**
- * Parse a top-level class or interface declaration.
- */
- protected void parseClass() throws SyntaxError, IOException {
- String doc = scanner.docComment;
-
- // Parse the modifiers.
- int mod = parseModifiers(MM_CLASS | MM_MEMBER);
-
- parseNamedClass(mod, PACKAGE, doc);
- }
-
- // Current strict/default state of floating point. This is
- // set and reset with a stack discipline around methods and named
- // classes. Only M_STRICTFP may be set in this word. try...
- // finally is not needed to protect setting and resetting because
- // there are no error messages based on FPstate.
- private int FPstate = 0;
-
- /**
- * Parse a block-local class or interface declaration.
- */
- protected Statement parseLocalClass(int mod) throws SyntaxError, IOException {
- long p = pos;
- ClassDefinition body = parseNamedClass(M_LOCAL | mod, STAT, null);
- Statement ds[] = {
- new VarDeclarationStatement(p, new LocalMember(body), null)
- };
- Expression type = new TypeExpression(p, body.getType());
- return new DeclarationStatement(p, 0, type, ds);
- }
-
- /**
- * Parse a named class or interface declaration,
- * starting at "class" or "interface".
- * @arg ctx Syntactic context of the class, one of {PACKAGE CLASS STAT EXPR}.
- */
- protected ClassDefinition parseNamedClass(int mod, int ctx, String doc) throws SyntaxError, IOException {
- // Parse class/interface
- switch (token) {
- case INTERFACE:
- scan();
- mod |= M_INTERFACE;
- break;
-
- case CLASS:
- scan();
- break;
-
- default:
- env.error(pos, "class.expected");
- break;
- }
-
- int oldFPstate = FPstate;
- if ((mod & M_STRICTFP)!=0) {
- FPstate = M_STRICTFP;
- } else {
- // The & (...) isn't really necessary here because we do maintain
- // the invariant that FPstate has no extra bits set.
- mod |= FPstate & M_STRICTFP;
- }
-
- // Parse the class name
- IdentifierToken nm = scanner.getIdToken();
- long p = pos;
- expect(IDENT);
-
- Vector ext = new Vector<>();
- Vector impl = new Vector<>();
- parseInheritance(ext, impl);
-
- ClassDefinition tmp = parseClassBody(nm, mod, ctx, doc, ext, impl, p);
-
- FPstate = oldFPstate;
-
- return tmp;
- }
-
- protected void parseInheritance(Vector ext, Vector impl) throws SyntaxError, IOException {
- // Parse extends clause
- if (token == EXTENDS) {
- scan();
- ext.addElement(parseName(false));
- while (token == COMMA) {
- scan();
- ext.addElement(parseName(false));
- }
- }
-
- // Parse implements clause
- if (token == IMPLEMENTS) {
- scan();
- impl.addElement(parseName(false));
- while (token == COMMA) {
- scan();
- impl.addElement(parseName(false));
- }
- }
- }
-
- /**
- * Parse the body of a class or interface declaration,
- * starting at the left brace.
- */
- protected ClassDefinition parseClassBody(IdentifierToken nm, int mod,
- int ctx, String doc,
- Vector ext, Vector impl, long p
- ) throws SyntaxError, IOException {
- // Decide which is the super class
- IdentifierToken sup = null;
- if ((mod & M_INTERFACE) != 0) {
- if (impl.size() > 0) {
- env.error(impl.elementAt(0).getWhere(),
- "intf.impl.intf");
- }
- impl = ext;
- } else {
- if (ext.size() > 0) {
- if (ext.size() > 1) {
- env.error(ext.elementAt(1).getWhere(),
- "multiple.inherit");
- }
- sup = ext.elementAt(0);
- }
- }
-
- ClassDefinition oldClass = curClass;
-
- // Begin a new class
- IdentifierToken implids[] = new IdentifierToken[impl.size()];
- impl.copyInto(implids);
- ClassDefinition newClass =
- actions.beginClass(p, doc, mod, nm, sup, implids);
-
- // Parse fields
- expect(LBRACE);
- while ((token != EOF) && (token != RBRACE)) {
- try {
- curClass = newClass;
- parseField();
- } catch (SyntaxError e) {
- recoverField(newClass);
- } finally {
- curClass = oldClass;
- }
- }
- expect(RBRACE);
-
- // End the class
- actions.endClass(scanner.prevPos, newClass);
- return newClass;
- }
-
- /**
- * Recover after a syntax error in the file.
- * This involves discarding tokens until an EOF
- * or a possible legal continuation is encountered.
- */
- protected void recoverFile() throws IOException {
- while (true) {
- switch (token) {
- case CLASS:
- case INTERFACE:
- // Start of a new source file statement, continue
- return;
-
- case LBRACE:
- match(LBRACE, RBRACE);
- scan();
- break;
-
- case LPAREN:
- match(LPAREN, RPAREN);
- scan();
- break;
-
- case LSQBRACKET:
- match(LSQBRACKET, RSQBRACKET);
- scan();
- break;
-
- case EOF:
- return;
-
- default:
- // Don't know what to do, skip
- scan();
- break;
- }
- }
- }
-
- /**
- * Parse an Java file.
- */
- public void parseFile() {
- try {
- try {
- if (token == PACKAGE) {
- // Package statement
- long p = scan();
- IdentifierToken id = parseName(false);
- expect(SEMICOLON);
- actions.packageDeclaration(p, id);
- }
- } catch (SyntaxError e) {
- recoverFile();
- }
- while (token == IMPORT) {
- try{
- // Import statement
- long p = scan();
- IdentifierToken id = parseName(true);
- expect(SEMICOLON);
- if (id.id.getName().equals(idStar)) {
- id.id = id.id.getQualifier();
- actions.importPackage(p, id);
- } else {
- actions.importClass(p, id);
- }
- } catch (SyntaxError e) {
- recoverFile();
- }
- }
-
- while (token != EOF) {
- try {
- switch (token) {
- case FINAL:
- case PUBLIC:
- case PRIVATE:
- case ABSTRACT:
- case CLASS:
- case INTERFACE:
- case STRICTFP:
- // Start of a class
- parseClass();
- break;
-
- case SEMICOLON:
- // Bogus semicolon.
- // According to the JLS (7.6,19.6), a TypeDeclaration
- // may consist of a single semicolon, however, this
- // usage is discouraged (JLS 7.6). In contrast,
- // a FieldDeclaration may not be empty, and is flagged
- // as an error. See parseField above.
- scan();
- break;
-
- case EOF:
- // The end
- return;
-
- default:
- // Oops
- env.error(pos, "toplevel.expected");
- throw new SyntaxError();
- }
- } catch (SyntaxError e) {
- recoverFile();
- }
- }
- } catch (IOException e) {
- env.error(pos, "io.exception", env.getSource());
- return;
- }
- }
-
- /**
- * Usually this.scanner == (Scanner)this.
- * However, a delegate scanner can produce tokens for this parser,
- * in which case (Scanner)this is unused,
- * except for this.token and this.pos
- * instance variables which are filled from the real scanner
- * by this.scan() and the constructor.
- */
- protected Scanner scanner;
-
- // Design Note: We ought to disinherit Parser from Scanner.
- // We also should split out the interface ParserActions from
- // Parser, and make BatchParser implement ParserActions,
- // not extend Parser. This would split scanning, parsing,
- // and class building into distinct responsibility areas.
- // (Perhaps tree building could be virtualized too.)
-
- public long scan() throws IOException {
- if (scanner != this && scanner != null) {
- long result = scanner.scan();
- ((Scanner)this).token = scanner.token;
- ((Scanner)this).pos = scanner.pos;
- return result;
- }
- return super.scan();
- }
-
- public void match(int open, int close) throws IOException {
- if (scanner != this) {
- scanner.match(open, close);
- ((Scanner)this).token = scanner.token;
- ((Scanner)this).pos = scanner.pos;
- return;
- }
- super.match(open, close);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ParserActions.java b/src/jdk.rmic/share/classes/sun/tools/java/ParserActions.java
deleted file mode 100644
index 578c2da36d5..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ParserActions.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, 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 sun.tools.java;
-
-import sun.tools.tree.*;
-
-/**
- * This is the protocol by which a Parser makes callbacks
- * to the later phases of the compiler.
- *
- * (As a backwards compatibility trick, Parser implements
- * this protocol, so that an instance of a Parser subclass
- * can handle its own actions. The preferred way to use a
- * Parser, however, is to instantiate it directly with a
- * reference to your own ParserActions implementation.)
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author John R. Rose
- */
-public interface ParserActions {
- /**
- * package declaration
- */
- void packageDeclaration(long off, IdentifierToken nm);
-
- /**
- * import class
- */
- void importClass(long off, IdentifierToken nm);
-
- /**
- * import package
- */
- void importPackage(long off, IdentifierToken nm);
-
- /**
- * Define class
- * @return a cookie for the class
- * This cookie is used by the parser when calling defineField
- * and endClass, and is not examined otherwise.
- */
- ClassDefinition beginClass(long off, String doc,
- int mod, IdentifierToken nm,
- IdentifierToken sup, IdentifierToken impl[]);
-
-
- /**
- * End class
- * @param c a cookie returned by the corresponding beginClass call
- */
- void endClass(long off, ClassDefinition c);
-
- /**
- * Define a field
- * @param c a cookie returned by the corresponding beginClass call
- */
- void defineField(long where, ClassDefinition c,
- String doc, int mod, Type t,
- IdentifierToken nm, IdentifierToken args[],
- IdentifierToken exp[], Node val);
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/PathClassFile.java b/src/jdk.rmic/share/classes/sun/tools/java/PathClassFile.java
deleted file mode 100644
index 315c0bd77df..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/PathClassFile.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2014, 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 sun.tools.java;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-/**
- * This class is used to represent a file loaded from the class path, and
- * is represented by nio Path.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class PathClassFile extends ClassFile {
- private final Path path;
- private final BasicFileAttributes attrs;
-
- /**
- * Constructor for instance representing a Path
- */
- public PathClassFile(Path path) {
- this.path = path;
- try {
- this.attrs = Files.readAttributes(path, BasicFileAttributes.class);
- } catch (IOException ioExp) {
- throw new UncheckedIOException(ioExp);
- }
- }
-
- @Override
- public boolean isZipped() {
- return false;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return Files.newInputStream(path);
- }
-
- @Override
- public boolean exists() {
- return true;
- }
-
- @Override
- public boolean isDirectory() {
- return attrs.isDirectory();
- }
-
- @Override
- public long lastModified() {
- return attrs.lastModifiedTime().toMillis();
- }
-
- @Override
- public String getPath() {
- return path.toUri().toString();
- }
-
- @Override
- public String getName() {
- return path.getFileName().toString();
- }
-
-//JCOV
- @Override
- public String getAbsoluteName() {
- return path.toAbsolutePath().toUri().toString();
- }
-// end JCOV
-
- @Override
- public long length() {
- return attrs.size();
- }
-
- @Override
- public String toString() {
- return path.toString();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
deleted file mode 100644
index 56fe5e3a4eb..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * Copyright (c) 1998, 2019, 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 sun.tools.java;
-
-/**
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-public interface RuntimeConstants {
-
- /* Signature Characters */
- char SIGC_VOID = 'V';
- String SIG_VOID = "V";
- char SIGC_BOOLEAN = 'Z';
- String SIG_BOOLEAN = "Z";
- char SIGC_BYTE = 'B';
- String SIG_BYTE = "B";
- char SIGC_CHAR = 'C';
- String SIG_CHAR = "C";
- char SIGC_SHORT = 'S';
- String SIG_SHORT = "S";
- char SIGC_INT = 'I';
- String SIG_INT = "I";
- char SIGC_LONG = 'J';
- String SIG_LONG = "J";
- char SIGC_FLOAT = 'F';
- String SIG_FLOAT = "F";
- char SIGC_DOUBLE = 'D';
- String SIG_DOUBLE = "D";
- char SIGC_ARRAY = '[';
- String SIG_ARRAY = "[";
- char SIGC_CLASS = 'L';
- String SIG_CLASS = "L";
- char SIGC_METHOD = '(';
- String SIG_METHOD = "(";
- char SIGC_ENDCLASS = ';';
- String SIG_ENDCLASS = ";";
- char SIGC_ENDMETHOD = ')';
- String SIG_ENDMETHOD = ")";
- char SIGC_PACKAGE = '/';
- String SIG_PACKAGE = "/";
-
- /* Class File Constants */
- int JAVA_MAGIC = 0xcafebabe;
- int JAVA_MIN_SUPPORTED_VERSION = 45;
- int JAVA_MAX_SUPPORTED_VERSION = 59;
- int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
- int JAVA_MIN_PREVIEW_MAJOR_VERSION = 55; // preview intro'd in JDK 11
- int JAVA_PREVIEW_MINOR_VERSION = 0xffff;
-
- /* Generate class file version for 1.1 by default */
- int JAVA_DEFAULT_VERSION = 45;
- int JAVA_DEFAULT_MINOR_VERSION = 3;
-
- /* Constant table */
- int CONSTANT_UTF8 = 1;
- int CONSTANT_UNICODE = 2;
- int CONSTANT_INTEGER = 3;
- int CONSTANT_FLOAT = 4;
- int CONSTANT_LONG = 5;
- int CONSTANT_DOUBLE = 6;
- int CONSTANT_CLASS = 7;
- int CONSTANT_STRING = 8;
- int CONSTANT_FIELD = 9;
- int CONSTANT_METHOD = 10;
- int CONSTANT_INTERFACEMETHOD = 11;
- int CONSTANT_NAMEANDTYPE = 12;
- int CONSTANT_METHODHANDLE = 15;
- int CONSTANT_METHODTYPE = 16;
- int CONSTANT_INVOKEDYNAMIC = 18;
-
- /* Access and modifier flags */
- int ACC_PUBLIC = 0x00000001;
- int ACC_PRIVATE = 0x00000002;
- int ACC_PROTECTED = 0x00000004;
- int ACC_STATIC = 0x00000008;
- int ACC_FINAL = 0x00000010;
- int ACC_SYNCHRONIZED = 0x00000020;
- int ACC_VOLATILE = 0x00000040;
- int ACC_TRANSIENT = 0x00000080;
- int ACC_NATIVE = 0x00000100;
- int ACC_INTERFACE = 0x00000200;
- int ACC_ABSTRACT = 0x00000400;
- int ACC_SUPER = 0x00000020;
- int ACC_STRICT = 0x00000800;
-
- /* Type codes */
- int T_CLASS = 0x00000002;
- int T_BOOLEAN = 0x00000004;
- int T_CHAR = 0x00000005;
- int T_FLOAT = 0x00000006;
- int T_DOUBLE = 0x00000007;
- int T_BYTE = 0x00000008;
- int T_SHORT = 0x00000009;
- int T_INT = 0x0000000a;
- int T_LONG = 0x0000000b;
-
- /* Opcodes */
- int opc_try = -3;
- int opc_dead = -2;
- int opc_label = -1;
- int opc_nop = 0;
- int opc_aconst_null = 1;
- int opc_iconst_m1 = 2;
- int opc_iconst_0 = 3;
- int opc_iconst_1 = 4;
- int opc_iconst_2 = 5;
- int opc_iconst_3 = 6;
- int opc_iconst_4 = 7;
- int opc_iconst_5 = 8;
- int opc_lconst_0 = 9;
- int opc_lconst_1 = 10;
- int opc_fconst_0 = 11;
- int opc_fconst_1 = 12;
- int opc_fconst_2 = 13;
- int opc_dconst_0 = 14;
- int opc_dconst_1 = 15;
- int opc_bipush = 16;
- int opc_sipush = 17;
- int opc_ldc = 18;
- int opc_ldc_w = 19;
- int opc_ldc2_w = 20;
- int opc_iload = 21;
- int opc_lload = 22;
- int opc_fload = 23;
- int opc_dload = 24;
- int opc_aload = 25;
- int opc_iload_0 = 26;
- int opc_iload_1 = 27;
- int opc_iload_2 = 28;
- int opc_iload_3 = 29;
- int opc_lload_0 = 30;
- int opc_lload_1 = 31;
- int opc_lload_2 = 32;
- int opc_lload_3 = 33;
- int opc_fload_0 = 34;
- int opc_fload_1 = 35;
- int opc_fload_2 = 36;
- int opc_fload_3 = 37;
- int opc_dload_0 = 38;
- int opc_dload_1 = 39;
- int opc_dload_2 = 40;
- int opc_dload_3 = 41;
- int opc_aload_0 = 42;
- int opc_aload_1 = 43;
- int opc_aload_2 = 44;
- int opc_aload_3 = 45;
- int opc_iaload = 46;
- int opc_laload = 47;
- int opc_faload = 48;
- int opc_daload = 49;
- int opc_aaload = 50;
- int opc_baload = 51;
- int opc_caload = 52;
- int opc_saload = 53;
- int opc_istore = 54;
- int opc_lstore = 55;
- int opc_fstore = 56;
- int opc_dstore = 57;
- int opc_astore = 58;
- int opc_istore_0 = 59;
- int opc_istore_1 = 60;
- int opc_istore_2 = 61;
- int opc_istore_3 = 62;
- int opc_lstore_0 = 63;
- int opc_lstore_1 = 64;
- int opc_lstore_2 = 65;
- int opc_lstore_3 = 66;
- int opc_fstore_0 = 67;
- int opc_fstore_1 = 68;
- int opc_fstore_2 = 69;
- int opc_fstore_3 = 70;
- int opc_dstore_0 = 71;
- int opc_dstore_1 = 72;
- int opc_dstore_2 = 73;
- int opc_dstore_3 = 74;
- int opc_astore_0 = 75;
- int opc_astore_1 = 76;
- int opc_astore_2 = 77;
- int opc_astore_3 = 78;
- int opc_iastore = 79;
- int opc_lastore = 80;
- int opc_fastore = 81;
- int opc_dastore = 82;
- int opc_aastore = 83;
- int opc_bastore = 84;
- int opc_castore = 85;
- int opc_sastore = 86;
- int opc_pop = 87;
- int opc_pop2 = 88;
- int opc_dup = 89;
- int opc_dup_x1 = 90;
- int opc_dup_x2 = 91;
- int opc_dup2 = 92;
- int opc_dup2_x1 = 93;
- int opc_dup2_x2 = 94;
- int opc_swap = 95;
- int opc_iadd = 96;
- int opc_ladd = 97;
- int opc_fadd = 98;
- int opc_dadd = 99;
- int opc_isub = 100;
- int opc_lsub = 101;
- int opc_fsub = 102;
- int opc_dsub = 103;
- int opc_imul = 104;
- int opc_lmul = 105;
- int opc_fmul = 106;
- int opc_dmul = 107;
- int opc_idiv = 108;
- int opc_ldiv = 109;
- int opc_fdiv = 110;
- int opc_ddiv = 111;
- int opc_irem = 112;
- int opc_lrem = 113;
- int opc_frem = 114;
- int opc_drem = 115;
- int opc_ineg = 116;
- int opc_lneg = 117;
- int opc_fneg = 118;
- int opc_dneg = 119;
- int opc_ishl = 120;
- int opc_lshl = 121;
- int opc_ishr = 122;
- int opc_lshr = 123;
- int opc_iushr = 124;
- int opc_lushr = 125;
- int opc_iand = 126;
- int opc_land = 127;
- int opc_ior = 128;
- int opc_lor = 129;
- int opc_ixor = 130;
- int opc_lxor = 131;
- int opc_iinc = 132;
- int opc_i2l = 133;
- int opc_i2f = 134;
- int opc_i2d = 135;
- int opc_l2i = 136;
- int opc_l2f = 137;
- int opc_l2d = 138;
- int opc_f2i = 139;
- int opc_f2l = 140;
- int opc_f2d = 141;
- int opc_d2i = 142;
- int opc_d2l = 143;
- int opc_d2f = 144;
- int opc_i2b = 145;
- int opc_i2c = 146;
- int opc_i2s = 147;
- int opc_lcmp = 148;
- int opc_fcmpl = 149;
- int opc_fcmpg = 150;
- int opc_dcmpl = 151;
- int opc_dcmpg = 152;
- int opc_ifeq = 153;
- int opc_ifne = 154;
- int opc_iflt = 155;
- int opc_ifge = 156;
- int opc_ifgt = 157;
- int opc_ifle = 158;
- int opc_if_icmpeq = 159;
- int opc_if_icmpne = 160;
- int opc_if_icmplt = 161;
- int opc_if_icmpge = 162;
- int opc_if_icmpgt = 163;
- int opc_if_icmple = 164;
- int opc_if_acmpeq = 165;
- int opc_if_acmpne = 166;
- int opc_goto = 167;
- int opc_jsr = 168;
- int opc_ret = 169;
- int opc_tableswitch = 170;
- int opc_lookupswitch = 171;
- int opc_ireturn = 172;
- int opc_lreturn = 173;
- int opc_freturn = 174;
- int opc_dreturn = 175;
- int opc_areturn = 176;
- int opc_return = 177;
- int opc_getstatic = 178;
- int opc_putstatic = 179;
- int opc_getfield = 180;
- int opc_putfield = 181;
- int opc_invokevirtual = 182;
- int opc_invokespecial = 183;
- int opc_invokestatic = 184;
- int opc_invokeinterface = 185;
- int opc_invokedynamic = 186;
- int opc_new = 187;
- int opc_newarray = 188;
- int opc_anewarray = 189;
- int opc_arraylength = 190;
- int opc_athrow = 191;
- int opc_checkcast = 192;
- int opc_instanceof = 193;
- int opc_monitorenter = 194;
- int opc_monitorexit = 195;
- int opc_wide = 196;
- int opc_multianewarray = 197;
- int opc_ifnull = 198;
- int opc_ifnonnull = 199;
- int opc_goto_w = 200;
- int opc_jsr_w = 201;
- int opc_breakpoint = 202;
-
- /* Opcode Names */
- String opcNames[] = {
- "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"
- };
-
- /* Opcode Lengths */
- int opcLengths[] = {
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 2,
- 3,
- 2,
- 3,
- 3,
- 2,
- 2,
- 2,
- 2,
- 2,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 2,
- 2,
- 2,
- 2,
- 2,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 3,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 2,
- 99,
- 99,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 3,
- 5,
- 5,
- 3,
- 2,
- 3,
- 1,
- 1,
- 3,
- 3,
- 1,
- 1,
- 0,
- 4,
- 3,
- 3,
- 5,
- 5,
- 1
- };
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Scanner.java b/src/jdk.rmic/share/classes/sun/tools/java/Scanner.java
deleted file mode 100644
index e2112102ae8..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Scanner.java
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * Copyright (c) 1994, 2015, 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 sun.tools.java;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Hashtable;
-
-/**
- * A Scanner for Java tokens. Errors are reported
- * to the environment object.
- *
- * The scanner keeps track of the current token,
- * the value of the current token (if any), and the start
- * position of the current token.
- *
- * The scan() method advances the scanner to the next
- * token in the input.
- *
- * The match() method is used to quickly match opening
- * brackets (ie: '(', '{', or '[') with their closing
- * counter part. This is useful during error recovery.
- *
- * An position consists of: ((linenr << WHEREOFFSETBITS) | offset)
- * this means that both the line number and the exact offset into
- * the file are encoded in each position value.
- *
- * The compiler treats either "\n", "\r" or "\r\n" as the
- * end of a line.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-@SuppressWarnings("deprecation")
-public
-class Scanner implements Constants {
- /**
- * The increment for each character.
- */
- public static final long OFFSETINC = 1;
-
- /**
- * The increment for each line.
- */
- public static final long LINEINC = 1L << WHEREOFFSETBITS;
-
- /**
- * End of input
- */
- public static final int EOF = -1;
-
- /**
- * Where errors are reported
- */
- public Environment env;
-
- /**
- * Input reader
- */
- protected ScannerInputReader in;
-
- /**
- * If true, present all comments as tokens.
- * Contents are not saved, but positions are recorded accurately,
- * so the comment can be recovered from the text.
- * Line terminations are also returned as comment tokens,
- * and may be distinguished by their start and end positions,
- * which are equal (meaning, these tokens contain no chars).
- */
- public boolean scanComments = false;
-
- /**
- * Current token
- */
- public int token;
-
- /**
- * The position of the current token
- */
- public long pos;
-
- /**
- * The position of the previous token
- */
- public long prevPos;
-
- /**
- * The current character
- */
- protected int ch;
-
- /*
- * Token values.
- */
- public char charValue;
- public int intValue;
- public long longValue;
- public float floatValue;
- public double doubleValue;
- public String stringValue;
- public Identifier idValue;
- public int radix; // Radix, when reading int or long
-
- /*
- * A doc comment preceding the most recent token
- */
- public String docComment;
-
- /*
- * A growable character buffer.
- */
- private int count;
- private char buffer[] = new char[1024];
- private void growBuffer() {
- char newBuffer[] = new char[buffer.length * 2];
- System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
- buffer = newBuffer;
- }
-
- // The following two methods have been hand-inlined in
- // scanDocComment. If you make changes here, you should
- // check to see if scanDocComment also needs modification.
- private void putc(int ch) {
- if (count == buffer.length) {
- growBuffer();
- }
- buffer[count++] = (char)ch;
- }
-
- private String bufferString() {
- return new String(buffer, 0, count);
- }
-
- /**
- * Create a scanner to scan an input stream.
- */
- public Scanner(Environment env, InputStream in) throws IOException {
- this.env = env;
- useInputStream(in);
- }
-
- /**
- * Setup input from the given input stream,
- * and scan the first token from it.
- */
- protected void useInputStream(InputStream in) throws IOException {
- try {
- this.in = new ScannerInputReader(env, in);
- } catch (Exception e) {
- env.setCharacterEncoding(null);
- this.in = new ScannerInputReader(env, in);
- }
-
- ch = this.in.read();
- prevPos = this.in.pos;
-
- scan();
- }
-
- /**
- * Create a scanner to scan an input stream.
- */
- protected Scanner(Environment env) {
- this.env = env;
- // Expect the subclass to call useInputStream at the right time.
- }
-
- /**
- * Define a keyword.
- */
- private static void defineKeyword(int val) {
- Identifier.lookup(opNames[val]).setType(val);
- }
-
- /**
- * Initialized keyword and token Hashtables
- */
- static {
- // Statement keywords
- defineKeyword(FOR);
- defineKeyword(IF);
- defineKeyword(ELSE);
- defineKeyword(WHILE);
- defineKeyword(DO);
- defineKeyword(SWITCH);
- defineKeyword(CASE);
- defineKeyword(DEFAULT);
- defineKeyword(BREAK);
- defineKeyword(CONTINUE);
- defineKeyword(RETURN);
- defineKeyword(TRY);
- defineKeyword(CATCH);
- defineKeyword(FINALLY);
- defineKeyword(THROW);
-
- // Type defineKeywords
- defineKeyword(BYTE);
- defineKeyword(CHAR);
- defineKeyword(SHORT);
- defineKeyword(INT);
- defineKeyword(LONG);
- defineKeyword(FLOAT);
- defineKeyword(DOUBLE);
- defineKeyword(VOID);
- defineKeyword(BOOLEAN);
-
- // Expression keywords
- defineKeyword(INSTANCEOF);
- defineKeyword(TRUE);
- defineKeyword(FALSE);
- defineKeyword(NEW);
- defineKeyword(THIS);
- defineKeyword(SUPER);
- defineKeyword(NULL);
-
- // Declaration keywords
- defineKeyword(IMPORT);
- defineKeyword(CLASS);
- defineKeyword(EXTENDS);
- defineKeyword(IMPLEMENTS);
- defineKeyword(INTERFACE);
- defineKeyword(PACKAGE);
- defineKeyword(THROWS);
-
- // Modifier keywords
- defineKeyword(PRIVATE);
- defineKeyword(PUBLIC);
- defineKeyword(PROTECTED);
- defineKeyword(STATIC);
- defineKeyword(TRANSIENT);
- defineKeyword(SYNCHRONIZED);
- defineKeyword(NATIVE);
- defineKeyword(ABSTRACT);
- defineKeyword(VOLATILE);
- defineKeyword(FINAL);
- defineKeyword(STRICTFP);
-
- // reserved keywords
- defineKeyword(CONST);
- defineKeyword(GOTO);
- }
-
- /**
- * Scan a comment. This method should be
- * called once the initial /, * and the next
- * character have been read.
- */
- private void skipComment() throws IOException {
- while (true) {
- switch (ch) {
- case EOF:
- env.error(pos, "eof.in.comment");
- return;
-
- case '*':
- if ((ch = in.read()) == '/') {
- ch = in.read();
- return;
- }
- break;
-
- default:
- ch = in.read();
- break;
- }
- }
- }
-
- /**
- * Scan a doc comment. This method should be called
- * once the initial /, * and * have been read. It gathers
- * the content of the comment (witout leading spaces and '*'s)
- * in the string buffer.
- */
- private String scanDocComment() throws IOException {
- // Note: this method has been hand-optimized to yield
- // better performance. This was done after it was noted
- // that javadoc spent a great deal of its time here.
- // This should also help the performance of the compiler
- // as well -- it scans the doc comments to find
- // @deprecated tags.
- //
- // The logic of the method has been completely rewritten
- // to avoid the use of flags that need to be looked at
- // for every character read. Members that are accessed
- // more than once have been stored in local variables.
- // The methods putc() and bufferString() have been
- // inlined by hand. Extra cases have been added to
- // switch statements to trick the compiler into generating
- // a tableswitch instead of a lookupswitch.
- //
- // This implementation aims to preserve the previous
- // behavior of this method.
-
- int c;
-
- // Put `in' in a local variable.
- final ScannerInputReader in = this.in;
-
- // We maintain the buffer locally rather than calling putc().
- char[] buffer = this.buffer;
- int count = 0;
-
- // We are called pointing at the second star of the doc
- // comment:
- //
- // Input: /** the rest of the comment ... */
- // ^
- //
- // We rely on this in the code below.
-
- // Consume any number of stars.
- while ((c = in.read()) == '*')
- ;
-
- // Is the comment of the form /**/, /***/, /****/, etc.?
- if (c == '/') {
- // Set ch and return
- ch = in.read();
- return "";
- }
-
- // Skip a newline on the first line of the comment.
- if (c == '\n') {
- c = in.read();
- }
-
- outerLoop:
- // The outerLoop processes the doc comment, looping once
- // for each line. For each line, it first strips off
- // whitespace, then it consumes any stars, then it
- // puts the rest of the line into our buffer.
- while (true) {
-
- // The wsLoop consumes whitespace from the beginning
- // of each line.
- wsLoop:
- while (true) {
- switch (c) {
- case ' ':
- case '\t':
- // We could check for other forms of whitespace
- // as well, but this is left as is for minimum
- // disturbance of functionality.
- //
- // Just skip whitespace.
- c = in.read();
- break;
-
- // We have added extra cases here to trick the
- // compiler into using a tableswitch instead of
- // a lookupswitch. They can be removed without
- // a change in meaning.
- case 10: case 11: case 12: case 13: case 14: case 15:
- case 16: case 17: case 18: case 19: case 20: case 21:
- case 22: case 23: case 24: case 25: case 26: case 27:
- case 28: case 29: case 30: case 31:
- default:
- // We've seen something that isn't whitespace,
- // jump out.
- break wsLoop;
- }
- } // end wsLoop.
-
- // Are there stars here? If so, consume them all
- // and check for the end of comment.
- if (c == '*') {
- // Skip all of the stars...
- do {
- c = in.read();
- } while (c == '*');
-
- // ...then check for the closing slash.
- if (c == '/') {
- // We're done with the doc comment.
- // Set ch and break out.
- ch = in.read();
- break outerLoop;
- }
- }
-
- // The textLoop processes the rest of the characters
- // on the line, adding them to our buffer.
- textLoop:
- while (true) {
- switch (c) {
- case EOF:
- // We've seen a premature EOF. Break out
- // of the loop.
- env.error(pos, "eof.in.comment");
- ch = EOF;
- break outerLoop;
-
- case '*':
- // Is this just a star? Or is this the
- // end of a comment?
- c = in.read();
- if (c == '/') {
- // This is the end of the comment,
- // set ch and return our buffer.
- ch = in.read();
- break outerLoop;
- }
- // This is just an ordinary star. Add it to
- // the buffer.
- if (count == buffer.length) {
- growBuffer();
- buffer = this.buffer;
- }
- buffer[count++] = '*';
- break;
-
- case '\n':
- // We've seen a newline. Add it to our
- // buffer and break out of this loop,
- // starting fresh on a new line.
- if (count == buffer.length) {
- growBuffer();
- buffer = this.buffer;
- }
- buffer[count++] = '\n';
- c = in.read();
- break textLoop;
-
- // Again, the extra cases here are a trick
- // to get the compiler to generate a tableswitch.
- case 0: case 1: case 2: case 3: case 4: case 5:
- case 6: case 7: case 8: case 11: case 12: case 13:
- case 14: case 15: case 16: case 17: case 18: case 19:
- case 20: case 21: case 22: case 23: case 24: case 25:
- case 26: case 27: case 28: case 29: case 30: case 31:
- case 32: case 33: case 34: case 35: case 36: case 37:
- case 38: case 39: case 40:
- default:
- // Add the character to our buffer.
- if (count == buffer.length) {
- growBuffer();
- buffer = this.buffer;
- }
- buffer[count++] = (char)c;
- c = in.read();
- break;
- }
- } // end textLoop
- } // end outerLoop
-
- // We have scanned our doc comment. It is stored in
- // buffer. The previous implementation of scanDocComment
- // stripped off all trailing spaces and stars from the comment.
- // We will do this as well, so as to cause a minimum of
- // disturbance. Is this what we want?
- if (count > 0) {
- int i = count - 1;
- trailLoop:
- while (i > -1) {
- switch (buffer[i]) {
- case ' ':
- case '\t':
- case '*':
- i--;
- break;
- // And again, the extra cases here are a trick
- // to get the compiler to generate a tableswitch.
- case 0: case 1: case 2: case 3: case 4: case 5:
- case 6: case 7: case 8: case 10: case 11: case 12:
- case 13: case 14: case 15: case 16: case 17: case 18:
- case 19: case 20: case 21: case 22: case 23: case 24:
- case 25: case 26: case 27: case 28: case 29: case 30:
- case 31: case 33: case 34: case 35: case 36: case 37:
- case 38: case 39: case 40:
- default:
- break trailLoop;
- }
- }
- count = i + 1;
-
- // Return the text of the doc comment.
- return new String(buffer, 0, count);
- } else {
- return "";
- }
- }
-
- /**
- * Scan a number. The first digit of the number should be the current
- * character. We may be scanning hex, decimal, or octal at this point
- */
- @SuppressWarnings("fallthrough")
- private void scanNumber() throws IOException {
- boolean seenNonOctal = false;
- boolean overflow = false;
- boolean seenDigit = false; // used to detect invalid hex number 0xL
- radix = (ch == '0' ? 8 : 10);
- long value = ch - '0';
- count = 0;
- putc(ch); // save character in buffer
- numberLoop:
- for (;;) {
- switch (ch = in.read()) {
- case '.':
- if (radix == 16)
- break numberLoop; // an illegal character
- scanReal();
- return;
-
- case '8': case '9':
- // We can't yet throw an error if reading an octal. We might
- // discover we're really reading a real.
- seenNonOctal = true;
- // Fall through
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- seenDigit = true;
- putc(ch);
- if (radix == 10) {
- overflow = overflow || (value * 10)/10 != value;
- value = (value * 10) + (ch - '0');
- overflow = overflow || (value - 1 < -1);
- } else if (radix == 8) {
- overflow = overflow || (value >>> 61) != 0;
- value = (value << 3) + (ch - '0');
- } else {
- overflow = overflow || (value >>> 60) != 0;
- value = (value << 4) + (ch - '0');
- }
- break;
-
- case 'd': case 'D': case 'e': case 'E': case 'f': case 'F':
- if (radix != 16) {
- scanReal();
- return;
- }
- // fall through
- case 'a': case 'A': case 'b': case 'B': case 'c': case 'C':
- seenDigit = true;
- putc(ch);
- if (radix != 16)
- break numberLoop; // an illegal character
- overflow = overflow || (value >>> 60) != 0;
- value = (value << 4) + 10 +
- Character.toLowerCase((char)ch) - 'a';
- break;
-
- case 'l': case 'L':
- ch = in.read(); // skip over 'l'
- longValue = value;
- token = LONGVAL;
- break numberLoop;
-
- case 'x': case 'X':
- // if the first character is a '0' and this is the second
- // letter, then read in a hexadecimal number. Otherwise, error.
- if (count == 1 && radix == 8) {
- radix = 16;
- seenDigit = false;
- break;
- } else {
- // we'll get an illegal character error
- break numberLoop;
- }
-
- default:
- intValue = (int)value;
- token = INTVAL;
- break numberLoop;
- }
- } // while true
-
- // We have just finished reading the number. The next thing better
- // not be a letter or digit.
- // Note: There will be deprecation warnings against these uses
- // of Character.isJavaLetterOrDigit and Character.isJavaLetter.
- // Do not fix them yet; allow the compiler to run on pre-JDK1.1 VMs.
- if (Character.isJavaLetterOrDigit((char)ch) || ch == '.') {
- env.error(in.pos, "invalid.number");
- do { ch = in.read(); }
- while (Character.isJavaLetterOrDigit((char)ch) || ch == '.');
- intValue = 0;
- token = INTVAL;
- } else if (radix == 8 && seenNonOctal) {
- // A bogus octal literal.
- intValue = 0;
- token = INTVAL;
- env.error(pos, "invalid.octal.number");
- } else if (radix == 16 && seenDigit == false) {
- // A hex literal with no digits, 0xL, for example.
- intValue = 0;
- token = INTVAL;
- env.error(pos, "invalid.hex.number");
- } else {
- if (token == INTVAL) {
- // Check for overflow. Note that base 10 literals
- // have different rules than base 8 and 16.
- overflow = overflow ||
- (value & 0xFFFFFFFF00000000L) != 0 ||
- (radix == 10 && value > 2147483648L);
-
- if (overflow) {
- intValue = 0;
-
- // Give a specific error message which tells
- // the user the range.
- switch (radix) {
- case 8:
- env.error(pos, "overflow.int.oct");
- break;
- case 10:
- env.error(pos, "overflow.int.dec");
- break;
- case 16:
- env.error(pos, "overflow.int.hex");
- break;
- default:
- throw new CompilerError("invalid radix");
- }
- }
- } else {
- if (overflow) {
- longValue = 0;
-
- // Give a specific error message which tells
- // the user the range.
- switch (radix) {
- case 8:
- env.error(pos, "overflow.long.oct");
- break;
- case 10:
- env.error(pos, "overflow.long.dec");
- break;
- case 16:
- env.error(pos, "overflow.long.hex");
- break;
- default:
- throw new CompilerError("invalid radix");
- }
- }
- }
- }
- }
-
- /**
- * Scan a float. We are either looking at the decimal, or we have already
- * seen it and put it into the buffer. We haven't seen an exponent.
- * Scan a float. Should be called with the current character is either
- * the 'e', 'E' or '.'
- */
- @SuppressWarnings("fallthrough")
- private void scanReal() throws IOException {
- boolean seenExponent = false;
- boolean isSingleFloat = false;
- char lastChar;
- if (ch == '.') {
- putc(ch);
- ch = in.read();
- }
-
- numberLoop:
- for ( ; ; ch = in.read()) {
- switch (ch) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- putc(ch);
- break;
-
- case 'e': case 'E':
- if (seenExponent)
- break numberLoop; // we'll get a format error
- putc(ch);
- seenExponent = true;
- break;
-
- case '+': case '-':
- lastChar = buffer[count - 1];
- if (lastChar != 'e' && lastChar != 'E')
- break numberLoop; // this isn't an error, though!
- putc(ch);
- break;
-
- case 'f': case 'F':
- ch = in.read(); // skip over 'f'
- isSingleFloat = true;
- break numberLoop;
-
- case 'd': case 'D':
- ch = in.read(); // skip over 'd'
- // fall through
- default:
- break numberLoop;
- } // sswitch
- } // loop
-
- // we have just finished reading the number. The next thing better
- // not be a letter or digit.
- if (Character.isJavaLetterOrDigit((char)ch) || ch == '.') {
- env.error(in.pos, "invalid.number");
- do { ch = in.read(); }
- while (Character.isJavaLetterOrDigit((char)ch) || ch == '.');
- doubleValue = 0;
- token = DOUBLEVAL;
- } else {
- token = isSingleFloat ? FLOATVAL : DOUBLEVAL;
- try {
- lastChar = buffer[count - 1];
- if (lastChar == 'e' || lastChar == 'E'
- || lastChar == '+' || lastChar == '-') {
- env.error(in.pos -1, "float.format");
- } else if (isSingleFloat) {
- String string = bufferString();
- floatValue = Float.valueOf(string).floatValue();
- if (Float.isInfinite(floatValue)) {
- env.error(pos, "overflow.float");
- } else if (floatValue == 0 && !looksLikeZero(string)) {
- env.error(pos, "underflow.float");
- }
- } else {
- String string = bufferString();
- doubleValue = Double.valueOf(string).doubleValue();
- if (Double.isInfinite(doubleValue)) {
- env.error(pos, "overflow.double");
- } else if (doubleValue == 0 && !looksLikeZero(string)) {
- env.error(pos, "underflow.double");
- }
- }
- } catch (NumberFormatException ee) {
- env.error(pos, "float.format");
- doubleValue = 0;
- floatValue = 0;
- }
- }
- return;
- }
-
- // We have a token that parses as a number. Is this token possibly zero?
- // i.e. does it have a non-zero value in the mantissa?
- private static boolean looksLikeZero(String token) {
- int length = token.length();
- for (int i = 0; i < length; i++) {
- switch (token.charAt(i)) {
- case 0: case '.':
- continue;
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- return false;
- case 'e': case 'E': case 'f': case 'F':
- return true;
- }
- }
- return true;
- }
-
- /**
- * Scan an escape character.
- * @return the character or -1 if it escaped an
- * end-of-line.
- */
- private int scanEscapeChar() throws IOException {
- long p = in.pos;
-
- switch (ch = in.read()) {
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7': {
- int n = ch - '0';
- for (int i = 2 ; i > 0 ; i--) {
- switch (ch = in.read()) {
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- n = (n << 3) + ch - '0';
- break;
-
- default:
- if (n > 0xFF) {
- env.error(p, "invalid.escape.char");
- }
- return n;
- }
- }
- ch = in.read();
- if (n > 0xFF) {
- env.error(p, "invalid.escape.char");
- }
- return n;
- }
-
- case 'r': ch = in.read(); return '\r';
- case 'n': ch = in.read(); return '\n';
- case 'f': ch = in.read(); return '\f';
- case 'b': ch = in.read(); return '\b';
- case 't': ch = in.read(); return '\t';
- case '\\': ch = in.read(); return '\\';
- case '\"': ch = in.read(); return '\"';
- case '\'': ch = in.read(); return '\'';
- }
-
- env.error(p, "invalid.escape.char");
- ch = in.read();
- return -1;
- }
-
- /**
- * Scan a string. The current character
- * should be the opening " of the string.
- */
- private void scanString() throws IOException {
- token = STRINGVAL;
- count = 0;
- ch = in.read();
-
- // Scan a String
- while (true) {
- switch (ch) {
- case EOF:
- env.error(pos, "eof.in.string");
- stringValue = bufferString();
- return;
-
- case '\r':
- case '\n':
- ch = in.read();
- env.error(pos, "newline.in.string");
- stringValue = bufferString();
- return;
-
- case '"':
- ch = in.read();
- stringValue = bufferString();
- return;
-
- case '\\': {
- int c = scanEscapeChar();
- if (c >= 0) {
- putc((char)c);
- }
- break;
- }
-
- default:
- putc(ch);
- ch = in.read();
- break;
- }
- }
- }
-
- /**
- * Scan a character. The current character should be
- * the opening ' of the character constant.
- */
- private void scanCharacter() throws IOException {
- token = CHARVAL;
-
- switch (ch = in.read()) {
- case '\\':
- int c = scanEscapeChar();
- charValue = (char)((c >= 0) ? c : 0);
- break;
-
- case '\'':
- // There are two standard problems this case deals with. One
- // is the malformed single quote constant (i.e. the programmer
- // uses ''' instead of '\'') and the other is the empty
- // character constant (i.e. ''). Just consume any number of
- // single quotes and emit an error message.
- charValue = 0;
- env.error(pos, "invalid.char.constant");
- ch = in.read();
- while (ch == '\'') {
- ch = in.read();
- }
- return;
-
- case '\r':
- case '\n':
- charValue = 0;
- env.error(pos, "invalid.char.constant");
- return;
-
- default:
- charValue = (char)ch;
- ch = in.read();
- break;
- }
-
- if (ch == '\'') {
- ch = in.read();
- } else {
- env.error(pos, "invalid.char.constant");
- while (true) {
- switch (ch) {
- case '\'':
- ch = in.read();
- return;
- case ';':
- case '\n':
- case EOF:
- return;
- default:
- ch = in.read();
- }
- }
- }
- }
-
- /**
- * Scan an Identifier. The current character should
- * be the first character of the identifier.
- */
- private void scanIdentifier() throws IOException {
- count = 0;
-
- while (true) {
- putc(ch);
- switch (ch = in.read()) {
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case '$': case '_':
- break;
-
- default:
- if (!Character.isJavaLetterOrDigit((char)ch)) {
- idValue = Identifier.lookup(bufferString());
- token = idValue.getType();
- return;
- }
- }
- }
- }
-
- /**
- * The ending position of the current token
- */
- // Note: This should be part of the pos itself.
- public long getEndPos() {
- return in.pos;
- }
-
- /**
- * If the current token is IDENT, return the identifier occurrence.
- * It will be freshly allocated.
- */
- public IdentifierToken getIdToken() {
- return (token != IDENT) ? null : new IdentifierToken(pos, idValue);
- }
-
- /**
- * Scan the next token.
- * @return the position of the previous token.
- */
- public long scan() throws IOException {
- return xscan();
- }
-
- @SuppressWarnings("fallthrough")
- protected long xscan() throws IOException {
- final ScannerInputReader in = this.in;
- long retPos = pos;
- prevPos = in.pos;
- docComment = null;
- while (true) {
- pos = in.pos;
-
- switch (ch) {
- case EOF:
- token = EOF;
- return retPos;
-
- case '\n':
- if (scanComments) {
- ch = ' ';
- // Avoid this path the next time around.
- // Do not just call in.read; we want to present
- // a null token (and also avoid read-ahead).
- token = COMMENT;
- return retPos;
- }
- // Fall through
- case ' ':
- case '\t':
- case '\f':
- ch = in.read();
- break;
-
- case '/':
- switch (ch = in.read()) {
- case '/':
- // Parse a // comment
- while (((ch = in.read()) != EOF) && (ch != '\n'));
- if (scanComments) {
- token = COMMENT;
- return retPos;
- }
- break;
-
- case '*':
- ch = in.read();
- if (ch == '*') {
- docComment = scanDocComment();
- } else {
- skipComment();
- }
- if (scanComments) {
- return retPos;
- }
- break;
-
- case '=':
- ch = in.read();
- token = ASGDIV;
- return retPos;
-
- default:
- token = DIV;
- return retPos;
- }
- break;
-
- case '"':
- scanString();
- return retPos;
-
- case '\'':
- scanCharacter();
- return retPos;
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- scanNumber();
- return retPos;
-
- case '.':
- switch (ch = in.read()) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- count = 0;
- putc('.');
- scanReal();
- break;
- default:
- token = FIELD;
- }
- return retPos;
-
- case '{':
- ch = in.read();
- token = LBRACE;
- return retPos;
-
- case '}':
- ch = in.read();
- token = RBRACE;
- return retPos;
-
- case '(':
- ch = in.read();
- token = LPAREN;
- return retPos;
-
- case ')':
- ch = in.read();
- token = RPAREN;
- return retPos;
-
- case '[':
- ch = in.read();
- token = LSQBRACKET;
- return retPos;
-
- case ']':
- ch = in.read();
- token = RSQBRACKET;
- return retPos;
-
- case ',':
- ch = in.read();
- token = COMMA;
- return retPos;
-
- case ';':
- ch = in.read();
- token = SEMICOLON;
- return retPos;
-
- case '?':
- ch = in.read();
- token = QUESTIONMARK;
- return retPos;
-
- case '~':
- ch = in.read();
- token = BITNOT;
- return retPos;
-
- case ':':
- ch = in.read();
- token = COLON;
- return retPos;
-
- case '-':
- switch (ch = in.read()) {
- case '-':
- ch = in.read();
- token = DEC;
- return retPos;
-
- case '=':
- ch = in.read();
- token = ASGSUB;
- return retPos;
- }
- token = SUB;
- return retPos;
-
- case '+':
- switch (ch = in.read()) {
- case '+':
- ch = in.read();
- token = INC;
- return retPos;
-
- case '=':
- ch = in.read();
- token = ASGADD;
- return retPos;
- }
- token = ADD;
- return retPos;
-
- case '<':
- switch (ch = in.read()) {
- case '<':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = ASGLSHIFT;
- return retPos;
- }
- token = LSHIFT;
- return retPos;
-
- case '=':
- ch = in.read();
- token = LE;
- return retPos;
- }
- token = LT;
- return retPos;
-
- case '>':
- switch (ch = in.read()) {
- case '>':
- switch (ch = in.read()) {
- case '=':
- ch = in.read();
- token = ASGRSHIFT;
- return retPos;
-
- case '>':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = ASGURSHIFT;
- return retPos;
- }
- token = URSHIFT;
- return retPos;
- }
- token = RSHIFT;
- return retPos;
-
- case '=':
- ch = in.read();
- token = GE;
- return retPos;
- }
- token = GT;
- return retPos;
-
- case '|':
- switch (ch = in.read()) {
- case '|':
- ch = in.read();
- token = OR;
- return retPos;
-
- case '=':
- ch = in.read();
- token = ASGBITOR;
- return retPos;
- }
- token = BITOR;
- return retPos;
-
- case '&':
- switch (ch = in.read()) {
- case '&':
- ch = in.read();
- token = AND;
- return retPos;
-
- case '=':
- ch = in.read();
- token = ASGBITAND;
- return retPos;
- }
- token = BITAND;
- return retPos;
-
- case '=':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = EQ;
- return retPos;
- }
- token = ASSIGN;
- return retPos;
-
- case '%':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = ASGREM;
- return retPos;
- }
- token = REM;
- return retPos;
-
- case '^':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = ASGBITXOR;
- return retPos;
- }
- token = BITXOR;
- return retPos;
-
- case '!':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = NE;
- return retPos;
- }
- token = NOT;
- return retPos;
-
- case '*':
- if ((ch = in.read()) == '=') {
- ch = in.read();
- token = ASGMUL;
- return retPos;
- }
- token = MUL;
- return retPos;
-
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case '$': case '_':
- scanIdentifier();
- return retPos;
-
- case '\u001a':
- // Our one concession to DOS.
- if ((ch = in.read()) == EOF) {
- token = EOF;
- return retPos;
- }
- env.error(pos, "funny.char");
- ch = in.read();
- break;
-
-
- default:
- if (Character.isJavaLetter((char)ch)) {
- scanIdentifier();
- return retPos;
- }
- env.error(pos, "funny.char");
- ch = in.read();
- break;
- }
- }
- }
-
- /**
- * Scan to a matching '}', ']' or ')'. The current token must be
- * a '{', '[' or '(';
- */
- public void match(int open, int close) throws IOException {
- int depth = 1;
-
- while (true) {
- scan();
- if (token == open) {
- depth++;
- } else if (token == close) {
- if (--depth == 0) {
- return;
- }
- } else if (token == EOF) {
- env.error(pos, "unbalanced.paren");
- return;
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ScannerInputReader.java b/src/jdk.rmic/share/classes/sun/tools/java/ScannerInputReader.java
deleted file mode 100644
index e57fe78d4da..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ScannerInputReader.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.tools.java;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.BufferedReader;
-import java.io.FilterReader;
-import java.io.UnsupportedEncodingException;
-
-/**
- * An input stream for java programs. The stream treats either "\n", "\r"
- * or "\r\n" as the end of a line, it always returns \n. It also parses
- * UNICODE characters expressed as \uffff. However, if it sees "\\", the
- * second slash cannot begin a unicode sequence. It keeps track of the current
- * position in the input stream.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @author Arthur van Hoff
- */
-
-public
-class ScannerInputReader extends FilterReader implements Constants {
- // A note. This class does not really properly subclass FilterReader.
- // Since this class only overrides the single character read method,
- // and not the multi-character read method, any use of the latter
- // will not work properly. Any attempt to use this code outside of
- // the compiler should take that into account.
- //
- // For efficiency, it might be worth moving this code to Scanner and
- // getting rid of this class.
-
- Environment env;
- long pos;
-
- private long chpos;
- private int pushBack = -1;
-
- public ScannerInputReader(Environment env, InputStream in)
- throws UnsupportedEncodingException
- {
- // ScannerInputStream has been modified to no longer use
- // BufferedReader. It now does its own buffering for
- // performance.
- super(env.getCharacterEncoding() != null ?
- new InputStreamReader(in, env.getCharacterEncoding()) :
- new InputStreamReader(in));
-
- // Start out the buffer empty.
- currentIndex = 0;
- numChars = 0;
-
- this.env = env;
- chpos = Scanner.LINEINC;
- }
-
- //------------------------------------------------------------
- // Buffering code.
-
- // The size of our buffer.
- private static final int BUFFERLEN = 10 * 1024;
-
- // A character buffer.
- private final char[] buffer = new char[BUFFERLEN];
-
- // The index of the next character to be "read" from the buffer.
- private int currentIndex;
-
- // The number of characters in the buffer. -1 if EOF is reached.
- private int numChars;
-
- /**
- * Get the next character from our buffer.
- * Note: this method has been inlined by hand in the `read' method
- * below. Any changes made to this method should be equally applied
- * to that code.
- */
- private int getNextChar() throws IOException {
- // Check to see if we have either run out of characters in our
- // buffer or gotten to EOF on a previous call.
- if (currentIndex >= numChars) {
- numChars = in.read(buffer);
- if (numChars == -1) {
- // We have reached EOF.
- return -1;
- }
-
- // No EOF. currentIndex points to first char in buffer.
- currentIndex = 0;
- }
-
- return buffer[currentIndex++];
- }
-
- //------------------------------------------------------------
-
- public int read(char[] buffer, int off, int len) {
- throw new CompilerError(
- "ScannerInputReader is not a fully implemented reader.");
- }
-
- public int read() throws IOException {
- pos = chpos;
- chpos += Scanner.OFFSETINC;
-
- int c = pushBack;
- if (c == -1) {
- getchar: try {
- // Here the call...
- // c = getNextChar();
- // has been inlined by hand for performance.
-
- if (currentIndex >= numChars) {
- numChars = in.read(buffer);
- if (numChars == -1) {
- // We have reached EOF.
- c = -1;
- break getchar;
- }
-
- // No EOF. currentIndex points to first char in buffer.
- currentIndex = 0;
- }
- c = buffer[currentIndex++];
-
- } catch (java.io.CharConversionException e) {
- env.error(pos, "invalid.encoding.char");
- // this is fatal error
- return -1;
- }
- } else {
- pushBack = -1;
- }
-
- // parse special characters
- switch (c) {
- case -2:
- // -2 is a special code indicating a pushback of a backslash that
- // definitely isn't the start of a unicode sequence.
- return '\\';
-
- case '\\':
- if ((c = getNextChar()) != 'u') {
- pushBack = (c == '\\' ? -2 : c);
- return '\\';
- }
- // we have a unicode sequence
- chpos += Scanner.OFFSETINC;
- while ((c = getNextChar()) == 'u') {
- chpos += Scanner.OFFSETINC;
- }
-
- // unicode escape sequence
- int d = 0;
- for (int i = 0 ; i < 4 ; i++, chpos += Scanner.OFFSETINC, c = getNextChar()) {
- switch (c) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- d = (d << 4) + c - '0';
- break;
-
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- d = (d << 4) + 10 + c - 'a';
- break;
-
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- d = (d << 4) + 10 + c - 'A';
- break;
-
- default:
- env.error(pos, "invalid.escape.char");
- pushBack = c;
- return d;
- }
- }
- pushBack = c;
-
- // To read the following line, switch \ and /...
- // Handle /u000a, /u000A, /u000d, /u000D properly as
- // line terminators as per JLS 3.4, even though they are encoded
- // (this properly respects the order given in JLS 3.2).
- switch (d) {
- case '\n':
- chpos += Scanner.LINEINC;
- return '\n';
- case '\r':
- if ((c = getNextChar()) != '\n') {
- pushBack = c;
- } else {
- chpos += Scanner.OFFSETINC;
- }
- chpos += Scanner.LINEINC;
- return '\n';
- default:
- return d;
- }
-
- case '\n':
- chpos += Scanner.LINEINC;
- return '\n';
-
- case '\r':
- if ((c = getNextChar()) != '\n') {
- pushBack = c;
- } else {
- chpos += Scanner.OFFSETINC;
- }
- chpos += Scanner.LINEINC;
- return '\n';
-
- default:
- return c;
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/SyntaxError.java b/src/jdk.rmic/share/classes/sun/tools/java/SyntaxError.java
deleted file mode 100644
index ab07100c430..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/SyntaxError.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.java;
-
-/**
- * Syntax errors, should always be caught inside the
- * parser for error recovery.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@SuppressWarnings("serial") // JDK implementation class
-public
-class SyntaxError extends Exception {
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/Type.java b/src/jdk.rmic/share/classes/sun/tools/java/Type.java
deleted file mode 100644
index b36b16e4d2f..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/Type.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (c) 1994, 2019, 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 sun.tools.java;
-
-import java.util.Hashtable;
-
-/**
- * This class represents an Java Type.
- *
- * It encapsulates an Java type signature and it provides
- * quick access to the components of the type. Note that
- * all types are hashed into a hashtable (typeHash), that
- * means that each distinct type is only allocated once,
- * saving space and making equality checks cheap.
- *
- * For simple types use the constants defined in this class.
- * (Type.tInt, Type.tShort, ...). To create complex types use
- * the static methods Type.tArray, Type.tMethod or Type.tClass.
- *
- * For classes, arrays and method types a sub class of class
- * type is created which defines the extra type components.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @see ArrayType
- * @see ClassType
- * @see MethodType
- * @author Arthur van Hoff
- */
-public
-class Type implements Constants {
- /**
- * This hashtable is used to cache types
- */
- private static final Hashtable typeHash = new Hashtable<>(231);
-
- /**
- * The TypeCode of this type. The value of this field is one
- * of the TC_* contant values defined in Constants.
- * @see Constants
- */
- protected int typeCode;
-
- /**
- * The TypeSignature of this type. This type signature is
- * equivalent to the runtime type signatures used by the
- * interpreter.
- */
- protected String typeSig;
-
- /*
- * Predefined types.
- */
- public static final Type noArgs[] = new Type[0];
- public static final Type tError = new Type(TC_ERROR, "?");
- public static final Type tPackage = new Type(TC_ERROR, ".");
- public static final Type tNull = new Type(TC_NULL, "*");
- public static final Type tVoid = new Type(TC_VOID, SIG_VOID);
- public static final Type tBoolean = new Type(TC_BOOLEAN, SIG_BOOLEAN);
- public static final Type tByte = new Type(TC_BYTE, SIG_BYTE);
- public static final Type tChar = new Type(TC_CHAR, SIG_CHAR);
- public static final Type tShort = new Type(TC_SHORT, SIG_SHORT);
- public static final Type tInt = new Type(TC_INT, SIG_INT);
- public static final Type tFloat = new Type(TC_FLOAT, SIG_FLOAT);
- public static final Type tLong = new Type(TC_LONG, SIG_LONG);
- public static final Type tDouble = new Type(TC_DOUBLE, SIG_DOUBLE);
- public static final Type tObject = Type.tClass(idJavaLangObject);
- public static final Type tClassDesc = Type.tClass(idJavaLangClass);
- public static final Type tString = Type.tClass(idJavaLangString);
- public static final Type tCloneable = Type.tClass(idJavaLangCloneable);
- public static final Type tSerializable = Type.tClass(idJavaIoSerializable);
-
- /**
- * Create a type given a typecode and a type signature.
- */
- protected Type(int typeCode, String typeSig) {
- this.typeCode = typeCode;
- this.typeSig = typeSig;
- typeHash.put(typeSig, this);
- }
-
- /**
- * Return the Java type signature.
- */
- public final String getTypeSignature() {
- return typeSig;
- }
-
- /**
- * Return the type code.
- */
- public final int getTypeCode() {
- return typeCode;
- }
-
- /**
- * Return the type mask. The bits in this mask correspond
- * to the TM_* constants defined in Constants. Only one bit
- * is set at a type.
- * @see Constants
- */
- public final int getTypeMask() {
- return 1 << typeCode;
- }
-
- /**
- * Check for a certain type.
- */
- public final boolean isType(int tc) {
- return typeCode == tc;
- }
-
- /**
- * Check to see if this is the bogus type "array of void"
- *
- * Although this highly degenerate "type" is not constructable from
- * the grammar, the Parser accepts it. Rather than monkey with the
- * Parser, we check for the bogus type at specific points and give
- * a nice error.
- */
- public boolean isVoidArray() {
- // a void type is not a void array.
- if (!isType(TC_ARRAY)) {
- return false;
- }
- // If this is an array, find out what its element type is.
- Type type = this;
- while (type.isType(TC_ARRAY))
- type = type.getElementType();
-
- return type.isType(TC_VOID);
- }
-
-
- /**
- * Check for a certain set of types.
- */
- public final boolean inMask(int tm) {
- return ((1 << typeCode) & tm) != 0;
- }
-
- /**
- * Create an array type.
- */
- public static synchronized Type tArray(Type elem) {
- String sig = new String(SIG_ARRAY + elem.getTypeSignature());
- Type t = typeHash.get(sig);
- if (t == null) {
- t = new ArrayType(sig, elem);
- }
- return t;
- }
-
- /**
- * Return the element type of an array type. Only works
- * for array types.
- */
- public Type getElementType() {
- throw new CompilerError("getElementType");
- }
-
- /**
- * Return the array dimension. Only works for
- * array types.
- */
- public int getArrayDimension() {
- return 0;
- }
-
- /**
- * Create a class type.
- * @arg className the fully qualified class name
- */
- public static synchronized Type tClass(Identifier className) {
- if (className.isInner()) {
- Type t = tClass(mangleInnerType(className));
- if (t.getClassName() != className)
- // Somebody got here first with a mangled name.
- // (Perhaps it came from a binary.)
- changeClassName(t.getClassName(), className);
- return t;
- }
- // see if we've cached the object in the Identifier
- if (className.typeObject != null) {
- return className.typeObject;
- }
- String sig =
- new String(SIG_CLASS +
- className.toString().replace('.', SIGC_PACKAGE) +
- SIG_ENDCLASS);
- Type t = typeHash.get(sig);
- if (t == null) {
- t = new ClassType(sig, className);
- }
-
- className.typeObject = t; // cache the Type object in the Identifier
- return t;
- }
-
- /**
- * Return the ClassName. Only works on class types.
- */
- public Identifier getClassName() {
- throw new CompilerError("getClassName:" + this);
- }
-
- /**
- * Given an inner identifier, return the non-inner, mangled
- * representation used to manage signatures.
- *
- * Note: It is changed to 'public' for Jcov file generation.
- * (see Assembler.java)
- */
-
- public static Identifier mangleInnerType(Identifier className) {
- // Map "pkg.Foo. Bar" to "pkg.Foo$Bar".
- if (!className.isInner()) return className;
- Identifier mname = Identifier.lookup(
- className.getFlatName().toString().
- replace('.', SIGC_INNERCLASS) );
- if (mname.isInner()) throw new CompilerError("mangle "+mname);
- return Identifier.lookup(className.getQualifier(), mname);
- }
-
- /**
- * We have learned that a signature means something other
- * that what we thought it meant. Live with it: Change all
- * affected data structures to reflect the new name of the old type.
- *
- * (This is necessary because of an ambiguity between the
- * low-level signatures of inner types and their manglings.
- * Note that the latter are also valid class names.)
- */
- static void changeClassName(Identifier oldName, Identifier newName) {
- // Note: If we are upgrading "pkg.Foo$Bar" to "pkg.Foo. Bar",
- // we assume someone else will come along and deal with any types
- // inner within Bar. So, there's only one change to make.
- ((ClassType)Type.tClass(oldName)).className = newName;
- }
-
- /**
- * Create a method type with no arguments.
- */
- public static synchronized Type tMethod(Type ret) {
- return tMethod(ret, noArgs);
- }
-
- /**
- * Create a method type with arguments.
- */
- public static synchronized Type tMethod(Type returnType, Type argTypes[]) {
- StringBuilder sb = new StringBuilder();
- sb.append(SIG_METHOD);
- for (int i = 0 ; i < argTypes.length ; i++) {
- sb.append(argTypes[i].getTypeSignature());
- }
- sb.append(SIG_ENDMETHOD);
- sb.append(returnType.getTypeSignature());
-
- String sig = sb.toString();
- Type t = typeHash.get(sig);
- if (t == null) {
- t = new MethodType(sig, returnType, argTypes);
- }
- return t;
- }
-
- /**
- * Return the return type. Only works for method types.
- */
- public Type getReturnType() {
- throw new CompilerError("getReturnType");
- }
-
- /**
- * Return the argument types. Only works for method types.
- */
- public Type[] getArgumentTypes() {
- throw new CompilerError("getArgumentTypes");
- }
-
- /**
- * Create a Type from an Java type signature.
- * @exception CompilerError invalid type signature.
- */
- public static synchronized Type tType(String sig) {
- Type t = typeHash.get(sig);
- if (t != null) {
- return t;
- }
-
- switch (sig.charAt(0)) {
- case SIGC_ARRAY:
- return Type.tArray(tType(sig.substring(1)));
-
- case SIGC_CLASS:
- return Type.tClass(Identifier.lookup(sig.substring(1, sig.length() - 1).replace(SIGC_PACKAGE, '.')));
-
- case SIGC_METHOD: {
- Type argv[] = new Type[8];
- int argc = 0;
- int i, j;
-
- for (i = 1 ; sig.charAt(i) != SIGC_ENDMETHOD ; i = j) {
- for (j = i ; sig.charAt(j) == SIGC_ARRAY ; j++);
- if (sig.charAt(j++) == SIGC_CLASS) {
- while (sig.charAt(j++) != SIGC_ENDCLASS);
- }
- if (argc == argv.length) {
- Type newargv[] = new Type[argc * 2];
- System.arraycopy(argv, 0, newargv, 0, argc);
- argv = newargv;
- }
- argv[argc++] = tType(sig.substring(i, j));
- }
-
- Type argtypes[] = new Type[argc];
- System.arraycopy(argv, 0, argtypes, 0, argc);
- return Type.tMethod(tType(sig.substring(i + 1)), argtypes);
- }
- }
-
- throw new CompilerError("invalid TypeSignature:" + sig);
- }
-
- /**
- * Check if the type arguments are the same.
- * @return true if both types are method types and the
- * argument types are identical.
- */
- public boolean equalArguments(Type t) {
- return false;
- }
-
- /**
- * Return the amount of space this type takes up on the
- * Java operand stack. For a method this is equal to the
- * total space taken up by the arguments.
- */
- public int stackSize() {
- switch (typeCode) {
- case TC_ERROR:
- case TC_VOID:
- return 0;
- case TC_BOOLEAN:
- case TC_BYTE:
- case TC_SHORT:
- case TC_CHAR:
- case TC_INT:
- case TC_FLOAT:
- case TC_ARRAY:
- case TC_CLASS:
- return 1;
- case TC_LONG:
- case TC_DOUBLE:
- return 2;
- }
- throw new CompilerError("stackSize " + toString());
- }
-
- /**
- * Return the type code offset. This offset can be added to
- * an opcode to get the right opcode type. Most opcodes
- * are ordered: int, long, float, double, array. For
- * example: iload, lload fload, dload, aload. So the
- * appropriate opcode is iadd + type.getTypeCodeOffset().
- */
- public int getTypeCodeOffset() {
- switch (typeCode) {
- case TC_BOOLEAN:
- case TC_BYTE:
- case TC_SHORT:
- case TC_CHAR:
- case TC_INT:
- return 0;
- case TC_LONG:
- return 1;
- case TC_FLOAT:
- return 2;
- case TC_DOUBLE:
- return 3;
- case TC_NULL:
- case TC_ARRAY:
- case TC_CLASS:
- return 4;
- }
- throw new CompilerError("invalid typecode: " + typeCode);
- }
-
- /**
- * Convert a Type to a string, if abbrev is true class names are
- * not fully qualified, if ret is true the return type is included.
- */
- public String typeString(String id, boolean abbrev, boolean ret) {
- String s = null;
-
- switch (typeCode) {
- case TC_NULL: s = "null"; break;
- case TC_VOID: s = "void"; break;
- case TC_BOOLEAN: s = "boolean"; break;
- case TC_BYTE: s = "byte"; break;
- case TC_CHAR: s = "char"; break;
- case TC_SHORT: s = "short"; break;
- case TC_INT: s = "int"; break;
- case TC_LONG: s = "long"; break;
- case TC_FLOAT: s = "float"; break;
- case TC_DOUBLE: s = "double"; break;
- case TC_ERROR: s = "";
- if (this==tPackage) s = "";
- break;
- default: s = "unknown";
- }
-
- return (id.length() > 0) ? s + " " + id : s;
- }
-
- /**
- * Create a type string, given an identifier.
- */
- public String typeString(String id) {
- return typeString(id, false, true);
- }
-
- /**
- * Convert to a String
- */
- public String toString() {
- return typeString("", false, true);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/java/ZipClassFile.java b/src/jdk.rmic/share/classes/sun/tools/java/ZipClassFile.java
deleted file mode 100644
index 4e68b3d1a6e..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/java/ZipClassFile.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2014, 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 sun.tools.java;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.zip.*;
-
-/**
- * This class is used to represent a file loaded from the class path, and
- * is a zip file entry.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-final
-class ZipClassFile extends ClassFile {
- private final ZipFile zipFile;
- private final ZipEntry zipEntry;
-
- /**
- * Constructor for instance representing a zip file entry
- */
- public ZipClassFile(ZipFile zf, ZipEntry ze) {
- this.zipFile = zf;
- this.zipEntry = ze;
- }
-
- @Override
- public boolean isZipped() {
- return true;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- return zipFile.getInputStream(zipEntry);
- } catch (ZipException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- @Override
- public boolean exists() {
- return true;
- }
-
- @Override
- public boolean isDirectory() {
- return zipEntry.getName().endsWith("/");
- }
-
- @Override
- public long lastModified() {
- return zipEntry.getTime();
- }
-
- @Override
- public String getPath() {
- return zipFile.getName() + "(" + zipEntry.getName() + ")";
- }
-
- @Override
- public String getName() {
- return zipEntry.getName();
- }
-
-//JCOV
- @Override
- public String getAbsoluteName() {
- return zipFile.getName() + "(" + zipEntry.getName() + ")";
- }
-// end JCOV
-
- @Override
- public long length() {
- return zipEntry.getSize();
- }
-
- @Override
- public String toString() {
- return zipEntry.toString();
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/BatchEnvironment.java b/src/jdk.rmic/share/classes/sun/tools/javac/BatchEnvironment.java
deleted file mode 100644
index ae1b45a2030..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/BatchEnvironment.java
+++ /dev/null
@@ -1,1354 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.tree.Node;
-import sun.tools.java.Package;
-
-import java.util.*;
-import java.io.*;
-
-/**
- * Main environment of the batch version of the Java compiler,
- * this needs more work.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-public
-class BatchEnvironment extends Environment implements ErrorConsumer {
- /**
- * The stream where error message are printed.
- */
- OutputStream out;
-
- /**
- * The path we use for finding source files.
- */
- protected ClassPath sourcePath;
-
- /**
- * The path we use for finding class (binary) files.
- */
- protected ClassPath binaryPath;
-
- /**
- * A hashtable of resource contexts.
- */
- Hashtable packages = new Hashtable<>(31);
-
- /**
- * The classes, in order of appearance.
- */
- Vector classesOrdered = new Vector<>();
-
- /**
- * The classes, keyed by ClassDeclaration.
- */
- Hashtable classes = new Hashtable<>(351);
-
- /**
- * flags
- */
- public int flags;
-
- /**
- * Major and minor versions to use for generated class files.
- * Environments that extend BatchEnvironment (such as javadoc's
- * Env class) get the default values below.
- *
- * javac itself may override these versions with values determined
- * from the command line "-target" option.
- */
- public short majorVersion = JAVA_DEFAULT_VERSION;
- public short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
-
-// JCOV
- /**
- * coverage data file
- */
- public File covFile;
-// end JCOV
-
- /**
- * The number of errors and warnings
- */
- public int nerrors;
- public int nwarnings;
- public int ndeprecations;
-
- /**
- * A list of files containing deprecation warnings.
- */
- Vector deprecationFiles = new Vector<>();
-
- /**
- * writes out error messages
- */
-
- ErrorConsumer errorConsumer;
-
- /**
- * Old constructors -- these constructors build a BatchEnvironment
- * with an old-style class path.
- */
- public BatchEnvironment(ClassPath path) {
- this(System.out, path);
- }
- public BatchEnvironment(OutputStream out,
- ClassPath path) {
- this(out, path, (ErrorConsumer) null);
- }
- public BatchEnvironment(OutputStream out,
- ClassPath path,
- ErrorConsumer errorConsumer) {
- this(out, path, path, errorConsumer);
- }
-
- /**
- * New constructors -- these constructors build a BatchEnvironment
- * with a source path and a binary path.
- */
- public BatchEnvironment(ClassPath sourcePath,
- ClassPath binaryPath) {
- this(System.out, sourcePath, binaryPath);
- }
- public BatchEnvironment(OutputStream out,
- ClassPath sourcePath,
- ClassPath binaryPath) {
- this(out, sourcePath, binaryPath, (ErrorConsumer) null);
- }
- public BatchEnvironment(OutputStream out,
- ClassPath sourcePath,
- ClassPath binaryPath,
- ErrorConsumer errorConsumer) {
- this.out = out;
- this.sourcePath = sourcePath;
- this.binaryPath = binaryPath;
- this.errorConsumer = (errorConsumer == null) ? this : errorConsumer;
- }
-
- /**
- * Factory
- */
- static BatchEnvironment create(OutputStream out,
- String srcPathString,
- String classPathString,
- String sysClassPathString) {
- ClassPath[] classPaths = classPaths(srcPathString, classPathString,
- sysClassPathString);
- return new BatchEnvironment(out, classPaths[0], classPaths[1]);
- }
-
- protected static ClassPath[] classPaths(String srcPathString,
- String classPathString,
- String sysClassPathString) {
- // Create our source classpath and our binary classpath
- ClassPath sourcePath;
- ClassPath binaryPath;
- StringBuffer binaryPathBuffer = new StringBuffer();
-
- if (classPathString == null) {
- // The env.class.path property is the user's CLASSPATH
- // environment variable, and it set by the wrapper (ie,
- // javac.exe).
- classPathString = System.getProperty("env.class.path");
- if (classPathString == null) {
- classPathString = ".";
- }
- }
- if (srcPathString == null) {
- srcPathString = classPathString;
- }
- if (sysClassPathString == null) {
- sysClassPathString = System.getProperty("sun.boot.class.path");
- if (sysClassPathString == null) { // shouldn't happen; recover gracefully
- sysClassPathString = classPathString;
- }
- }
- appendPath(binaryPathBuffer, sysClassPathString);
-
- appendPath(binaryPathBuffer, classPathString);
-
- sourcePath = new ClassPath(srcPathString);
- binaryPath = new ClassPath(binaryPathBuffer.toString());
-
- return new ClassPath[]{sourcePath, binaryPath};
- }
-
- private static void appendPath(StringBuffer buf, String str) {
- if (str.length() > 0) {
- if (buf.length() > 0) {
- buf.append(File.pathSeparator);
- }
- buf.append(str);
- }
- }
-
- /**
- * Return flags
- */
- public int getFlags() {
- return flags;
- }
-
- /**
- * Return major version to use for generated class files
- */
- public short getMajorVersion() {
- return majorVersion;
- }
-
- /**
- * Return minor version to use for generated class files
- */
- public short getMinorVersion() {
- return minorVersion;
- }
-
-// JCOV
- /**
- * Return coverage data file
- */
- public File getcovFile() {
- return covFile;
- }
-// end JCOV
-
- /**
- * Return an enumeration of all the currently defined classes
- * in order of appearance to getClassDeclaration().
- */
- public Enumeration getClasses() {
- return classesOrdered.elements();
- }
-
- /**
- * A set of Identifiers for all packages exempt from the "exists"
- * check in Imports#resolve(). These are the current packages for
- * all classes being compiled as of the first call to isExemptPackage.
- */
- private Set exemptPackages;
-
- /**
- * Tells whether an Identifier refers to a package which should be
- * exempt from the "exists" check in Imports#resolve().
- */
- public boolean isExemptPackage(Identifier id) {
- if (exemptPackages == null) {
- // Collect a list of the packages of all classes currently
- // being compiled.
- setExemptPackages();
- }
-
- return exemptPackages.contains(id);
- }
-
- /**
- * Set the set of packages which are exempt from the exists check
- * in Imports#resolve().
- */
- private void setExemptPackages() {
- // The JLS gives us the freedom to define "accessibility" of
- // a package in whatever manner we wish. After the evaluation
- // of bug 4093217, we have decided to consider a package P
- // accessible if either:
- //
- // 1. The directory corresponding to P exists on the classpath.
- // 2. For any class C currently being compiled, C belongs to
- // package P.
- // 3. For any class C currently being compiled, C belongs to
- // package Q and Q is a subpackage of P.
- //
- // In order to implement this, we collect the current packages
- // (and prefixes) of all packages we have found so far. These
- // will be exempt from the "exists" check in
- // sun.tools.java.Imports#resolve().
-
- exemptPackages = new HashSet<>(101);
-
- // Add all of the current packages and their prefixes to our set.
- for (Enumeration e = getClasses(); e.hasMoreElements(); ) {
- ClassDeclaration c = e.nextElement();
- if (c.getStatus() == CS_PARSED) {
- SourceClass def = (SourceClass) c.getClassDefinition();
- if (def.isLocal())
- continue;
-
- Identifier pkg = def.getImports().getCurrentPackage();
-
- // Add the name of this package and all of its prefixes
- // to our set.
- while (pkg != idNull && exemptPackages.add(pkg)) {
- pkg = pkg.getQualifier();
- }
- }
- }
-
- // Before we go any further, we make sure java.lang is
- // accessible and that it is not ambiguous. These checks
- // are performed for "ordinary" packages in
- // sun.tools.java.Imports#resolve(). The reason we perform
- // them specially for java.lang is that we want to report
- // the error once, and outside of any particular file.
-
- // Check to see if java.lang is accessible.
- if (!exemptPackages.contains(idJavaLang)) {
- // Add java.lang to the set of exempt packages.
- exemptPackages.add(idJavaLang);
-
- try {
- if (!getPackage(idJavaLang).exists()) {
- // java.lang doesn't exist.
- error(0, "package.not.found.strong", idJavaLang);
- return;
- }
- } catch (IOException ee) {
- // We got an IO exception checking to see if the package
- // java.lang exists.
- error(0, "io.exception.package", idJavaLang);
- }
- }
-
- // Next we ensure that java.lang is not both a class and
- // a package. (Fix for 4101529)
- //
- // This change has been backed out because, on WIN32, it
- // failed to take character case into account. It will
- // be put back in later.
- //
- // Identifier resolvedName =
- // resolvePackageQualifiedName(idJavaLang);
- // Identifier topClassName = resolvedName.getTopName();
- // //if (Imports.importable(topClassName, env)) {
- // if (Imports.importable(topClassName, this)) {
- // // It is a package and a class. Emit the error.
- // error(0, "package.class.conflict.strong",
- // idJavaLang, topClassName);
- // return;
- // }
- }
-
- /**
- * Get a class, given the fully qualified class name
- */
- public ClassDeclaration getClassDeclaration(Identifier nm) {
- return getClassDeclaration(Type.tClass(nm));
- }
-
- public ClassDeclaration getClassDeclaration(Type t) {
- ClassDeclaration c = classes.get(t);
- if (c == null) {
- classes.put(t, c = new ClassDeclaration(t.getClassName()));
- classesOrdered.addElement(c);
- }
- return c;
- }
-
- /**
- * Check if a class exists
- * Applies only to package members (non-nested classes).
- */
- public boolean classExists(Identifier nm) {
- if (nm.isInner()) {
- nm = nm.getTopName(); // just in case
- }
- Type t = Type.tClass(nm);
- try {
- ClassDeclaration c = classes.get(t);
- return (c != null) ? c.getName().equals(nm) :
- getPackage(nm.getQualifier()).classExists(nm.getName());
- } catch (IOException e) {
- return true;
- }
- }
-
- /**
- * Generate a new name similar to the given one.
- * Do it in such a way that repeated compilations of
- * the same source generate the same series of names.
- */
-
- // This code does not perform as stated above.
- // Correction below is part of fix for bug id 4056065.
- //
- // NOTE: The method 'generateName' has now been folded into its
- // single caller, 'makeClassDefinition', which appears later in
- // this file.
-
- /*--------------------------*
- public Identifier generateName(ClassDefinition outerClass, Identifier nm) {
- Identifier outerNm = outerClass.getName();
- Identifier flat = outerNm.getFlatName();
- Identifier stem = Identifier.lookup(outerNm.getQualifier(),
- flat.getHead());
- for (int i = 1; ; i++) {
- String name = i + (nm.equals(idNull) ? "" : SIG_INNERCLASS + nm);
- Identifier nm1 = Identifier.lookupInner(stem,
- Identifier.lookup(name));
- if (classes.get(Type.tClass(nm1)) == null)
- return nm1;
- }
- }
- *--------------------------*/
-
- /**
- * Get the package path for a package
- */
- public Package getPackage(Identifier pkg) throws IOException {
- Package p = packages.get(pkg);
- if (p == null) {
- packages.put(pkg, p = new Package(sourcePath, binaryPath, pkg));
- }
- return p;
- }
-
- /**
- * Parse a source file
- */
- public void parseFile(ClassFile file) throws FileNotFoundException {
- long tm = System.currentTimeMillis();
- InputStream input;
- BatchParser p;
-
- if (tracing) dtEnter("parseFile: PARSING SOURCE " + file);
-
- Environment env = new Environment(this, file);
-
- try {
- input = file.getInputStream();
- env.setCharacterEncoding(getCharacterEncoding());
- // p = new BatchParser(e, new BufferedInputStream(input));
- p = new BatchParser(env, input);
- } catch(IOException ex) {
- if (tracing) dtEvent("parseFile: IO EXCEPTION " + file);
- throw new FileNotFoundException();
- }
-
- try {
- p.parseFile();
- } catch(Exception e) {
- throw new CompilerError(e);
- }
-
- try {
- input.close();
- } catch (IOException ex) {
- // We're turn with the input, so ignore this.
- }
-
- if (verbose()) {
- tm = System.currentTimeMillis() - tm;
- output(Main.getText("benv.parsed_in", file.getPath(),
- Long.toString(tm)));
- }
-
- if (p.classes.size() == 0) {
- // The JLS allows a file to contain no compilation units --
- // that is, it allows a file to contain no classes or interfaces.
- // In this case, we are still responsible for checking that the
- // imports resolve properly. The way the compiler is organized,
- // this is the last point at which we still have enough information
- // to do so. (Fix for 4041851).
- p.imports.resolve(env);
- } else {
- // In an attempt to see that classes which come from the
- // same source file are all recompiled when any one of them
- // would be recompiled (when using the -depend option) we
- // introduce artificial dependencies between these classes.
- // We do this by calling the addDependency() method, which
- // adds a (potentially unused) class reference to the constant
- // pool of the class.
- //
- // Previously, we added a dependency from every class in the
- // file, to every class in the file. This introduced, in
- // total, a quadratic number of potentially bogus constant
- // pool entries. This was bad. Now we add our artificial
- // dependencies in such a way that the classes are connected
- // in a circle. While single links is probably sufficient, the
- // code below adds double links just to be diligent.
- // (Fix for 4108286).
- //
- // Note that we don't chain in inner classes. The links
- // between them and their outerclass should be sufficient
- // here.
- // (Fix for 4107960).
- //
- // The dependency code was previously in BatchParser.java.
- Enumeration e = p.classes.elements();
-
- // first will not be an inner class.
- ClassDefinition first = e.nextElement();
- if (first.isInnerClass()) {
- throw new CompilerError("BatchEnvironment, first is inner");
- }
-
- ClassDefinition current = first;
- ClassDefinition next;
- while (e.hasMoreElements()) {
- next = e.nextElement();
- // Don't chain in inner classes.
- if (next.isInnerClass()) {
- continue;
- }
- current.addDependency(next.getClassDeclaration());
- next.addDependency(current.getClassDeclaration());
- current = next;
- }
- // Make a circle. Don't bother to add a dependency if there
- // is only one class in the file.
- if (current != first) {
- current.addDependency(first.getClassDeclaration());
- first.addDependency(current.getClassDeclaration());
- }
- }
-
- if (tracing) dtExit("parseFile: SOURCE PARSED " + file);
- }
-
- /**
- * Load a binary file
- */
- BinaryClass loadFile(ClassFile file) throws IOException {
- long tm = System.currentTimeMillis();
- InputStream input = file.getInputStream();
- BinaryClass c = null;
-
- if (tracing) dtEnter("loadFile: LOADING CLASSFILE " + file);
-
- try {
- DataInputStream is =
- new DataInputStream(new BufferedInputStream(input));
- c = BinaryClass.load(new Environment(this, file), is,
- loadFileFlags());
- } catch (ClassFormatError e) {
- error(0, "class.format", file.getPath(), e.getMessage());
- if (tracing) dtExit("loadFile: CLASS FORMAT ERROR " + file);
- return null;
- } catch (java.io.EOFException e) {
- // If we get an EOF while processing a class file, then
- // it has been truncated. We let other I/O errors pass
- // through. Fix for 4088443.
- error(0, "truncated.class", file.getPath());
- return null;
- }
-
- input.close();
- if (verbose()) {
- tm = System.currentTimeMillis() - tm;
- output(Main.getText("benv.loaded_in", file.getPath(),
- Long.toString(tm)));
- }
-
- if (tracing) dtExit("loadFile: CLASSFILE LOADED " + file);
-
- return c;
- }
-
- /**
- * Default flags for loadFile. Subclasses may override this.
- */
- int loadFileFlags() {
- return 0;
- }
-
- /**
- * Load a binary class
- */
- boolean needsCompilation(Hashtable check, ClassDeclaration c) {
- switch (c.getStatus()) {
-
- case CS_UNDEFINED:
- if (tracing) dtEnter("needsCompilation: UNDEFINED " + c.getName());
- loadDefinition(c);
- return needsCompilation(check, c);
-
- case CS_UNDECIDED:
- if (tracing) dtEnter("needsCompilation: UNDECIDED " + c.getName());
- if (check.get(c) == null) {
- check.put(c, c);
-
- BinaryClass bin = (BinaryClass)c.getClassDefinition();
- for (Enumeration e = bin.getDependencies() ; e.hasMoreElements() ;) {
- ClassDeclaration dep = e.nextElement();
- if (needsCompilation(check, dep)) {
- // It must be source, dependencies need compilation
- c.setDefinition(bin, CS_SOURCE);
- if (tracing) dtExit("needsCompilation: YES (source) " + c.getName());
- return true;
- }
- }
- }
- if (tracing) dtExit("needsCompilation: NO (undecided) " + c.getName());
- return false;
-
- case CS_BINARY:
- if (tracing) {
- dtEnter("needsCompilation: BINARY " + c.getName());
- dtExit("needsCompilation: NO (binary) " + c.getName());
- }
- return false;
-
- }
-
- if (tracing) dtExit("needsCompilation: YES " + c.getName());
- return true;
- }
-
- /**
- * Load the definition of a class
- * or at least determine how to load it.
- * The caller must repeat calls to this method
- * until it the state converges to CS_BINARY, CS_PARSED, or the like..
- * @see ClassDeclaration#getClassDefinition
- */
- public void loadDefinition(ClassDeclaration c) {
- if (tracing) dtEnter("loadDefinition: ENTER " +
- c.getName() + ", status " + c.getStatus());
- switch (c.getStatus()) {
- case CS_UNDEFINED: {
- if (tracing)
- dtEvent("loadDefinition: STATUS IS UNDEFINED");
- Identifier nm = c.getName();
- Package pkg;
- try {
- pkg = getPackage(nm.getQualifier());
- } catch (IOException e) {
- // If we can't get at the package, then we'll just
- // have to set the class to be not found.
- c.setDefinition(null, CS_NOTFOUND);
-
- error(0, "io.exception", c);
- if (tracing)
- dtExit("loadDefinition: IO EXCEPTION (package)");
- return;
- }
- ClassFile binfile = pkg.getBinaryFile(nm.getName());
- if (binfile == null) {
- // must be source, there is no binary
- c.setDefinition(null, CS_SOURCE);
- if (tracing)
- dtExit("loadDefinition: MUST BE SOURCE (no binary) " +
- c.getName());
- return;
- }
-
- ClassFile srcfile = pkg.getSourceFile(nm.getName());
- if (srcfile == null) {
- if (tracing)
- dtEvent("loadDefinition: NO SOURCE " + c.getName());
- BinaryClass bc = null;
- try {
- bc = loadFile(binfile);
- } catch (IOException e) {
- // If we can't access the binary, set the class to
- // be not found. (bug id 4030497)
- c.setDefinition(null, CS_NOTFOUND);
-
- error(0, "io.exception", binfile);
- if (tracing)
- dtExit("loadDefinition: IO EXCEPTION (binary)");
- return;
- }
- if ((bc != null) && !bc.getName().equals(nm)) {
- error(0, "wrong.class", binfile.getPath(), c, bc);
- bc = null;
- if (tracing)
- dtEvent("loadDefinition: WRONG CLASS (binary)");
- }
- if (bc == null) {
- // no source nor binary found
- c.setDefinition(null, CS_NOTFOUND);
- if (tracing)
- dtExit("loadDefinition: NOT FOUND (source or binary)");
- return;
- }
-
- // Couldn't find the source, try the one mentioned in the binary
- if (bc.getSource() != null) {
- srcfile = ClassFile.newClassFile(new File((String)bc.getSource()));
- // Look for the source file
- srcfile = pkg.getSourceFile(srcfile.getName());
- if ((srcfile != null) && srcfile.exists()) {
- if (tracing)
- dtEvent("loadDefinition: FILENAME IN BINARY " +
- srcfile);
- if (srcfile.lastModified() > binfile.lastModified()) {
- // must be source, it is newer than the binary
- c.setDefinition(bc, CS_SOURCE);
- if (tracing)
- dtEvent("loadDefinition: SOURCE IS NEWER " +
- srcfile);
- bc.loadNested(this);
- if (tracing)
- dtExit("loadDefinition: MUST BE SOURCE " +
- c.getName());
- return;
- }
- if (dependencies()) {
- c.setDefinition(bc, CS_UNDECIDED);
- if (tracing)
- dtEvent("loadDefinition: UNDECIDED " +
- c.getName());
- } else {
- c.setDefinition(bc, CS_BINARY);
- if (tracing)
- dtEvent("loadDefinition: MUST BE BINARY " +
- c.getName());
- }
- bc.loadNested(this);
- if (tracing)
- dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
- }
-
- // It must be binary, there is no source
- c.setDefinition(bc, CS_BINARY);
- if (tracing)
- dtEvent("loadDefinition: MUST BE BINARY (no source) " +
- c.getName());
- bc.loadNested(this);
- if (tracing)
- dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
- BinaryClass bc = null;
- try {
- if (srcfile.lastModified() > binfile.lastModified()) {
- // must be source, it is newer than the binary
- c.setDefinition(null, CS_SOURCE);
- if (tracing)
- dtEvent("loadDefinition: MUST BE SOURCE (younger than binary) " +
- c.getName());
- return;
- }
- bc = loadFile(binfile);
- } catch (IOException e) {
- error(0, "io.exception", binfile);
- if (tracing)
- dtEvent("loadDefinition: IO EXCEPTION (binary)");
- }
- if ((bc != null) && !bc.getName().equals(nm)) {
- error(0, "wrong.class", binfile.getPath(), c, bc);
- bc = null;
- if (tracing)
- dtEvent("loadDefinition: WRONG CLASS (binary)");
- }
- if (bc != null) {
- Identifier name = bc.getName();
- if (name.equals(c.getName())) {
- if (dependencies()) {
- c.setDefinition(bc, CS_UNDECIDED);
- if (tracing)
- dtEvent("loadDefinition: UNDECIDED " + name);
- } else {
- c.setDefinition(bc, CS_BINARY);
- if (tracing)
- dtEvent("loadDefinition: MUST BE BINARY " + name);
- }
- } else {
- c.setDefinition(null, CS_NOTFOUND);
- if (tracing)
- dtEvent("loadDefinition: NOT FOUND (source or binary)");
- if (dependencies()) {
- getClassDeclaration(name).setDefinition(bc, CS_UNDECIDED);
- if (tracing)
- dtEvent("loadDefinition: UNDECIDED " + name);
- } else {
- getClassDeclaration(name).setDefinition(bc, CS_BINARY);
- if (tracing)
- dtEvent("loadDefinition: MUST BE BINARY " + name);
- }
- }
- } else {
- c.setDefinition(null, CS_NOTFOUND);
- if (tracing)
- dtEvent("loadDefinition: NOT FOUND (source or binary)");
- }
- if (bc != null && bc == c.getClassDefinition())
- bc.loadNested(this);
- if (tracing) dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
-
- case CS_UNDECIDED: {
- if (tracing) dtEvent("loadDefinition: STATUS IS UNDECIDED");
- Hashtable tab = new Hashtable<>();
- if (!needsCompilation(tab, c)) {
- // All undecided classes that this class depends on must be binary
- for (Enumeration e = tab.keys() ; e.hasMoreElements() ; ) {
- ClassDeclaration dep = e.nextElement();
- if (dep.getStatus() == CS_UNDECIDED) {
- // must be binary, dependencies need compilation
- dep.setDefinition(dep.getClassDefinition(), CS_BINARY);
- if (tracing)
- dtEvent("loadDefinition: MUST BE BINARY " + dep);
- }
- }
- }
- if (tracing) dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
-
- case CS_SOURCE: {
- if (tracing) dtEvent("loadDefinition: STATUS IS SOURCE");
- ClassFile srcfile = null;
- Package pkg = null;
- if (c.getClassDefinition() != null) {
- // Use the source file name from the binary class file
- try {
- pkg = getPackage(c.getName().getQualifier());
- srcfile = pkg.getSourceFile((String)c.getClassDefinition().getSource());
- } catch (IOException e) {
- error(0, "io.exception", c);
- if (tracing)
- dtEvent("loadDefinition: IO EXCEPTION (package)");
- }
- if (srcfile == null) {
- String fn = (String)c.getClassDefinition().getSource();
- srcfile = ClassFile.newClassFile(new File(fn));
- }
- } else {
- // Get a source file name from the package
- Identifier nm = c.getName();
- try {
- pkg = getPackage(nm.getQualifier());
- srcfile = pkg.getSourceFile(nm.getName());
- } catch (IOException e) {
- error(0, "io.exception", c);
- if (tracing)
- dtEvent("loadDefinition: IO EXCEPTION (package)");
- }
- if (srcfile == null) {
- // not found, there is no source
- c.setDefinition(null, CS_NOTFOUND);
- if (tracing)
- dtExit("loadDefinition: SOURCE NOT FOUND " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
- }
- try {
- parseFile(srcfile);
- } catch (FileNotFoundException e) {
- error(0, "io.exception", srcfile);
- if (tracing) dtEvent("loadDefinition: IO EXCEPTION (source)");
- }
- if ((c.getClassDefinition() == null) || (c.getStatus() == CS_SOURCE)) {
- // not found after parsing the file
- error(0, "wrong.source", srcfile.getPath(), c, pkg);
- c.setDefinition(null, CS_NOTFOUND);
- if (tracing)
- dtEvent("loadDefinition: WRONG CLASS (source) " +
- c.getName());
- }
- if (tracing) dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- return;
- }
- }
- if (tracing) dtExit("loadDefinition: EXIT " +
- c.getName() + ", status " + c.getStatus());
- }
-
- /**
- * Create a new class.
- */
- public ClassDefinition makeClassDefinition(Environment toplevelEnv,
- long where,
- IdentifierToken name,
- String doc, int modifiers,
- IdentifierToken superClass,
- IdentifierToken interfaces[],
- ClassDefinition outerClass) {
-
- Identifier nm = name.getName();
- long nmpos = name.getWhere();
-
- Identifier pkgNm;
- String mangledName = null;
- ClassDefinition localContextClass = null;
-
- // Provide name for a local class. This used to be set after
- // the class was created, but it is needed for checking within
- // the class constructor.
- // NOTE: It seems that we could always provide the simple name,
- // and thereby avoid the test in 'ClassDefinition.getLocalName()'
- // for the definedness of the local name. There, if the local
- // name is not set, a simple name is extracted from the result of
- // 'getName()'. That name can potentially change, however, as
- // it is ultimately derived from 'ClassType.className', which is
- // set by 'Type.changeClassName'. Better leave this alone...
- Identifier localName = null;
-
- if (nm.isQualified() || nm.isInner()) {
- pkgNm = nm;
- } else if ((modifiers & (M_LOCAL | M_ANONYMOUS)) != 0) {
- // Inaccessible class. Create a name of the form
- // 'PackageMember.N$localName' or 'PackageMember.N'.
- // Note that the '.' will be converted later to a '$'.
- // pkgNm = generateName(outerClass, nm);
- localContextClass = outerClass.getTopClass();
- // Always use the smallest number in generating the name that
- // renders the complete name unique within the top-level class.
- // This is required to make the names more predictable, as part
- // of a serialization-related workaround, and satisfies an obscure
- // requirement that the name of a local class be of the form
- // 'PackageMember$1$localName' when this name is unique.
- for (int i = 1 ; ; i++) {
- mangledName = i + (nm.equals(idNull) ? "" : SIG_INNERCLASS + nm);
- if (localContextClass.getLocalClass(mangledName) == null) {
- break;
- }
- }
- Identifier outerNm = localContextClass.getName();
- pkgNm = Identifier.lookupInner(outerNm, Identifier.lookup(mangledName));
- //System.out.println("LOCAL CLASS: " + pkgNm + " IN " + localContextClass);
- if ((modifiers & M_ANONYMOUS) != 0) {
- localName = idNull;
- } else {
- // Local class has a locally-scoped name which is independent of pkgNm.
- localName = nm;
- }
- } else if (outerClass != null) {
- // Accessible inner class. Qualify name with surrounding class name.
- pkgNm = Identifier.lookupInner(outerClass.getName(), nm);
- } else {
- pkgNm = nm;
- }
-
- // Find the class
- ClassDeclaration c = toplevelEnv.getClassDeclaration(pkgNm);
-
- // Make sure this is the first definition
- if (c.isDefined()) {
- toplevelEnv.error(nmpos, "class.multidef",
- c.getName(), c.getClassDefinition().getSource());
- // Don't mess with the existing class declarations with same name
- c = new ClassDeclaration (pkgNm);
- }
-
- if (superClass == null && !pkgNm.equals(idJavaLangObject)) {
- superClass = new IdentifierToken(idJavaLangObject);
- }
-
- ClassDefinition sourceClass =
- new SourceClass(toplevelEnv, where, c, doc,
- modifiers, superClass, interfaces,
- (SourceClass) outerClass, localName);
-
- if (outerClass != null) {
- // It is a member of its enclosing class.
- outerClass.addMember(toplevelEnv, new SourceMember(sourceClass));
- // Record local (or anonymous) class in the class whose name will
- // serve as the prefix of the local class name. This is necessary
- // so that the class may be retrieved from its name, which does not
- // fully represent the class nesting structure.
- // See 'ClassDefinition.getClassDefinition'.
- // This is part of a fix for bugid 4054523 and 4030421.
- if ((modifiers & (M_LOCAL | M_ANONYMOUS)) != 0) {
- localContextClass.addLocalClass(sourceClass, mangledName);
- }
- }
-
- // The local name of an anonymous or local class used to be set here
- // with a call to 'setLocalName'. This has been moved to the constructor
- // for 'SourceClass', which now takes a 'localName' argument.
-
- return sourceClass;
- }
-
- /*
- * makeMemberDefinition method is left with rawtypes and with lint messages suppressed.
- * The addition of Generics to com.sun.tools.* has uncovered an inconsistency
- * in usage though tools still work correctly as long as this function is allowed to
- * function as is.
- */
-
- /**
- * Create a new field.
- */
- @SuppressWarnings({"rawtypes","unchecked"})
- public MemberDefinition makeMemberDefinition(Environment origEnv, long where,
- ClassDefinition clazz,
- String doc, int modifiers,
- Type type, Identifier name,
- IdentifierToken argNames[],
- IdentifierToken expIds[],
- Object value) {
- if (tracing) dtEvent("makeMemberDefinition: " + name + " IN " + clazz);
- Vector v = null;
- if (argNames != null) {
- v = new Vector(argNames.length);
- for (int i = 0 ; i < argNames.length ; i++) {
- v.addElement(argNames[i]);
- }
- }
- SourceMember f = new SourceMember(where, clazz, doc, modifiers,
- type, name, v, expIds, (Node)value);
- clazz.addMember(origEnv, f);
- return f;
- }
-
- /**
- * Release resources in classpath.
- */
- public void shutdown() {
- try {
- if (sourcePath != null) {
- sourcePath.close();
- }
- if (binaryPath != null && binaryPath != sourcePath) {
- binaryPath.close();
- }
- } catch (IOException ee) {
- output(Main.getText("benv.failed_to_close_class_path",
- ee.toString()));
- }
- sourcePath = null;
- binaryPath = null;
-
- super.shutdown();
- }
-
- /**
- * Error String
- */
- public
- String errorString(String err, Object arg1, Object arg2, Object arg3) {
- String key = null;
-
- if(err.startsWith("warn."))
- key = "javac.err." + err.substring(5);
- else
- key = "javac.err." + err;
-
- return Main.getText(key,
- arg1 != null ? arg1.toString() : null,
- arg2 != null ? arg2.toString() : null,
- arg3 != null ? arg3.toString() : null);
- }
-
- /**
- * The filename where the last errors have occurred
- */
- String errorFileName;
-
- /**
- * List of outstanding error messages
- */
- ErrorMessage errors;
-
- /**
- * Insert an error message in the list of outstanding error messages.
- * The list is sorted on input position and contains no duplicates.
- * The return value indicates whether or not the message was
- * actually inserted.
- *
- * The method flushErrors() used to check for duplicate error messages.
- * It would only detect duplicates if they were contiguous. Removing
- * non-contiguous duplicate error messages is slightly less complicated
- * at insertion time, so the functionality was moved here. This also
- * saves a miniscule number of allocations.
- */
- protected
- boolean insertError(long where, String message) {
- //output("ERR = " + message);
-
- if (errors == null
- || errors.where > where) {
- // If the list is empty, or the error comes before any other
- // errors, insert it at the beginning of the list.
- ErrorMessage newMsg = new ErrorMessage(where, message);
- newMsg.next = errors;
- errors = newMsg;
-
- } else if (errors.where == where
- && errors.message.equals(message)) {
- // The new message is an exact duplicate of the first message
- // in the list. Don't insert it.
- return false;
-
- } else {
- // Okay, we know that the error doesn't come first. Walk
- // the list until we find the right position for insertion.
- ErrorMessage current = errors;
- ErrorMessage next;
-
- while ((next = current.next) != null
- && next.where < where) {
- current = next;
- }
-
- // Now walk over any errors with the same location, looking
- // for duplicates. If we find a duplicate, don't insert the
- // error.
- while ((next = current.next) != null
- && next.where == where) {
- if (next.message.equals(message)) {
- // We have found an exact duplicate. Don't bother to
- // insert the error.
- return false;
- }
- current = next;
- }
-
- // Now insert after current.
- ErrorMessage newMsg = new ErrorMessage(where, message);
- newMsg.next = current.next;
- current.next = newMsg;
- }
-
- // Indicate that the insertion occurred.
- return true;
- }
-
- private int errorsPushed;
-
- /**
- * Maximum number of errors to print.
- */
- public int errorLimit = 100;
-
- private boolean hitErrorLimit;
-
- /**
- * Flush outstanding errors
- */
-
- public void pushError(String errorFileName, int line, String message,
- String referenceText, String referenceTextPointer) {
- int limit = errorLimit + nwarnings;
- if (++errorsPushed >= limit && errorLimit >= 0) {
- if (!hitErrorLimit) {
- hitErrorLimit = true;
- output(errorString("too.many.errors",
- errorLimit,null,null));
- }
- return;
- }
- if (errorFileName.endsWith(".java")) {
- output(errorFileName + ":" + line + ": " + message);
- output(referenceText);
- output(referenceTextPointer);
- } else {
- // It wasn't really a source file (probably an error or
- // warning because of a malformed or badly versioned
- // class file.
- output(errorFileName + ": " + message);
- }
- }
-
- public void flushErrors() {
- if (errors == null) {
- return;
- }
-
- boolean inputAvail = false;
- // Read the file
- char data[] = null;
- int dataLength = 0;
- // A malformed file encoding could cause a CharConversionException.
- // If something bad happens while trying to find the source file,
- // don't bother trying to show lines.
- try {
- FileInputStream in = new FileInputStream(errorFileName);
- data = new char[in.available()];
- InputStreamReader reader =
- (getCharacterEncoding() != null ?
- new InputStreamReader(in, getCharacterEncoding()) :
- new InputStreamReader(in));
- dataLength = reader.read(data);
- reader.close();
- inputAvail = true;
- } catch(IOException e) {
- // inputAvail will not be set
- }
-
- // Report the errors
- for (ErrorMessage msg = errors ; msg != null ; msg = msg.next) {
- // There used to be code here which checked
- // for duplicate error messages. This functionality
- // has been moved to the method insertError(). See
- // the comments on that method for more information.
-
- int ln = (int) (msg.where >>> WHEREOFFSETBITS);
- int off = (int) (msg.where & ((1L << WHEREOFFSETBITS) - 1));
- if (off > dataLength) off = dataLength;
-
- String referenceString = "";
- String markerString = "";
- if(inputAvail) {
- int i, j;
- for (i = off ; (i > 0) && (data[i - 1] != '\n') && (data[i - 1] != '\r') ; i--);
- for (j = off ; (j < dataLength) && (data[j] != '\n') && (data[j] != '\r') ; j++);
- referenceString = new String(data, i, j - i);
-
- char strdata[] = new char[(off - i) + 1];
- for (j = i ; j < off ; j++) {
- strdata[j-i] = (data[j] == '\t') ? '\t' : ' ';
- }
- strdata[off-i] = '^';
- markerString = new String(strdata);
- }
-
- errorConsumer.pushError(errorFileName, ln, msg.message,
- referenceString, markerString);
- }
- errors = null;
- }
-
- /**
- * Report error
- */
- public
- void reportError(Object src, long where, String err, String msg) {
- if (src == null) {
- if (errorFileName != null) {
- flushErrors();
- errorFileName = null;
- }
- if (err.startsWith("warn.")) {
- if (warnings()) {
- nwarnings++;
- output(msg);
- }
- return;
- }
- output("error: " + msg);
- nerrors++;
- flags |= F_ERRORSREPORTED;
-
- } else if (src instanceof String) {
- String fileName = (String)src;
-
- // Flush errors if we've moved on to a new file.
- if (!fileName.equals(errorFileName)) {
- flushErrors();
- errorFileName = fileName;
- }
-
- // Classify `err' as a warning, deprecation warning, or
- // error message. Proceed accordingly.
- if (err.startsWith("warn.")) {
- if (err.indexOf("is.deprecated") >= 0) {
- // This is a deprecation warning. Add `src' to the
- // list of files with deprecation warnings.
- if (!deprecationFiles.contains(src)) {
- deprecationFiles.addElement(src);
- }
-
- // If we are reporting deprecations, try to add it
- // to our list. Otherwise, just increment the
- // deprecation count.
- if (deprecation()) {
- if (insertError(where, msg)) {
- ndeprecations++;
- }
- } else {
- ndeprecations++;
- }
- } else {
- // This is a regular warning. If we are reporting
- // warnings, try to add it to the list. Otherwise, just
- // increment the warning count.
- if (warnings()) {
- if (insertError(where, msg)) {
- nwarnings++;
- }
- } else {
- nwarnings++;
- }
- }
- } else {
- // This is an error. Try to add it to the list of errors.
- // If it isn't a duplicate, increment our error count.
- if (insertError(where, msg)) {
- nerrors++;
- flags |= F_ERRORSREPORTED;
- }
- }
- } else if (src instanceof ClassFile) {
- reportError(((ClassFile)src).getPath(), where, err, msg);
-
- } else if (src instanceof Identifier) {
- reportError(src.toString(), where, err, msg);
-
- } else if (src instanceof ClassDeclaration) {
- try {
- reportError(((ClassDeclaration)src).getClassDefinition(this), where, err, msg);
- } catch (ClassNotFound e) {
- reportError(((ClassDeclaration)src).getName(), where, err, msg);
- }
- } else if (src instanceof ClassDefinition) {
- ClassDefinition c = (ClassDefinition)src;
- if (!err.startsWith("warn.")) {
- c.setError();
- }
- reportError(c.getSource(), where, err, msg);
-
- } else if (src instanceof MemberDefinition) {
- reportError(((MemberDefinition)src).getClassDeclaration(), where, err, msg);
-
- } else {
- output(src + ":error=" + err + ":" + msg);
- }
- }
-
- /**
- * Issue an error
- */
- public void error(Object source, long where, String err, Object arg1, Object arg2, Object arg3) {
- if (errorsPushed >= errorLimit + nwarnings) {
- // Don't bother to queue any more errors if they won't get printed.
- return;
- }
- if (System.getProperty("javac.dump.stack") != null) {
- output("javac.err."+err+": "+errorString(err, arg1, arg2, arg3));
- new Exception("Stack trace").printStackTrace(new PrintStream(out));
- }
- reportError(source, where, err, errorString(err, arg1, arg2, arg3));
- }
-
- /**
- * Output a string. This can either be an error message or something
- * for debugging.
- */
- public void output(String msg) {
- PrintStream out =
- this.out instanceof PrintStream ? (PrintStream)this.out
- : new PrintStream(this.out, true);
- out.println(msg);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/BatchParser.java b/src/jdk.rmic/share/classes/sun/tools/javac/BatchParser.java
deleted file mode 100644
index 03fc237da99..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/BatchParser.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.tree.*;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Vector;
-import java.util.Enumeration;
-
-/**
- * Batch file parser, this needs more work.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-public
-class BatchParser extends Parser {
- /**
- * The current package
- */
- protected Identifier pkg;
-
- /**
- * The current imports
- */
- protected Imports imports;
-
- /**
- * The classes defined in this file
- */
- protected Vector classes;
-
-
- /**
- * The current class
- */
- protected SourceClass sourceClass;
-
- /**
- * The toplevel environment
- */
- protected Environment toplevelEnv;
-
- /**
- * Create a batch file parser
- */
- public BatchParser(Environment env, InputStream in) throws IOException {
- super(env, in);
-
- imports = new Imports(env);
- classes = new Vector<>();
- toplevelEnv = imports.newEnvironment(env);
- }
-
- /**
- * Package declaration
- */
- public void packageDeclaration(long where, IdentifierToken t) {
- Identifier nm = t.getName();
- //System.out.println("package " + nm);
- if (pkg == null) {
- // This code has been changed to pass an IdentifierToken,
- // rather than an Identifier, to setCurrentPackage(). Imports
- // now needs the location of the token.
- pkg = t.getName();
- imports.setCurrentPackage(t);
- } else {
- env.error(where, "package.repeated");
- }
- }
-
- /**
- * Import class
- */
- public void importClass(long pos, IdentifierToken t) {
- //System.out.println("import class " + t);
- imports.addClass(t);
- }
-
- /**
- * Import package
- */
- public void importPackage(long pos, IdentifierToken t) {
- //System.out.println("import package " + t);
- imports.addPackage(t);
- }
-
- /**
- * Define class
- */
- public ClassDefinition beginClass(long where, String doc, int mod,
- IdentifierToken t,
- IdentifierToken sup,
- IdentifierToken interfaces[]) {
-
- // If this class is nested, the modifier bits set here will
- // be copied into the 'SourceMember' object for the inner class
- // created during the call to 'makeClassDefinition' below.
- // When writing the class file, we will look there for the
- // 'untransformed' modifiers. The modifiers in the ClassDefinition
- // object will end up as the 'transformed' modifiers. Note that
- // there are some bits set here that are not legal class modifiers
- // according to the JVMS, e.g., M_PRIVATE and M_STATIC. These are
- // masked off while writing the class file, but are preserved in
- // the InnerClasses attributes.
-
- if (tracing) toplevelEnv.dtEnter("beginClass: " + sourceClass);
-
- SourceClass outerClass = sourceClass;
-
- if (outerClass == null && pkg != null) {
- t = new IdentifierToken(t.getWhere(),
- Identifier.lookup(pkg, t.getName()));
- }
-
- // The defaults for anonymous and local classes should be documented!
-
- if ((mod & M_ANONYMOUS) != 0) {
- mod |= (M_FINAL | M_PRIVATE);
- }
- if ((mod & M_LOCAL) != 0) {
- mod |= M_PRIVATE;
- }
-
- // Certain modifiers are implied as follows:
- //
- // 1. Any interface (nested or not) is implicitly deemed to be abstract,
- // whether it is explicitly marked so or not. (Java 1.0.)
- // 2. A interface which is a member of a type is implicitly deemed to
- // be static, whether it is explicitly marked so or not. (InnerClasses)
- // 3a. A type which is a member of an interface is implicitly deemed
- // to be public, whether it is explicitly marked so or not. (InnerClasses)
- // 3b. A type which is a member of an interface is implicitly deemed
- // to be static, whether it is explicitly marked so or not. (InnerClasses)
-
- if ((mod & M_INTERFACE) != 0) {
- // Rule 1.
- mod |= M_ABSTRACT;
- if (outerClass != null) {
- // Rule 2.
- mod |= M_STATIC;
- }
- }
-
- if (outerClass != null && outerClass.isInterface()) {
- // Rule 3a.
- // For interface members, neither 'private' nor 'protected'
- // are legal modifiers. We avoid setting M_PUBLIC in some
- // cases in order to avoid interfering with error detection
- // and reporting. This is patched up, after reporting an
- // error, by 'SourceClass.addMember'.
- if ((mod & (M_PRIVATE | M_PROTECTED)) == 0)
- mod |= M_PUBLIC;
- // Rule 3b.
- mod |= M_STATIC;
- }
-
- // For nested classes, we must transform 'protected' to 'public'
- // and 'private' to package scope. This must be done later,
- // because any modifiers set here will be copied into the
- // 'MemberDefinition' for the nested class, which must represent
- // the original untransformed modifiers. Also, compile-time
- // checks should be performed against the actual, untransformed
- // modifiers. This is in contrast to transformations that implement
- // implicit modifiers, such as M_STATIC and M_FINAL for fields
- // of interfaces.
-
- sourceClass = (SourceClass)
- toplevelEnv.makeClassDefinition(toplevelEnv, where, t,
- doc, mod, sup,
- interfaces, outerClass);
-
- sourceClass.getClassDeclaration().setDefinition(sourceClass, CS_PARSED);
- env = new Environment(toplevelEnv, sourceClass);
-
- if (tracing) toplevelEnv.dtEvent("beginClass: SETTING UP DEPENDENCIES");
-
- // The code which adds artificial dependencies between
- // classes in the same source file has been moved to
- // BatchEnvironment#parseFile().
-
- if (tracing) toplevelEnv.dtEvent("beginClass: ADDING TO CLASS LIST");
-
- classes.addElement(sourceClass);
-
- if (tracing) toplevelEnv.dtExit("beginClass: " + sourceClass);
-
- return sourceClass;
- }
-
- /**
- * Report the current class under construction.
- */
- public ClassDefinition getCurrentClass() {
- return sourceClass;
- }
-
- /**
- * End class
- */
- public void endClass(long where, ClassDefinition c) {
-
- if (tracing) toplevelEnv.dtEnter("endClass: " + sourceClass);
-
- // c == sourceClass; don't bother to check
- sourceClass.setEndPosition(where);
- SourceClass outerClass = (SourceClass) sourceClass.getOuterClass();
- sourceClass = outerClass;
- env = toplevelEnv;
- if (sourceClass != null)
- env = new Environment(env, sourceClass);
-
- if (tracing) toplevelEnv.dtExit("endClass: " + sourceClass);
- }
-
- /**
- * Define a method
- */
- public void defineField(long where, ClassDefinition c,
- String doc, int mod, Type t,
- IdentifierToken name, IdentifierToken args[],
- IdentifierToken exp[], Node val) {
- // c == sourceClass; don't bother to check
- Identifier nm = name.getName();
- // Members that are nested classes are not created with 'defineField',
- // so these transformations do not apply to them. See 'beginClass' above.
- if (sourceClass.isInterface()) {
- // Members of interfaces are implicitly public.
- if ((mod & (M_PRIVATE | M_PROTECTED)) == 0)
- // For interface members, neither 'private' nor 'protected'
- // are legal modifiers. Avoid setting M_PUBLIC in some cases
- // to avoid interfering with later error detection. This will
- // be fixed up after the error is reported.
- mod |= M_PUBLIC;
- // Methods of interfaces are implicitly abstract.
- // Fields of interfaces are implicitly static and final.
- if (t.isType(TC_METHOD)) {
- mod |= M_ABSTRACT;
- } else {
- mod |= M_STATIC | M_FINAL;
- }
- }
- if (nm.equals(idInit)) {
- // The parser reports "idInit" when in reality it has found
- // that there is no method name at all present.
- // So, decide if it's really a constructor, or a syntax error.
- Type rt = t.getReturnType();
- Identifier retname = !rt.isType(TC_CLASS) ? idStar /*no match*/
- : rt.getClassName();
- Identifier clsname = sourceClass.getLocalName();
- if (clsname.equals(retname)) {
- t = Type.tMethod(Type.tVoid, t.getArgumentTypes());
- } else if (clsname.equals(retname.getFlatName().getName())) {
- // It appears to be a constructor with spurious qualification.
- t = Type.tMethod(Type.tVoid, t.getArgumentTypes());
- env.error(where, "invalid.method.decl.qual");
- } else if (retname.isQualified() || retname.equals(idStar)) {
- // It appears to be a type name with no method name.
- env.error(where, "invalid.method.decl.name");
- return;
- } else {
- // We assume the type name is missing, even though the
- // simple name that's present might have been intended
- // to be a type: "String (){}" vs. "toString(){}".
- env.error(where, "invalid.method.decl");
- return;
- }
- }
-
- if (args == null && t.isType(TC_METHOD)) {
- args = new IdentifierToken[0];
- }
-
- if (exp == null && t.isType(TC_METHOD)) {
- exp = new IdentifierToken[0];
- }
-
- MemberDefinition f = env.makeMemberDefinition(env, where, sourceClass,
- doc, mod, t, nm,
- args, exp, val);
- if (env.dump()) {
- f.print(System.out);
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/CompilerMember.java b/src/jdk.rmic/share/classes/sun/tools/javac/CompilerMember.java
deleted file mode 100644
index c62eee3b055..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/CompilerMember.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.asm.Assembler;
-
-/**
- * This class is used to represents fields while they are
- * being compiled
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-final
-class CompilerMember implements Comparable {
- MemberDefinition field;
- Assembler asm;
- Object value;
- String name;
- String sig;
- String key;
-
- CompilerMember(MemberDefinition field, Assembler asm) {
- this.field = field;
- this.asm = asm;
- name = field.getName().toString();
- sig = field.getType().getTypeSignature();
- }
-
- public int compareTo(Object o) {
- CompilerMember cm = (CompilerMember) o;
- return getKey().compareTo(cm.getKey());
- }
-
- String getKey() {
- if (key==null)
- key = name+sig;
- return key;
- }
-
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/ErrorConsumer.java b/src/jdk.rmic/share/classes/sun/tools/javac/ErrorConsumer.java
deleted file mode 100644
index 1564681d9aa..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/ErrorConsumer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 1996, 2004, 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 sun.tools.javac;
-
-/**
- * Allows for easier parsing of errors and warnings from the compiler
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-public
-interface ErrorConsumer {
- public void pushError(String errorFileName,
- int line,
- String message,
- String referenceText, String referenceTextPointer);
-};
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/ErrorMessage.java b/src/jdk.rmic/share/classes/sun/tools/javac/ErrorMessage.java
deleted file mode 100644
index 7ee89b49f77..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/ErrorMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-/**
- * A sorted list of error messages
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-final
-class ErrorMessage {
- long where;
- String message;
- ErrorMessage next;
-
- /**
- * Constructor
- */
- ErrorMessage(long where, String message) {
- this.where = where;
- this.message = message;
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/Main.java b/src/jdk.rmic/share/classes/sun/tools/javac/Main.java
deleted file mode 100644
index 835158c80b3..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/Main.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.util.CommandLine;
-// JCOV
-import sun.tools.asm.Assembler;
-// end JCOV
-
-import java.util.*;
-import java.io.*;
-import java.text.MessageFormat;
-
-/**
- * Main program of the Java compiler
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- *
- * @deprecated As of J2SE 1.3, the preferred way to compile Java
- * language sources is by using the new compiler,
- * com.sun.tools.javac.Main.
- */
-@Deprecated
-public
-class Main implements Constants {
- /**
- * Name of the program.
- */
- String program;
-
- /**
- * The stream where error message are printed.
- */
- OutputStream out;
-
- /**
- * Constructor.
- */
- public Main(OutputStream out, String program) {
- this.out = out;
- this.program = program;
- }
-
- /**
- * Exit status.
- * We introduce a separate integer status variable, and do not alter the
- * convention that 'compile' returns a boolean true upon a successful
- * compilation with no errors. (JavaTest relies on this.)
- */
-
- public static final int EXIT_OK = 0; // Compilation completed with no errors.
- public static final int EXIT_ERROR = 1; // Compilation completed but reported errors.
- public static final int EXIT_CMDERR = 2; // Bad command-line arguments and/or switches.
- public static final int EXIT_SYSERR = 3; // System error or resource exhaustion.
- public static final int EXIT_ABNORMAL = 4; // Compiler terminated abnormally.
-
- private int exitStatus;
-
- public int getExitStatus() {
- return exitStatus;
- }
-
- public boolean compilationPerformedSuccessfully() {
- return exitStatus == EXIT_OK || exitStatus == EXIT_ERROR;
- }
-
- public boolean compilationReportedErrors () {
- return exitStatus != EXIT_OK;
- }
-
- /**
- * Output a message.
- */
- private void output(String msg) {
- PrintStream out =
- this.out instanceof PrintStream ? (PrintStream)this.out
- : new PrintStream(this.out, true);
- out.println(msg);
- }
-
- /**
- * Top level error message. This method is called when the
- * environment could not be set up yet.
- */
- private void error(String msg) {
- exitStatus = EXIT_CMDERR;
- output(getText(msg));
- }
-
- private void error(String msg, String arg1) {
- exitStatus = EXIT_CMDERR;
- output(getText(msg, arg1));
- }
-
- private void error(String msg, String arg1, String arg2) {
- exitStatus = EXIT_CMDERR;
- output(getText(msg, arg1, arg2));
- }
-
- /**
- * Print usage message and make exit status an error.
- * Note: 'javac' invoked without any arguments is considered
- * be an error.
- */
- public void usage_error() {
- error("main.usage", program);
- }
-
- private static ResourceBundle messageRB;
-
- /**
- * Initialize ResourceBundle
- */
- static void initResource() {
- try {
- messageRB =
- ResourceBundle.getBundle("sun.tools.javac.resources.javac");
- } catch (MissingResourceException e) {
- throw new Error("Fatal: Resource for javac is missing");
- }
- }
-
- /**
- * get and format message string from resource
- */
- public static String getText(String key) {
- return getText(key, (String)null);
- }
-
- public static String getText(String key, int num) {
- return getText(key, Integer.toString(num));
- }
-
- public static String getText(String key, String fixed) {
- return getText(key, fixed, null);
- }
-
- public static String getText(String key, String fixed1, String fixed2) {
- return getText(key, fixed1, fixed2, null);
- }
-
- public static String getText(String key, String fixed1,
- String fixed2, String fixed3) {
- if (messageRB == null) {
- initResource();
- }
- try {
- String message = messageRB.getString(key);
- return MessageFormat.format(message, fixed1, fixed2, fixed3);
- } catch (MissingResourceException e) {
- if (fixed1 == null) fixed1 = "null";
- if (fixed2 == null) fixed2 = "null";
- if (fixed3 == null) fixed3 = "null";
- String message = "JAVAC MESSAGE FILE IS BROKEN: key={0}, arguments={1}, {2}, {3}";
- return MessageFormat.format(message, key, fixed1, fixed2, fixed3);
- }
- }
-
- // What major and minor version numbers to use for the -target flag.
- // This should grow every time the minor version number accepted by
- // the VM is incremented.
- private static final String[] releases = { "1.1", "1.2", "1.3", "1.4" };
- private static final short[] majorVersions = { 45, 46, 47, 48 };
- private static final short[] minorVersions = { 3, 0, 0, 0 };
-
- /**
- * Run the compiler
- */
- @SuppressWarnings("fallthrough")
- public synchronized boolean compile(String argv[]) {
- String sourcePathArg = null;
- String classPathArg = null;
- String sysClassPathArg = null;
- boolean verbosePath = false;
-
- String targetArg = null;
- short majorVersion = JAVA_DEFAULT_VERSION;
- short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
-
- File destDir = null;
-//JCOV
- File covFile = null;
- String optJcov = "-Xjcov";
- String optJcovFile = "-Xjcov:file=";
-//end JCOV
- int flags = F_WARNINGS | F_DEBUG_LINES | F_DEBUG_SOURCE;
- long tm = System.currentTimeMillis();
- Vector v = new Vector<>();
- boolean nowrite = false;
- String props = null;
- String encoding = null;
-
- // These flags are used to make sure conflicting -O and -g
- // options aren't given.
- String prior_g = null;
- String prior_O = null;
-
- exitStatus = EXIT_OK;
-
- // Pre-process command line for @file arguments
- try {
- argv = CommandLine.parse(argv);
- } catch (FileNotFoundException e) {
- error("javac.err.cant.read", e.getMessage());
- System.exit(1);
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- // Parse arguments
- for (int i = 0 ; i < argv.length ; i++) {
- if (argv[i].equals("-g")) {
- if (prior_g!=null && !(prior_g.equals("-g")))
- error("main.conflicting.options", prior_g, "-g");
- prior_g = "-g";
- flags |= F_DEBUG_LINES;
- flags |= F_DEBUG_VARS;
- flags |= F_DEBUG_SOURCE;
- } else if (argv[i].equals("-g:none")) {
- if (prior_g!=null && !(prior_g.equals("-g:none")))
- error("main.conflicting.options", prior_g, "-g:none");
- prior_g = "-g:none";
- flags &= ~F_DEBUG_LINES;
- flags &= ~F_DEBUG_VARS;
- flags &= ~F_DEBUG_SOURCE;
- } else if (argv[i].startsWith("-g:")) {
- // We choose to have debugging options conflict even
- // if they amount to the same thing (for example,
- // -g:source,lines and -g:lines,source). However, multiple
- // debugging options are allowed if they are textually
- // identical.
- if (prior_g!=null && !(prior_g.equals(argv[i])))
- error("main.conflicting.options", prior_g, argv[i]);
- prior_g = argv[i];
- String args = argv[i].substring("-g:".length());
- flags &= ~F_DEBUG_LINES;
- flags &= ~F_DEBUG_VARS;
- flags &= ~F_DEBUG_SOURCE;
- while (true) {
- if (args.startsWith("lines")) {
- flags |= F_DEBUG_LINES;
- args = args.substring("lines".length());
- } else if (args.startsWith("vars")) {
- flags |= F_DEBUG_VARS;
- args = args.substring("vars".length());
- } else if (args.startsWith("source")) {
- flags |= F_DEBUG_SOURCE;
- args = args.substring("source".length());
- } else {
- error("main.bad.debug.option",argv[i]);
- usage_error();
- return false; // Stop processing now
- }
- if (args.length() == 0) break;
- if (args.startsWith(","))
- args = args.substring(",".length());
- }
- } else if (argv[i].equals("-O")) {
- // -O is accepted for backward compatibility, but
- // is no longer effective. Use the undocumented
- // -XO option to get the old behavior.
- if (prior_O!=null && !(prior_O.equals("-O")))
- error("main.conflicting.options", prior_O, "-O");
- prior_O = "-O";
- } else if (argv[i].equals("-nowarn")) {
- flags &= ~F_WARNINGS;
- } else if (argv[i].equals("-deprecation")) {
- flags |= F_DEPRECATION;
- } else if (argv[i].equals("-verbose")) {
- flags |= F_VERBOSE;
- } else if (argv[i].equals("-nowrite")) {
- nowrite = true;
- } else if (argv[i].equals("-classpath")) {
- if ((i + 1) < argv.length) {
- if (classPathArg!=null) {
- error("main.option.already.seen","-classpath");
- }
- classPathArg = argv[++i];
- } else {
- error("main.option.requires.argument","-classpath");
- usage_error();
- return false; // Stop processing now
- }
- } else if (argv[i].equals("-sourcepath")) {
- if ((i + 1) < argv.length) {
- if (sourcePathArg != null) {
- error("main.option.already.seen","-sourcepath");
- }
- sourcePathArg = argv[++i];
- } else {
- error("main.option.requires.argument","-sourcepath");
- usage_error();
- return false; // Stop processing now
- }
- } else if (argv[i].equals("-sysclasspath")) {
- if ((i + 1) < argv.length) {
- if (sysClassPathArg != null) {
- error("main.option.already.seen","-sysclasspath");
- }
- sysClassPathArg = argv[++i];
- } else {
- error("main.option.requires.argument","-sysclasspath");
- usage_error();
- return false; // Stop processing now
- }
- } else if (argv[i].equals("-bootclasspath")) {
- if ((i + 1) < argv.length) {
- if (sysClassPathArg != null) {
- error("main.option.already.seen","-bootclasspath");
- }
- sysClassPathArg = argv[++i];
- } else {
- error("main.option.requires.argument","-bootclasspath");
- usage_error();
- return false; // Stop processing now
- }
- } else if (argv[i].equals("-encoding")) {
- if ((i + 1) < argv.length) {
- if (encoding!=null)
- error("main.option.already.seen","-encoding");
- encoding = argv[++i];
- } else {
- error("main.option.requires.argument","-encoding");
- usage_error();
- return false; // Stop processing now
- }
- } else if (argv[i].equals("-target")) {
- if ((i + 1) < argv.length) {
- if (targetArg!=null)
- error("main.option.already.seen","-target");
- targetArg = argv[++i];
- int j;
- for (j=0; j optJcovFile.length())) {
- covFile = new File(argv[i].substring(optJcovFile.length()));
- flags &= ~F_OPT;
- flags &= ~F_OPT_INTERCLASS;
- flags |= F_COVERAGE;
- flags |= F_COVDATA;
-// end JCOV
- } else if (argv[i].equals("-XO")) {
- // This is what -O used to be. Now undocumented.
- if (prior_O!=null && !(prior_O.equals("-XO")))
- error("main.conflicting.options", prior_O, "-XO");
- prior_O = "-XO";
- flags |= F_OPT;
- } else if (argv[i].equals("-Xinterclass")) {
- if (prior_O!=null && !(prior_O.equals("-Xinterclass")))
- error("main.conflicting.options", prior_O, "-Xinterclass");
- prior_O = "-Xinterclass";
- flags |= F_OPT;
- flags |= F_OPT_INTERCLASS;
- flags |= F_DEPENDENCIES;
- } else if (argv[i].equals("-Xdepend")) {
- flags |= F_DEPENDENCIES;
- } else if (argv[i].equals("-Xdebug")) {
- flags |= F_DUMP;
- // Unadvertised option used by JWS. The non-X version should
- // be removed, but we'll leave it in until we find out for
- // sure that no one still depends on that option syntax.
- } else if (argv[i].equals("-xdepend") || argv[i].equals("-Xjws")) {
- flags |= F_PRINT_DEPENDENCIES;
- // change the default output in this case:
- if (out == System.err) {
- out = System.out;
- }
- } else if (argv[i].equals("-Xstrictdefault")) {
- // Make strict floating point the default
- flags |= F_STRICTDEFAULT;
- } else if (argv[i].equals("-Xverbosepath")) {
- verbosePath = true;
- } else if (argv[i].equals("-Xstdout")) {
- out = System.out;
- } else if (argv[i].equals("-X")) {
- error("main.unsupported.usage");
- return false; // Stop processing now
- } else if (argv[i].equals("-Xversion1.2")) {
- // Inform the compiler that it need not target VMs
- // earlier than version 1.2. This option is here
- // for testing purposes only. It is deliberately
- // kept orthogonal to the -target option in 1.2.0
- // for the sake of stability. These options will
- // be merged in a future release.
- flags |= F_VERSION12;
- } else if (argv[i].endsWith(".java")) {
- v.addElement(argv[i]);
- } else {
- error("main.no.such.option",argv[i]);
- usage_error();
- return false; // Stop processing now
- }
- }
- if (v.size() == 0 || exitStatus == EXIT_CMDERR) {
- usage_error();
- return false;
- }
-
- // Create our Environment.
- BatchEnvironment env = BatchEnvironment.create(out,
- sourcePathArg,
- classPathArg,
- sysClassPathArg);
- if (verbosePath) {
- output(getText("main.path.msg",
- env.sourcePath.toString(),
- env.binaryPath.toString()));
- }
-
- env.flags |= flags;
- env.majorVersion = majorVersion;
- env.minorVersion = minorVersion;
-// JCOV
- env.covFile = covFile;
-// end JCOV
- env.setCharacterEncoding(encoding);
-
- // Preload the "out of memory" error string just in case we run
- // out of memory during the compile.
- String noMemoryErrorString = getText("main.no.memory");
- String stackOverflowErrorString = getText("main.stack.overflow");
-
- env.error(0, "warn.class.is.deprecated", "sun.tools.javac.Main");
-
- try {
- // Parse all input files
- for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
- File file = new File(e.nextElement());
- try {
- env.parseFile(ClassFile.newClassFile(file));
- } catch (FileNotFoundException ee) {
- env.error(0, "cant.read", file.getPath());
- exitStatus = EXIT_CMDERR;
- }
- }
-
- // Do a post-read check on all newly-parsed classes,
- // after they have all been read.
- for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
- ClassDeclaration c = e.nextElement();
- if (c.getStatus() == CS_PARSED) {
- if (c.getClassDefinition().isLocal())
- continue;
- try {
- c.getClassDefinition(env);
- } catch (ClassNotFound ee) {
- }
- }
- }
-
- // compile all classes that need compilation
- ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
- boolean done;
-
- do {
- done = true;
- env.flushErrors();
- for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
- ClassDeclaration c = e.nextElement();
- SourceClass src;
-
- switch (c.getStatus()) {
- case CS_UNDEFINED:
- if (!env.dependencies()) {
- break;
- }
- // fall through
-
- case CS_SOURCE:
- if (tracing)
- env.dtEvent("Main.compile (SOURCE): loading, " + c);
- done = false;
- env.loadDefinition(c);
- if (c.getStatus() != CS_PARSED) {
- if (tracing)
- env.dtEvent("Main.compile (SOURCE): not parsed, " + c);
- break;
- }
- // fall through
-
- case CS_PARSED:
- if (c.getClassDefinition().isInsideLocal()) {
- // the enclosing block will check this one
- if (tracing)
- env.dtEvent("Main.compile (PARSED): skipping local class, " + c);
- continue;
- }
- done = false;
- if (tracing) env.dtEvent("Main.compile (PARSED): checking, " + c);
- src = (SourceClass)c.getClassDefinition(env);
- src.check(env);
- c.setDefinition(src, CS_CHECKED);
- // fall through
-
- case CS_CHECKED:
- src = (SourceClass)c.getClassDefinition(env);
- // bail out if there were any errors
- if (src.getError()) {
- if (tracing)
- env.dtEvent("Main.compile (CHECKED): bailing out on error, " + c);
- c.setDefinition(src, CS_COMPILED);
- break;
- }
- done = false;
- buf.reset();
- if (tracing)
- env.dtEvent("Main.compile (CHECKED): compiling, " + c);
- src.compile(buf);
- c.setDefinition(src, CS_COMPILED);
- src.cleanup(env);
-
- if (src.getNestError() || nowrite) {
- continue;
- }
-
- String pkgName = c.getName().getQualifier().toString().replace('.', File.separatorChar);
- String className = c.getName().getFlatName().toString().replace('.', SIGC_INNERCLASS) + ".class";
-
- File file;
- if (destDir != null) {
- if (pkgName.length() > 0) {
- file = new File(destDir, pkgName);
- if (!file.exists()) {
- file.mkdirs();
- }
- file = new File(file, className);
- } else {
- file = new File(destDir, className);
- }
- } else {
- ClassFile classfile = (ClassFile)src.getSource();
- if (classfile.isZipped()) {
- env.error(0, "cant.write", classfile.getPath());
- exitStatus = EXIT_CMDERR;
- continue;
- }
- file = new File(classfile.getPath());
- file = new File(file.getParent(), className);
- }
-
- // Create the file
- try {
- FileOutputStream out = new FileOutputStream(file.getPath());
- buf.writeTo(out);
- out.close();
-
- if (env.verbose()) {
- output(getText("main.wrote", file.getPath()));
- }
- } catch (IOException ee) {
- env.error(0, "cant.write", file.getPath());
- exitStatus = EXIT_CMDERR;
- }
-
- // Print class dependencies if requested (-xdepend)
- if (env.print_dependencies()) {
- src.printClassDependencies(env);
- }
- }
- }
- } while (!done);
- } catch (OutOfMemoryError ee) {
- // The compiler has run out of memory. Use the error string
- // which we preloaded.
- env.output(noMemoryErrorString);
- exitStatus = EXIT_SYSERR;
- return false;
- } catch (StackOverflowError ee) {
- env.output(stackOverflowErrorString);
- exitStatus = EXIT_SYSERR;
- return false;
- } catch (Error ee) {
- // We allow the compiler to take an exception silently if a program
- // error has previously been detected. Presumably, this makes the
- // compiler more robust in the face of bad error recovery.
- if (env.nerrors == 0 || env.dump()) {
- ee.printStackTrace();
- env.error(0, "fatal.error");
- exitStatus = EXIT_ABNORMAL;
- }
- } catch (Exception ee) {
- if (env.nerrors == 0 || env.dump()) {
- ee.printStackTrace();
- env.error(0, "fatal.exception");
- exitStatus = EXIT_ABNORMAL;
- }
- }
-
- int ndepfiles = env.deprecationFiles.size();
- if (ndepfiles > 0 && env.warnings()) {
- int ndeps = env.ndeprecations;
- Object file1 = env.deprecationFiles.elementAt(0);
- if (env.deprecation()) {
- if (ndepfiles > 1) {
- env.error(0, "warn.note.deprecations",
- ndepfiles, ndeps);
- } else {
- env.error(0, "warn.note.1deprecation",
- file1, ndeps);
- }
- } else {
- if (ndepfiles > 1) {
- env.error(0, "warn.note.deprecations.silent",
- ndepfiles, ndeps);
- } else {
- env.error(0, "warn.note.1deprecation.silent",
- file1, ndeps);
- }
- }
- }
-
- env.flushErrors();
- env.shutdown();
-
- boolean status = true;
- if (env.nerrors > 0) {
- String msg = "";
- if (env.nerrors > 1) {
- msg = getText("main.errors", env.nerrors);
- } else {
- msg = getText("main.1error");
- }
- if (env.nwarnings > 0) {
- if (env.nwarnings > 1) {
- msg += ", " + getText("main.warnings", env.nwarnings);
- } else {
- msg += ", " + getText("main.1warning");
- }
- }
- output(msg);
- if (exitStatus == EXIT_OK) {
- // Allow EXIT_CMDERR or EXIT_ABNORMAL to take precedence.
- exitStatus = EXIT_ERROR;
- }
- status = false;
- } else {
- if (env.nwarnings > 0) {
- if (env.nwarnings > 1) {
- output(getText("main.warnings", env.nwarnings));
- } else {
- output(getText("main.1warning"));
- }
- }
- }
-//JCOV
- if (env.covdata()) {
- Assembler CovAsm = new Assembler();
- CovAsm.GenJCov(env);
- }
-// end JCOV
-
- // We're done
- if (env.verbose()) {
- tm = System.currentTimeMillis() - tm;
- output(getText("main.done_in", Long.toString(tm)));
- }
-
- return status;
- }
-
- /**
- * Main program
- */
- public static void main(String argv[]) {
- OutputStream out = System.err;
-
- // This is superceeded by the -Xstdout option, but we leave
- // in the old property check for compatibility.
- if (Boolean.getBoolean("javac.pipe.output")) {
- out = System.out;
- }
-
- Main compiler = new Main(out, "javac");
- System.exit(compiler.compile(argv) ? 0 : compiler.exitStatus);
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/SourceClass.java b/src/jdk.rmic/share/classes/sun/tools/javac/SourceClass.java
deleted file mode 100644
index f5458453260..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/SourceClass.java
+++ /dev/null
@@ -1,2673 +0,0 @@
-/*
- * Copyright (c) 1994, 2014, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.tree.*;
-import sun.tools.tree.CompoundStatement;
-import sun.tools.asm.Assembler;
-import sun.tools.asm.ConstantPool;
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.DataOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-
-/**
- * This class represents an Java class as it is read from
- * an Java source file.
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-public
-class SourceClass extends ClassDefinition {
-
- /**
- * The toplevel environment, shared with the parser
- */
- Environment toplevelEnv;
-
- /**
- * The default constructor
- */
- SourceMember defConstructor;
-
- /**
- * The constant pool
- */
- ConstantPool tab = new ConstantPool();
-
- /**
- * The list of class dependencies
- */
- Hashtable deps = new Hashtable<>(11);
-
- /**
- * The field used to represent "this" in all of my code.
- */
- LocalMember thisArg;
-
- /**
- * Last token of class, as reported by parser.
- */
- long endPosition;
-
- /**
- * Access methods for constructors are distinguished from
- * the constructors themselves by a dummy first argument.
- * A unique type used for this purpose and shared by all
- * constructor access methods within a package-member class is
- * maintained here.
- *
- * This field is null except in an outermost class containing
- * one or more classes needing such an access method.
- */
- private Type dummyArgumentType = null;
-
- /**
- * Constructor
- */
- public SourceClass(Environment env, long where,
- ClassDeclaration declaration, String documentation,
- int modifiers, IdentifierToken superClass,
- IdentifierToken interfaces[],
- SourceClass outerClass, Identifier localName) {
- super(env.getSource(), where,
- declaration, modifiers, superClass, interfaces);
- setOuterClass(outerClass);
-
- this.toplevelEnv = env;
- this.documentation = documentation;
-
- if (ClassDefinition.containsDeprecated(documentation)) {
- this.modifiers |= M_DEPRECATED;
- }
-
- // Check for a package level class which is declared static.
- if (isStatic() && outerClass == null) {
- env.error(where, "static.class", this);
- this.modifiers &=~ M_STATIC;
- }
-
- // Inner classes cannot be static, nor can they be interfaces
- // (which are implicitly static). Static classes and interfaces
- // can only occur as top-level entities.
- //
- // Note that we do not have to check for local classes declared
- // to be static (this is currently caught by the parser) but
- // we check anyway in case the parser is modified to allow this.
- if (isLocal() || (outerClass != null && !outerClass.isTopLevel())) {
- if (isInterface()) {
- env.error(where, "inner.interface");
- } else if (isStatic()) {
- env.error(where, "static.inner.class", this);
- this.modifiers &=~ M_STATIC;
- if (innerClassMember != null) {
- innerClassMember.subModifiers(M_STATIC);
- }
- }
- }
-
- if (isPrivate() && outerClass == null) {
- env.error(where, "private.class", this);
- this.modifiers &=~ M_PRIVATE;
- }
- if (isProtected() && outerClass == null) {
- env.error(where, "protected.class", this);
- this.modifiers &=~ M_PROTECTED;
- }
- /*----*
- if ((isPublic() || isProtected()) && isInsideLocal()) {
- env.error(where, "warn.public.local.class", this);
- }
- *----*/
-
- // maybe define an uplevel "A.this" current instance field
- if (!isTopLevel() && !isLocal()) {
- LocalMember outerArg = outerClass.getThisArgument();
- UplevelReference r = getReference(outerArg);
- setOuterMember(r.getLocalField(env));
- }
-
- // Set simple, unmangled local name for a local or anonymous class.
- // NOTE: It would be OK to do this unconditionally, as null is the
- // correct value for a member (non-local) class.
- if (localName != null)
- setLocalName(localName);
-
- // Check for inner class with same simple name as one of
- // its enclosing classes. Note that 'getLocalName' returns
- // the simple, unmangled source-level name of any class.
- // The previous version of this code was not careful to avoid
- // mangled local class names. This version fixes 4047746.
- Identifier thisName = getLocalName();
- if (thisName != idNull) {
- // Test above suppresses error for nested anonymous classes,
- // which have an internal "name", but are not named in source code.
- for (ClassDefinition scope = outerClass; scope != null;
- scope = scope.getOuterClass()) {
- Identifier outerName = scope.getLocalName();
- if (thisName.equals(outerName))
- env.error(where, "inner.redefined", thisName);
- }
- }
- }
-
- /**
- * Return last position in this class.
- * @see #getWhere
- */
- public long getEndPosition() {
- return endPosition;
- }
-
- public void setEndPosition(long endPosition) {
- this.endPosition = endPosition;
- }
-
-
-// JCOV
- /**
- * Return absolute name of source file
- */
- public String getAbsoluteName() {
- String AbsName = ((ClassFile)getSource()).getAbsoluteName();
-
- return AbsName;
- }
-//end JCOV
-
- /**
- * Return imports
- */
- public Imports getImports() {
- return toplevelEnv.getImports();
- }
-
- /**
- * Find or create my "this" argument, which is used for all methods.
- */
- public LocalMember getThisArgument() {
- if (thisArg == null) {
- thisArg = new LocalMember(where, this, 0, getType(), idThis);
- }
- return thisArg;
- }
-
- /**
- * Add a dependency
- */
- public void addDependency(ClassDeclaration c) {
- if (tab != null) {
- tab.put(c);
- }
- // If doing -xdepend option, save away list of class dependencies
- // making sure to NOT include duplicates or the class we are in
- // (Hashtable's put() makes sure we don't have duplicates)
- if ( toplevelEnv.print_dependencies() && c != getClassDeclaration() ) {
- deps.put(c,c);
- }
- }
-
- /**
- * Add a field (check it first)
- */
- public void addMember(Environment env, MemberDefinition f) {
- // Make sure the access permissions are self-consistent:
- switch (f.getModifiers() & (M_PUBLIC | M_PRIVATE | M_PROTECTED)) {
- case M_PUBLIC:
- case M_PRIVATE:
- case M_PROTECTED:
- case 0:
- break;
- default:
- env.error(f.getWhere(), "inconsistent.modifier", f);
- // Cut out the more restrictive modifier(s):
- if (f.isPublic()) {
- f.subModifiers(M_PRIVATE | M_PROTECTED);
- } else {
- f.subModifiers(M_PRIVATE);
- }
- break;
- }
-
- // Note exemption for synthetic members below.
- if (f.isStatic() && !isTopLevel() && !f.isSynthetic()) {
- if (f.isMethod()) {
- env.error(f.getWhere(), "static.inner.method", f, this);
- f.subModifiers(M_STATIC);
- } else if (f.isVariable()) {
- if (!f.isFinal() || f.isBlankFinal()) {
- env.error(f.getWhere(), "static.inner.field", f.getName(), this);
- f.subModifiers(M_STATIC);
- }
- // Even if a static passes this test, there is still another
- // check in 'SourceMember.check'. The check is delayed so
- // that the initializer may be inspected more closely, using
- // 'isConstant()'. Part of fix for 4095568.
- } else {
- // Static inner classes are diagnosed in 'SourceClass.'.
- f.subModifiers(M_STATIC);
- }
- }
-
- if (f.isMethod()) {
- if (f.isConstructor()) {
- if (f.getClassDefinition().isInterface()) {
- env.error(f.getWhere(), "intf.constructor");
- return;
- }
- if (f.isNative() || f.isAbstract() ||
- f.isStatic() || f.isSynchronized() || f.isFinal()) {
- env.error(f.getWhere(), "constr.modifier", f);
- f.subModifiers(M_NATIVE | M_ABSTRACT |
- M_STATIC | M_SYNCHRONIZED | M_FINAL);
- }
- } else if (f.isInitializer()) {
- if (f.getClassDefinition().isInterface()) {
- env.error(f.getWhere(), "intf.initializer");
- return;
- }
- }
-
- // f is not allowed to return an array of void
- if ((f.getType().getReturnType()).isVoidArray()) {
- env.error(f.getWhere(), "void.array");
- }
-
- if (f.getClassDefinition().isInterface() &&
- (f.isStatic() || f.isSynchronized() || f.isNative()
- || f.isFinal() || f.isPrivate() || f.isProtected())) {
- env.error(f.getWhere(), "intf.modifier.method", f);
- f.subModifiers(M_STATIC | M_SYNCHRONIZED | M_NATIVE |
- M_FINAL | M_PRIVATE);
- }
- if (f.isTransient()) {
- env.error(f.getWhere(), "transient.meth", f);
- f.subModifiers(M_TRANSIENT);
- }
- if (f.isVolatile()) {
- env.error(f.getWhere(), "volatile.meth", f);
- f.subModifiers(M_VOLATILE);
- }
- if (f.isAbstract()) {
- if (f.isPrivate()) {
- env.error(f.getWhere(), "abstract.private.modifier", f);
- f.subModifiers(M_PRIVATE);
- }
- if (f.isStatic()) {
- env.error(f.getWhere(), "abstract.static.modifier", f);
- f.subModifiers(M_STATIC);
- }
- if (f.isFinal()) {
- env.error(f.getWhere(), "abstract.final.modifier", f);
- f.subModifiers(M_FINAL);
- }
- if (f.isNative()) {
- env.error(f.getWhere(), "abstract.native.modifier", f);
- f.subModifiers(M_NATIVE);
- }
- if (f.isSynchronized()) {
- env.error(f.getWhere(),"abstract.synchronized.modifier",f);
- f.subModifiers(M_SYNCHRONIZED);
- }
- }
- if (f.isAbstract() || f.isNative()) {
- if (f.getValue() != null) {
- env.error(f.getWhere(), "invalid.meth.body", f);
- f.setValue(null);
- }
- } else {
- if (f.getValue() == null) {
- if (f.isConstructor()) {
- env.error(f.getWhere(), "no.constructor.body", f);
- } else {
- env.error(f.getWhere(), "no.meth.body", f);
- }
- f.addModifiers(M_ABSTRACT);
- }
- }
- Vector arguments = f.getArguments();
- if (arguments != null) {
- // arguments can be null if this is an implicit abstract method
- int argumentLength = arguments.size();
- Type argTypes[] = f.getType().getArgumentTypes();
- for (int i = 0; i < argTypes.length; i++) {
- Object arg = arguments.elementAt(i);
- long where = f.getWhere();
- if (arg instanceof MemberDefinition) {
- where = ((MemberDefinition)arg).getWhere();
- arg = ((MemberDefinition)arg).getName();
- }
- // (arg should be an Identifier now)
- if (argTypes[i].isType(TC_VOID)
- || argTypes[i].isVoidArray()) {
- env.error(where, "void.argument", arg);
- }
- }
- }
- } else if (f.isInnerClass()) {
- if (f.isVolatile() ||
- f.isTransient() || f.isNative() || f.isSynchronized()) {
- env.error(f.getWhere(), "inner.modifier", f);
- f.subModifiers(M_VOLATILE | M_TRANSIENT |
- M_NATIVE | M_SYNCHRONIZED);
- }
- // same check as for fields, below:
- if (f.getClassDefinition().isInterface() &&
- (f.isPrivate() || f.isProtected())) {
- env.error(f.getWhere(), "intf.modifier.field", f);
- f.subModifiers(M_PRIVATE | M_PROTECTED);
- f.addModifiers(M_PUBLIC);
- // Fix up the class itself to agree with
- // the inner-class member.
- ClassDefinition c = f.getInnerClass();
- c.subModifiers(M_PRIVATE | M_PROTECTED);
- c.addModifiers(M_PUBLIC);
- }
- } else {
- if (f.getType().isType(TC_VOID) || f.getType().isVoidArray()) {
- env.error(f.getWhere(), "void.inst.var", f.getName());
- // REMIND: set type to error
- return;
- }
-
- if (f.isSynchronized() || f.isAbstract() || f.isNative()) {
- env.error(f.getWhere(), "var.modifier", f);
- f.subModifiers(M_SYNCHRONIZED | M_ABSTRACT | M_NATIVE);
- }
- if (f.isStrict()) {
- env.error(f.getWhere(), "var.floatmodifier", f);
- f.subModifiers(M_STRICTFP);
- }
- if (f.isTransient() && isInterface()) {
- env.error(f.getWhere(), "transient.modifier", f);
- f.subModifiers(M_TRANSIENT);
- }
- if (f.isVolatile() && (isInterface() || f.isFinal())) {
- env.error(f.getWhere(), "volatile.modifier", f);
- f.subModifiers(M_VOLATILE);
- }
- if (f.isFinal() && (f.getValue() == null) && isInterface()) {
- env.error(f.getWhere(), "initializer.needed", f);
- f.subModifiers(M_FINAL);
- }
-
- if (f.getClassDefinition().isInterface() &&
- (f.isPrivate() || f.isProtected())) {
- env.error(f.getWhere(), "intf.modifier.field", f);
- f.subModifiers(M_PRIVATE | M_PROTECTED);
- f.addModifiers(M_PUBLIC);
- }
- }
- // Do not check for repeated methods here: Types are not yet resolved.
- if (!f.isInitializer()) {
- for (MemberDefinition f2 = getFirstMatch(f.getName());
- f2 != null; f2 = f2.getNextMatch()) {
- if (f.isVariable() && f2.isVariable()) {
- env.error(f.getWhere(), "var.multidef", f, f2);
- return;
- } else if (f.isInnerClass() && f2.isInnerClass() &&
- !f.getInnerClass().isLocal() &&
- !f2.getInnerClass().isLocal()) {
- // Found a duplicate inner-class member.
- // Duplicate local classes are detected in
- // 'VarDeclarationStatement.checkDeclaration'.
- env.error(f.getWhere(), "inner.class.multidef", f);
- return;
- }
- }
- }
-
- super.addMember(env, f);
- }
-
- /**
- * Create an environment suitable for checking this class.
- * Make sure the source and imports are set right.
- * Make sure the environment contains no context information.
- * (Actually, throw away env altogether and use toplevelEnv instead.)
- */
- public Environment setupEnv(Environment env) {
- // In some cases, we go to some trouble to create the 'env' argument
- // that is discarded. We should remove the 'env' argument entirely
- // as well as the vestigial code that supports it. See comments on
- // 'newEnvironment' in 'checkInternal' below.
- return new Environment(toplevelEnv, this);
- }
-
- /**
- * A source class never reports deprecation, since the compiler
- * allows access to deprecated features that are being compiled
- * in the same job.
- */
- public boolean reportDeprecated(Environment env) {
- return false;
- }
-
- /**
- * See if the source file of this class is right.
- * @see ClassDefinition#noteUsedBy
- */
- public void noteUsedBy(ClassDefinition ref, long where, Environment env) {
- // If this class is not public, watch for cross-file references.
- super.noteUsedBy(ref, where, env);
- ClassDefinition def = this;
- while (def.isInnerClass()) {
- def = def.getOuterClass();
- }
- if (def.isPublic()) {
- return; // already checked
- }
- while (ref.isInnerClass()) {
- ref = ref.getOuterClass();
- }
- if (def.getSource().equals(ref.getSource())) {
- return; // intra-file reference
- }
- ((SourceClass)def).checkSourceFile(env, where);
- }
-
- /**
- * Check this class and all its fields.
- */
- public void check(Environment env) throws ClassNotFound {
- if (tracing) env.dtEnter("SourceClass.check: " + getName());
- if (isInsideLocal()) {
- // An inaccessible class gets checked when the surrounding
- // block is checked.
- // QUERY: Should this case ever occur?
- // What would invoke checking of a local class aside from
- // checking the surrounding method body?
- if (tracing) env.dtEvent("SourceClass.check: INSIDE LOCAL " +
- getOuterClass().getName());
- getOuterClass().check(env);
- } else {
- if (isInnerClass()) {
- if (tracing) env.dtEvent("SourceClass.check: INNER CLASS " +
- getOuterClass().getName());
- // Make sure the outer is checked first.
- ((SourceClass)getOuterClass()).maybeCheck(env);
- }
- Vset vset = new Vset();
- Context ctx = null;
- if (tracing)
- env.dtEvent("SourceClass.check: CHECK INTERNAL " + getName());
- vset = checkInternal(setupEnv(env), ctx, vset);
- // drop vset here
- }
- if (tracing) env.dtExit("SourceClass.check: " + getName());
- }
-
- private void maybeCheck(Environment env) throws ClassNotFound {
- if (tracing) env.dtEvent("SourceClass.maybeCheck: " + getName());
- // Check this class now, if it has not yet been checked.
- // Cf. Main.compile(). Perhaps this code belongs there somehow.
- ClassDeclaration c = getClassDeclaration();
- if (c.getStatus() == CS_PARSED) {
- // Set it first to avoid vicious circularity:
- c.setDefinition(this, CS_CHECKED);
- check(env);
- }
- }
-
- private Vset checkInternal(Environment env, Context ctx, Vset vset)
- throws ClassNotFound {
- Identifier nm = getClassDeclaration().getName();
- if (env.verbose()) {
- env.output("[checking class " + nm + "]");
- }
-
- // Save context enclosing class for later access
- // by 'ClassDefinition.resolveName.'
- classContext = ctx;
-
- // At present, the call to 'newEnvironment' is not needed.
- // The incoming environment to 'basicCheck' is always passed to
- // 'setupEnv', which discards it completely. This is also the
- // only call to 'newEnvironment', which is now apparently dead code.
- basicCheck(Context.newEnvironment(env, ctx));
-
- // Validate access for all inner-class components
- // of a qualified name, not just the last one, which
- // is checked below. Yes, this is a dirty hack...
- // Much of this code was cribbed from 'checkSupers'.
- // Part of fix for 4094658.
- ClassDeclaration sup = getSuperClass();
- if (sup != null) {
- long where = getWhere();
- where = IdentifierToken.getWhere(superClassId, where);
- env.resolveExtendsByName(where, this, sup.getName());
- }
- for (int i = 0 ; i < interfaces.length ; i++) {
- ClassDeclaration intf = interfaces[i];
- long where = getWhere();
- // Error localization fails here if interfaces were
- // elided during error recovery from an invalid one.
- if (interfaceIds != null
- && interfaceIds.length == interfaces.length) {
- where = IdentifierToken.getWhere(interfaceIds[i], where);
- }
- env.resolveExtendsByName(where, this, intf.getName());
- }
-
- // Does the name already exist in an imported package?
- // See JLS 8.1 for the precise rules.
- if (!isInnerClass() && !isInsideLocal()) {
- // Discard package qualification for the import checks.
- Identifier simpleName = nm.getName();
- try {
- // We want this to throw a ClassNotFound exception
- Imports imports = toplevelEnv.getImports();
- Identifier ID = imports.resolve(env, simpleName);
- if (ID != getName())
- env.error(where, "class.multidef.import", simpleName, ID);
- } catch (AmbiguousClass e) {
- // At least one of e.name1 and e.name2 must be different
- Identifier ID = (e.name1 != getName()) ? e.name1 : e.name2;
- env.error(where, "class.multidef.import", simpleName, ID);
- } catch (ClassNotFound e) {
- // we want this to happen
- }
-
- // Make sure that no package with the same fully qualified
- // name exists. This is required by JLS 7.1. We only need
- // to perform this check for top level classes -- it isn't
- // necessary for inner classes. (bug 4101529)
- //
- // This change has been backed out because, on WIN32, it
- // failed to distinguish between java.awt.event and
- // java.awt.Event when looking for a directory. We will
- // add this back in later.
- //
- // try {
- // if (env.getPackage(nm).exists()) {
- // env.error(where, "class.package.conflict", nm);
- // }
- // } catch (java.io.IOException ee) {
- // env.error(where, "io.exception.package", nm);
- // }
-
- // Make sure it was defined in the right file
- if (isPublic()) {
- checkSourceFile(env, getWhere());
- }
- }
-
- vset = checkMembers(env, ctx, vset);
- return vset;
- }
-
- private boolean sourceFileChecked = false;
-
- /**
- * See if the source file of this class is of the right name.
- */
- public void checkSourceFile(Environment env, long where) {
- // one error per offending class is sufficient
- if (sourceFileChecked) return;
- sourceFileChecked = true;
-
- String fname = getName().getName() + ".java";
- String src = ((ClassFile)getSource()).getName();
- if (!src.equals(fname)) {
- if (isPublic()) {
- env.error(where, "public.class.file", this, fname);
- } else {
- env.error(where, "warn.package.class.file", this, src, fname);
- }
- }
- }
-
- // Set true if superclass (but not necessarily superinterfaces) have
- // been checked. If the superclass is still unresolved, then an error
- // message should have been issued, and we assume that no further
- // resolution is possible.
- private boolean supersChecked = false;
-
- /**
- * Overrides 'ClassDefinition.getSuperClass'.
- */
-
- public ClassDeclaration getSuperClass(Environment env) {
- if (tracing) env.dtEnter("SourceClass.getSuperClass: " + this);
- // Superclass may fail to be set because of error recovery,
- // so resolve types here only if 'checkSupers' has not yet
- // completed its checks on the superclass.
- // QUERY: Can we eliminate the need to resolve superclasses on demand?
- // See comments in 'checkSupers' and in 'ClassDefinition.getInnerClass'.
- if (superClass == null && superClassId != null && !supersChecked) {
- resolveTypeStructure(env);
- // We used to report an error here if the superclass was not
- // resolved. Having moved the call to 'checkSupers' from 'basicCheck'
- // into 'resolveTypeStructure', the errors reported here should have
- // already been reported. Furthermore, error recovery can null out
- // the superclass, which would cause a spurious error from the test here.
- }
- if (tracing) env.dtExit("SourceClass.getSuperClass: " + this);
- return superClass;
- }
-
- /**
- * Check that all superclasses and superinterfaces are defined and
- * well formed. Among other checks, verify that the inheritance
- * graph is acyclic. Called from 'resolveTypeStructure'.
- */
-
- private void checkSupers(Environment env) throws ClassNotFound {
-
- // *** DEBUG ***
- supersCheckStarted = true;
-
- if (tracing) env.dtEnter("SourceClass.checkSupers: " + this);
-
- if (isInterface()) {
- if (isFinal()) {
- Identifier nm = getClassDeclaration().getName();
- env.error(getWhere(), "final.intf", nm);
- // Interfaces have no superclass. Superinterfaces
- // are checked below, in code shared with the class case.
- }
- } else {
- // Check superclass.
- // Call to 'getSuperClass(env)' (note argument) attempts
- // 'resolveTypeStructure' if superclass has not successfully
- // been resolved. Since we have just now called 'resolveSupers'
- // (see our call in 'resolveTypeStructure'), it is not clear
- // that this can do any good. Why not 'getSuperClass()' here?
- if (getSuperClass(env) != null) {
- long where = getWhere();
- where = IdentifierToken.getWhere(superClassId, where);
- try {
- ClassDefinition def =
- getSuperClass().getClassDefinition(env);
- // Resolve superclass and its ancestors.
- def.resolveTypeStructure(env);
- // Access to the superclass should be checked relative
- // to the surrounding context, not as if the reference
- // appeared within the class body. Changed 'canAccess'
- // to 'extendsCanAccess' to fix 4087314.
- if (!extendsCanAccess(env, getSuperClass())) {
- env.error(where, "cant.access.class", getSuperClass());
- // Might it be a better recovery to let the access go through?
- superClass = null;
- } else if (def.isFinal()) {
- env.error(where, "super.is.final", getSuperClass());
- // Might it be a better recovery to let the access go through?
- superClass = null;
- } else if (def.isInterface()) {
- env.error(where, "super.is.intf", getSuperClass());
- superClass = null;
- } else if (superClassOf(env, getSuperClass())) {
- env.error(where, "cyclic.super");
- superClass = null;
- } else {
- def.noteUsedBy(this, where, env);
- }
- if (superClass == null) {
- def = null;
- } else {
- // If we have a valid superclass, check its
- // supers as well, and so on up to root class.
- // Call to 'enclosingClassOf' will raise
- // 'NullPointerException' if 'def' is null,
- // so omit this check as error recovery.
- ClassDefinition sup = def;
- for (;;) {
- if (enclosingClassOf(sup)) {
- // Do we need a similar test for
- // interfaces? See bugid 4038529.
- env.error(where, "super.is.inner");
- superClass = null;
- break;
- }
- // Since we resolved the superclass and its
- // ancestors above, we should not discover
- // any unresolved classes on the superclass
- // chain. It should thus be sufficient to
- // call 'getSuperClass()' (no argument) here.
- ClassDeclaration s = sup.getSuperClass(env);
- if (s == null) {
- // Superclass not resolved due to error.
- break;
- }
- sup = s.getClassDefinition(env);
- }
- }
- } catch (ClassNotFound e) {
- // Error is detected in call to 'getClassDefinition'.
- // The class may actually exist but be ambiguous.
- // Call env.resolve(e.name) to see if it is.
- // env.resolve(name) will definitely tell us if the
- // class is ambiguous, but may not necessarily tell
- // us if the class is not found.
- // (part of solution for 4059855)
- reportError: {
- try {
- env.resolve(e.name);
- } catch (AmbiguousClass ee) {
- env.error(where,
- "ambig.class", ee.name1, ee.name2);
- superClass = null;
- break reportError;
- } catch (ClassNotFound ee) {
- // fall through
- }
- env.error(where, "super.not.found", e.name, this);
- superClass = null;
- } // The break exits this block
- }
-
- } else {
- // Superclass was null on entry, after call to
- // 'resolveSupers'. This should normally not happen,
- // as 'resolveSupers' sets 'superClass' to a non-null
- // value for all named classes, except for one special
- // case: 'java.lang.Object', which has no superclass.
- if (isAnonymous()) {
- // checker should have filled it in first
- throw new CompilerError("anonymous super");
- } else if (!getName().equals(idJavaLangObject)) {
- throw new CompilerError("unresolved super");
- }
- }
- }
-
- // At this point, if 'superClass' is null due to an error
- // in the user program, a message should have been issued.
- supersChecked = true;
-
- // Check interfaces
- for (int i = 0 ; i < interfaces.length ; i++) {
- ClassDeclaration intf = interfaces[i];
- long where = getWhere();
- if (interfaceIds != null
- && interfaceIds.length == interfaces.length) {
- where = IdentifierToken.getWhere(interfaceIds[i], where);
- }
- try {
- ClassDefinition def = intf.getClassDefinition(env);
- // Resolve superinterface and its ancestors.
- def.resolveTypeStructure(env);
- // Check superinterface access in the correct context.
- // Changed 'canAccess' to 'extendsCanAccess' to fix 4087314.
- if (!extendsCanAccess(env, intf)) {
- env.error(where, "cant.access.class", intf);
- } else if (!intf.getClassDefinition(env).isInterface()) {
- env.error(where, "not.intf", intf);
- } else if (isInterface() && implementedBy(env, intf)) {
- env.error(where, "cyclic.intf", intf);
- } else {
- def.noteUsedBy(this, where, env);
- // Interface is OK, leave it in the interface list.
- continue;
- }
- } catch (ClassNotFound e) {
- // The interface may actually exist but be ambiguous.
- // Call env.resolve(e.name) to see if it is.
- // env.resolve(name) will definitely tell us if the
- // interface is ambiguous, but may not necessarily tell
- // us if the interface is not found.
- // (part of solution for 4059855)
- reportError2: {
- try {
- env.resolve(e.name);
- } catch (AmbiguousClass ee) {
- env.error(where,
- "ambig.class", ee.name1, ee.name2);
- superClass = null;
- break reportError2;
- } catch (ClassNotFound ee) {
- // fall through
- }
- env.error(where, "intf.not.found", e.name, this);
- superClass = null;
- } // The break exits this block
- }
- // Remove this interface from the list of interfaces
- // as recovery from an error.
- ClassDeclaration newInterfaces[] =
- new ClassDeclaration[interfaces.length - 1];
- System.arraycopy(interfaces, 0, newInterfaces, 0, i);
- System.arraycopy(interfaces, i + 1, newInterfaces, i,
- newInterfaces.length - i);
- interfaces = newInterfaces;
- --i;
- }
- if (tracing) env.dtExit("SourceClass.checkSupers: " + this);
- }
-
- /**
- * Check all of the members of this class.
- *
- * Inner classes are checked in the following way. Any class which
- * is immediately contained in a block (anonymous and local classes)
- * is checked along with its containing method; see the
- * SourceMember.check() method for more information. Member classes
- * of this class are checked immediately after this class, unless this
- * class is insideLocal(), in which case, they are checked with the
- * rest of the members.
- */
- private Vset checkMembers(Environment env, Context ctx, Vset vset)
- throws ClassNotFound {
-
- // bail out if there were any errors
- if (getError()) {
- return vset;
- }
-
- // Make sure that all of our member classes have been
- // basicCheck'ed before we check the rest of our members.
- // If our member classes haven't been basicCheck'ed, then they
- // may not have methods. It is important that they
- // have methods so we can process NewInstanceExpressions
- // correctly. This problem didn't occur before 1.2beta1.
- // This is a fix for bug 4082816.
- for (MemberDefinition f = getFirstMember();
- f != null; f = f.getNextMember()) {
- if (f.isInnerClass()) {
- // System.out.println("Considering " + f + " in " + this);
- SourceClass cdef = (SourceClass) f.getInnerClass();
- if (cdef.isMember()) {
- cdef.basicCheck(env);
- }
- }
- }
-
- if (isFinal() && isAbstract()) {
- env.error(where, "final.abstract", this.getName().getName());
- }
-
- // This class should be abstract if there are any abstract methods
- // in our parent classes and interfaces which we do not override.
- // There are odd cases when, even though we cannot access some
- // abstract method from our superclass, that abstract method can
- // still force this class to be abstract. See the discussion in
- // bug id 1240831.
- if (!isInterface() && !isAbstract() && mustBeAbstract(env)) {
- // Set the class abstract.
- modifiers |= M_ABSTRACT;
-
- // Tell the user which methods force this class to be abstract.
-
- // First list all of the "unimplementable" abstract methods.
- Iterator iter = getPermanentlyAbstractMethods();
- while (iter.hasNext()) {
- MemberDefinition method = iter.next();
- // We couldn't override this method even if we
- // wanted to. Try to make the error message
- // as non-confusing as possible.
- env.error(where, "abstract.class.cannot.override",
- getClassDeclaration(), method,
- method.getDefiningClassDeclaration());
- }
-
- // Now list all of the traditional abstract methods.
- iter = getMethods(env);
- while (iter.hasNext()) {
- // For each method, check if it is abstract. If it is,
- // output an appropriate error message.
- MemberDefinition method = iter.next();
- if (method.isAbstract()) {
- env.error(where, "abstract.class",
- getClassDeclaration(), method,
- method.getDefiningClassDeclaration());
- }
- }
- }
-
- // Check the instance variables in a pre-pass before any constructors.
- // This lets constructors "in-line" any initializers directly.
- // It also lets us do some definite assignment checks on variables.
- Context ctxInit = new Context(ctx);
- Vset vsInst = vset.copy();
- Vset vsClass = vset.copy();
-
- // Do definite assignment checking on blank finals.
- // Other variables do not need such checks. The simple textual
- // ordering constraints implemented by MemberDefinition.canReach()
- // are necessary and sufficient for the other variables.
- // Note that within non-static code, all statics are always
- // definitely assigned, and vice-versa.
- for (MemberDefinition f = getFirstMember();
- f != null; f = f.getNextMember()) {
- if (f.isVariable() && f.isBlankFinal()) {
- // The following allocates a LocalMember object as a proxy
- // to represent the field.
- int number = ctxInit.declareFieldNumber(f);
- if (f.isStatic()) {
- vsClass = vsClass.addVarUnassigned(number);
- vsInst = vsInst.addVar(number);
- } else {
- vsInst = vsInst.addVarUnassigned(number);
- vsClass = vsClass.addVar(number);
- }
- }
- }
-
- // For instance variable checks, use a context with a "this" parameter.
- Context ctxInst = new Context(ctxInit, this);
- LocalMember thisArg = getThisArgument();
- int thisNumber = ctxInst.declare(env, thisArg);
- vsInst = vsInst.addVar(thisNumber);
-
- // Do all the initializers in order, checking the definite
- // assignment of blank finals. Separate static from non-static.
- for (MemberDefinition f = getFirstMember();
- f != null; f = f.getNextMember()) {
- try {
- if (f.isVariable() || f.isInitializer()) {
- if (f.isStatic()) {
- vsClass = f.check(env, ctxInit, vsClass);
- } else {
- vsInst = f.check(env, ctxInst, vsInst);
- }
- }
- } catch (ClassNotFound ee) {
- env.error(f.getWhere(), "class.not.found", ee.name, this);
- }
- }
-
- checkBlankFinals(env, ctxInit, vsClass, true);
-
- // Check the rest of the field definitions.
- // (Note: Re-checking a field is a no-op.)
- for (MemberDefinition f = getFirstMember();
- f != null; f = f.getNextMember()) {
- try {
- if (f.isConstructor()) {
- // When checking a constructor, an explicit call to
- // 'this(...)' makes all blank finals definitely assigned.
- // See 'MethodExpression.checkValue'.
- Vset vsCon = f.check(env, ctxInit, vsInst.copy());
- // May issue multiple messages for the same variable!!
- checkBlankFinals(env, ctxInit, vsCon, false);
- // (drop vsCon here)
- } else {
- Vset vsFld = f.check(env, ctx, vset.copy());
- // (drop vsFld here)
- }
- } catch (ClassNotFound ee) {
- env.error(f.getWhere(), "class.not.found", ee.name, this);
- }
- }
-
- // Must mark class as checked before visiting inner classes,
- // as they may in turn request checking of the current class
- // as an outer class. Fix for bug id 4056774.
- getClassDeclaration().setDefinition(this, CS_CHECKED);
-
- // Also check other classes in the same nest.
- // All checking of this nest must be finished before any
- // of its classes emit bytecode.
- // Otherwise, the inner classes might not have a chance to
- // add access or class literal fields to the outer class.
- for (MemberDefinition f = getFirstMember();
- f != null; f = f.getNextMember()) {
- if (f.isInnerClass()) {
- SourceClass cdef = (SourceClass) f.getInnerClass();
- if (!cdef.isInsideLocal()) {
- cdef.maybeCheck(env);
- }
- }
- }
-
- // Note: Since inner classes cannot set up-level variables,
- // the returned vset is always equal to the passed-in vset.
- // Still, we'll return it for the sake of regularity.
- return vset;
- }
-
- /** Make sure all my blank finals exist now. */
-
- private void checkBlankFinals(Environment env, Context ctxInit, Vset vset,
- boolean isStatic) {
- for (int i = 0; i < ctxInit.getVarNumber(); i++) {
- if (!vset.testVar(i)) {
- MemberDefinition ff = ctxInit.getElement(i);
- if (ff != null && ff.isBlankFinal()
- && ff.isStatic() == isStatic
- && ff.getClassDefinition() == this) {
- env.error(ff.getWhere(),
- "final.var.not.initialized", ff.getName());
- }
- }
- }
- }
-
- /**
- * Check this class has its superclass and its interfaces. Also
- * force it to have an method (if it doesn't already have one)
- * and to have all the abstract methods of its parents.
- */
- private boolean basicChecking = false;
- private boolean basicCheckDone = false;
- protected void basicCheck(Environment env) throws ClassNotFound {
-
- if (tracing) env.dtEnter("SourceClass.basicCheck: " + getName());
-
- super.basicCheck(env);
-
- if (basicChecking || basicCheckDone) {
- if (tracing) env.dtExit("SourceClass.basicCheck: OK " + getName());
- return;
- }
-
- if (tracing) env.dtEvent("SourceClass.basicCheck: CHECKING " + getName());
-
- basicChecking = true;
-
- env = setupEnv(env);
-
- Imports imports = env.getImports();
- if (imports != null) {
- imports.resolve(env);
- }
-
- resolveTypeStructure(env);
-
- // Check the existence of the superclass and all interfaces.
- // Also responsible for breaking inheritance cycles. This call
- // has been moved to 'resolveTypeStructure', just after the call
- // to 'resolveSupers', as inheritance cycles must be broken before
- // resolving types within the members. Fixes 4073739.
- // checkSupers(env);
-
- if (!isInterface()) {
-
- // Add implicit method, if necessary.
- // QUERY: What keeps us from adding an implicit constructor
- // when the user explicitly declares one? Is it truly guaranteed
- // that the declaration for such an explicit constructor will have
- // been processed by the time we arrive here? In general, 'basicCheck'
- // is called very early, prior to the normal member checking phase.
- if (!hasConstructor()) {
- Node code = new CompoundStatement(getWhere(), new Statement[0]);
- Type t = Type.tMethod(Type.tVoid);
-
- // Default constructors inherit the access modifiers of their
- // class. For non-inner classes, this follows from JLS 8.6.7,
- // as the only possible modifier is 'public'. For the sake of
- // robustness in the presence of errors, we ignore any other
- // modifiers. For inner classes, the rule needs to be extended
- // in some way to account for the possibility of private and
- // protected classes. We make the 'obvious' extension, however,
- // the inner classes spec is silent on this issue, and a definitive
- // resolution is needed. See bugid 4087421.
- // WORKAROUND: A private constructor might need an access method,
- // but it is not possible to create one due to a restriction in
- // the verifier. (This is a known problem -- see 4015397.)
- // We therefore do not inherit the 'private' modifier from the class,
- // allowing the default constructor to be package private. This
- // workaround can be observed via reflection, but is otherwise
- // undetectable, as the constructor is always accessible within
- // the class in which its containing (private) class appears.
- int accessModifiers = getModifiers() &
- (isInnerClass() ? (M_PUBLIC | M_PROTECTED) : M_PUBLIC);
- env.makeMemberDefinition(env, getWhere(), this, null,
- accessModifiers,
- t, idInit, null, null, code);
- }
- }
-
- // Only do the inheritance/override checks if they are turned on.
- // The idea here is that they will be done in javac, but not
- // in javadoc. See the comment for turnOffChecks(), above.
- if (doInheritanceChecks) {
-
- // Verify the compatibility of all inherited method definitions
- // by collecting all of our inheritable methods.
- collectInheritedMethods(env);
- }
-
- basicChecking = false;
- basicCheckDone = true;
- if (tracing) env.dtExit("SourceClass.basicCheck: " + getName());
- }
-
- /**
- * Add a group of methods to this class as miranda methods.
- *
- * For a definition of Miranda methods, see the comment above the
- * method addMirandaMethods() in the file
- * sun/tools/java/ClassDeclaration.java
- */
- protected void addMirandaMethods(Environment env,
- Iterator mirandas) {
-
- while(mirandas.hasNext()) {
- MemberDefinition method = mirandas.next();
-
- addMember(method);
-
- //System.out.println("adding miranda method " + newMethod +
- // " to " + this);
- }
- }
-
- /**
- * After parsing is complete , resolve all names
- * except those inside method bodies or initializers.
- * In particular, this is the point at which we find out what
- * kinds of variables and methods there are in the classes,
- * and therefore what is each class's interface to the world.
- *
- * Also perform certain other transformations, such as inserting
- * "this$C" arguments into constructors, and reorganizing structure
- * to flatten qualified member names.
- *
- * Do not perform type-based or name-based consistency checks
- * or normalizations (such as default nullary constructors),
- * and do not attempt to compile code against this class,
- * until after this phase.
- */
-
- private boolean resolving = false;
-
- public void resolveTypeStructure(Environment env) {
-
- if (tracing)
- env.dtEnter("SourceClass.resolveTypeStructure: " + getName());
-
- // Resolve immediately enclosing type, which in turn
- // forces resolution of all enclosing type declarations.
- ClassDefinition oc = getOuterClass();
- if (oc != null && oc instanceof SourceClass
- && !((SourceClass)oc).resolved) {
- // Do the outer class first, always.
- ((SourceClass)oc).resolveTypeStructure(env);
- // (Note: this.resolved is probably true at this point.)
- }
-
- // Punt if we've already resolved this class, or are currently
- // in the process of doing so.
- if (resolved || resolving) {
- if (tracing)
- env.dtExit("SourceClass.resolveTypeStructure: OK " + getName());
- return;
- }
-
- // Previously, 'resolved' was set here, and served to prevent
- // duplicate resolutions here as well as its function in
- // 'ClassDefinition.addMember'. Now, 'resolving' serves the
- // former purpose, distinct from that of 'resolved'.
- resolving = true;
-
- if (tracing)
- env.dtEvent("SourceClass.resolveTypeStructure: RESOLVING " + getName());
-
- env = setupEnv(env);
-
- // Resolve superclass names to class declarations
- // for the immediate superclass and superinterfaces.
- resolveSupers(env);
-
- // Check all ancestor superclasses for various
- // errors, verifying definition of all superclasses
- // and superinterfaces. Also breaks inheritance cycles.
- // Calls 'resolveTypeStructure' recursively for ancestors
- // This call used to appear in 'basicCheck', but was not
- // performed early enough. Most of the compiler will barf
- // on inheritance cycles!
- try {
- checkSupers(env);
- } catch (ClassNotFound ee) {
- // Undefined classes should be reported by 'checkSupers'.
- env.error(where, "class.not.found", ee.name, this);
- }
-
- for (MemberDefinition
- f = getFirstMember() ; f != null ; f = f.getNextMember()) {
- if (f instanceof SourceMember)
- ((SourceMember)f).resolveTypeStructure(env);
- }
-
- resolving = false;
-
- // Mark class as resolved. If new members are subsequently
- // added to the class, they will be resolved at that time.
- // See 'ClassDefinition.addMember'. Previously, this variable was
- // set prior to the calls to 'checkSupers' and 'resolveTypeStructure'
- // (which may engender further calls to 'checkSupers'). This could
- // lead to duplicate resolution of implicit constructors, as the call to
- // 'basicCheck' from 'checkSupers' could add the constructor while
- // its class is marked resolved, and thus would resolve the constructor,
- // believing it to be a "late addition". It would then be resolved
- // redundantly during the normal traversal of the members, which
- // immediately follows in the code above.
- resolved = true;
-
- // Now we have enough information to detect method repeats.
- for (MemberDefinition
- f = getFirstMember() ; f != null ; f = f.getNextMember()) {
- if (f.isInitializer()) continue;
- if (!f.isMethod()) continue;
- for (MemberDefinition f2 = f; (f2 = f2.getNextMatch()) != null; ) {
- if (!f2.isMethod()) continue;
- if (f.getType().equals(f2.getType())) {
- env.error(f.getWhere(), "meth.multidef", f);
- continue;
- }
- if (f.getType().equalArguments(f2.getType())) {
- env.error(f.getWhere(), "meth.redef.rettype", f, f2);
- continue;
- }
- }
- }
- if (tracing)
- env.dtExit("SourceClass.resolveTypeStructure: " + getName());
- }
-
- protected void resolveSupers(Environment env) {
- if (tracing)
- env.dtEnter("SourceClass.resolveSupers: " + this);
- // Find the super class
- if (superClassId != null && superClass == null) {
- superClass = resolveSuper(env, superClassId);
- // Special-case java.lang.Object here (not in the parser).
- // In all other cases, if we have a valid 'superClassId',
- // we return with a valid and non-null 'superClass' value.
- if (superClass == getClassDeclaration()
- && getName().equals(idJavaLangObject)) {
- superClass = null;
- superClassId = null;
- }
- }
- // Find interfaces
- if (interfaceIds != null && interfaces == null) {
- interfaces = new ClassDeclaration[interfaceIds.length];
- for (int i = 0 ; i < interfaces.length ; i++) {
- interfaces[i] = resolveSuper(env, interfaceIds[i]);
- for (int j = 0; j < i; j++) {
- if (interfaces[i] == interfaces[j]) {
- Identifier id = interfaceIds[i].getName();
- long where = interfaceIds[j].getWhere();
- env.error(where, "intf.repeated", id);
- }
- }
- }
- }
- if (tracing)
- env.dtExit("SourceClass.resolveSupers: " + this);
- }
-
- private ClassDeclaration resolveSuper(Environment env, IdentifierToken t) {
- Identifier name = t.getName();
- if (tracing)
- env.dtEnter("SourceClass.resolveSuper: " + name);
- if (isInnerClass())
- name = outerClass.resolveName(env, name);
- else
- name = env.resolveName(name);
- ClassDeclaration result = env.getClassDeclaration(name);
- // Result is never null, as a new 'ClassDeclaration' is
- // created if one with the given name does not exist.
- if (tracing) env.dtExit("SourceClass.resolveSuper: " + name);
- return result;
- }
-
- /**
- * During the type-checking of an outer method body or initializer,
- * this routine is called to check a local class body
- * in the proper context.
- * @param sup the named super class or interface (if anonymous)
- * @param args the actual arguments (if anonymous)
- */
- public Vset checkLocalClass(Environment env, Context ctx, Vset vset,
- ClassDefinition sup,
- Expression args[], Type argTypes[]
- ) throws ClassNotFound {
- env = setupEnv(env);
-
- if ((sup != null) != isAnonymous()) {
- throw new CompilerError("resolveAnonymousStructure");
- }
- if (isAnonymous()) {
- resolveAnonymousStructure(env, sup, args, argTypes);
- }
-
- // Run the checks in the lexical context from the outer class.
- vset = checkInternal(env, ctx, vset);
-
- // This is now done by 'checkInternal' via its call to 'checkMembers'.
- // getClassDeclaration().setDefinition(this, CS_CHECKED);
-
- return vset;
- }
-
- /**
- * As with checkLocalClass, run the inline phase for a local class.
- */
- public void inlineLocalClass(Environment env) {
- for (MemberDefinition
- f = getFirstMember(); f != null; f = f.getNextMember()) {
- if ((f.isVariable() || f.isInitializer()) && !f.isStatic()) {
- continue; // inlined inside of constructors only
- }
- try {
- ((SourceMember)f).inline(env);
- } catch (ClassNotFound ee) {
- env.error(f.getWhere(), "class.not.found", ee.name, this);
- }
- }
- if (getReferencesFrozen() != null && !inlinedLocalClass) {
- inlinedLocalClass = true;
- // add more constructor arguments for uplevel references
- for (MemberDefinition
- f = getFirstMember(); f != null; f = f.getNextMember()) {
- if (f.isConstructor()) {
- //((SourceMember)f).addUplevelArguments(false);
- ((SourceMember)f).addUplevelArguments();
- }
- }
- }
- }
- private boolean inlinedLocalClass = false;
-
- /**
- * Check a class which is inside a local class, but is not itself local.
- */
- public Vset checkInsideClass(Environment env, Context ctx, Vset vset)
- throws ClassNotFound {
- if (!isInsideLocal() || isLocal()) {
- throw new CompilerError("checkInsideClass");
- }
- return checkInternal(env, ctx, vset);
- }
-
- /**
- * Just before checking an anonymous class, decide its true
- * inheritance, and build its (sole, implicit) constructor.
- */
- private void resolveAnonymousStructure(Environment env,
- ClassDefinition sup,
- Expression args[], Type argTypes[]
- ) throws ClassNotFound {
-
- if (tracing) env.dtEvent("SourceClass.resolveAnonymousStructure: " +
- this + ", super " + sup);
-
- // Decide now on the superclass.
-
- // This check has been removed as part of the fix for 4055017.
- // In the anonymous class created to hold the 'class$' method
- // of an interface, 'superClassId' refers to 'java.lang.Object'.
- /*---------------------*
- if (!(superClass == null && superClassId.getName() == idNull)) {
- throw new CompilerError("superclass "+superClass);
- }
- *---------------------*/
-
- if (sup.isInterface()) {
- // allow an interface in the "super class" position
- int ni = (interfaces == null) ? 0 : interfaces.length;
- ClassDeclaration i1[] = new ClassDeclaration[1+ni];
- if (ni > 0) {
- System.arraycopy(interfaces, 0, i1, 1, ni);
- if (interfaceIds != null && interfaceIds.length == ni) {
- IdentifierToken id1[] = new IdentifierToken[1+ni];
- System.arraycopy(interfaceIds, 0, id1, 1, ni);
- id1[0] = new IdentifierToken(sup.getName());
- }
- }
- i1[0] = sup.getClassDeclaration();
- interfaces = i1;
-
- sup = toplevelEnv.getClassDefinition(idJavaLangObject);
- }
- superClass = sup.getClassDeclaration();
-
- if (hasConstructor()) {
- throw new CompilerError("anonymous constructor");
- }
-
- // Synthesize an appropriate constructor.
- Type t = Type.tMethod(Type.tVoid, argTypes);
- IdentifierToken names[] = new IdentifierToken[argTypes.length];
- for (int i = 0; i < names.length; i++) {
- names[i] = new IdentifierToken(args[i].getWhere(),
- Identifier.lookup("$"+i));
- }
- int outerArg = (sup.isTopLevel() || sup.isLocal()) ? 0 : 1;
- Expression superArgs[] = new Expression[-outerArg + args.length];
- for (int i = outerArg ; i < args.length ; i++) {
- superArgs[-outerArg + i] = new IdentifierExpression(names[i]);
- }
- long where = getWhere();
- Expression superExp;
- if (outerArg == 0) {
- superExp = new SuperExpression(where);
- } else {
- superExp = new SuperExpression(where,
- new IdentifierExpression(names[0]));
- }
- Expression superCall = new MethodExpression(where,
- superExp, idInit,
- superArgs);
- Statement body[] = { new ExpressionStatement(where, superCall) };
- Node code = new CompoundStatement(where, body);
- int mod = M_SYNTHETIC; // ISSUE: make M_PRIVATE, with wrapper?
- env.makeMemberDefinition(env, where, this, null,
- mod, t, idInit, names, null, code);
- }
-
- /**
- * Convert class modifiers to a string for diagnostic purposes.
- * Accepts modifiers applicable to inner classes and that appear
- * in the InnerClasses attribute only, as well as those that may
- * appear in the class modifier proper.
- */
-
- private static int classModifierBits[] =
- { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
- ACC_INTERFACE, ACC_ABSTRACT, ACC_SUPER, M_ANONYMOUS, M_LOCAL,
- M_STRICTFP, ACC_STRICT};
-
- private static String classModifierNames[] =
- { "PUBLIC", "PRIVATE", "PROTECTED", "STATIC", "FINAL",
- "INTERFACE", "ABSTRACT", "SUPER", "ANONYMOUS", "LOCAL",
- "STRICTFP", "STRICT"};
-
- static String classModifierString(int mods) {
- String s = "";
- for (int i = 0; i < classModifierBits.length; i++) {
- if ((mods & classModifierBits[i]) != 0) {
- s = s + " " + classModifierNames[i];
- mods &= ~classModifierBits[i];
- }
- }
- if (mods != 0) {
- s = s + " ILLEGAL:" + Integer.toHexString(mods);
- }
- return s;
- }
-
- /**
- * Find or create an access method for a private member,
- * or return null if this is not possible.
- */
- public MemberDefinition getAccessMember(Environment env, Context ctx,
- MemberDefinition field, boolean isSuper) {
- return getAccessMember(env, ctx, field, false, isSuper);
- }
-
- public MemberDefinition getUpdateMember(Environment env, Context ctx,
- MemberDefinition field, boolean isSuper) {
- if (!field.isVariable()) {
- throw new CompilerError("method");
- }
- return getAccessMember(env, ctx, field, true, isSuper);
- }
-
- private MemberDefinition getAccessMember(Environment env, Context ctx,
- MemberDefinition field,
- boolean isUpdate,
- boolean isSuper) {
-
- // The 'isSuper' argument is really only meaningful when the
- // target member is a method, in which case an 'invokespecial'
- // is needed. For fields, 'getfield' and 'putfield' instructions
- // are generated in either case, and 'isSuper' currently plays
- // no essential role. Nonetheless, we maintain the distinction
- // consistently for the time being.
-
- boolean isStatic = field.isStatic();
- boolean isMethod = field.isMethod();
-
- // Find pre-existing access method.
- // In the case of a field access method, we only look for the getter.
- // A getter is always created whenever a setter is.
- // QUERY: Why doesn't the 'MemberDefinition' object for the field
- // itself just have fields for its getter and setter?
- MemberDefinition af;
- for (af = getFirstMember(); af != null; af = af.getNextMember()) {
- if (af.getAccessMethodTarget() == field) {
- if (isMethod && af.isSuperAccessMethod() == isSuper) {
- break;
- }
- // Distinguish the getter and the setter by the number of
- // arguments.
- int nargs = af.getType().getArgumentTypes().length;
- // This was (nargs == (isStatic ? 0 : 1) + (isUpdate ? 1 : 0))
- // in order to find a setter as well as a getter. This caused
- // allocation of multiple getters.
- if (nargs == (isStatic ? 0 : 1)) {
- break;
- }
- }
- }
-
- if (af != null) {
- if (!isUpdate) {
- return af;
- } else {
- MemberDefinition uf = af.getAccessUpdateMember();
- if (uf != null) {
- return uf;
- }
- }
- } else if (isUpdate) {
- // must find or create the getter before creating the setter
- af = getAccessMember(env, ctx, field, false, isSuper);
- }
-
- // If we arrive here, we are creating a new access member.
-
- Identifier anm;
- Type dummyType = null;
-
- if (field.isConstructor()) {
- // For a constructor, we use the same name as for all
- // constructors (""), but add a distinguishing
- // argument of an otherwise unused "dummy" type.
- anm = idInit;
- // Get the dummy class, creating it if necessary.
- SourceClass outerMostClass = (SourceClass)getTopClass();
- dummyType = outerMostClass.dummyArgumentType;
- if (dummyType == null) {
- // Create dummy class.
- IdentifierToken sup =
- new IdentifierToken(0, idJavaLangObject);
- IdentifierToken interfaces[] = {};
- IdentifierToken t = new IdentifierToken(0, idNull);
- int mod = M_ANONYMOUS | M_STATIC | M_SYNTHETIC;
- // If an interface has a public inner class, the dummy class for
- // the constructor must always be accessible. Fix for 4221648.
- if (outerMostClass.isInterface()) {
- mod |= M_PUBLIC;
- }
- ClassDefinition dummyClass =
- toplevelEnv.makeClassDefinition(toplevelEnv,
- 0, t, null, mod,
- sup, interfaces,
- outerMostClass);
- // Check the class.
- // It is likely that a full check is not really necessary,
- // but it is essential that the class be marked as parsed.
- dummyClass.getClassDeclaration().setDefinition(dummyClass, CS_PARSED);
- Expression argsX[] = {};
- Type argTypesX[] = {};
- try {
- ClassDefinition supcls =
- toplevelEnv.getClassDefinition(idJavaLangObject);
- dummyClass.checkLocalClass(toplevelEnv, null,
- new Vset(), supcls, argsX, argTypesX);
- } catch (ClassNotFound ee) {};
- // Get class type.
- dummyType = dummyClass.getType();
- outerMostClass.dummyArgumentType = dummyType;
- }
- } else {
- // Otherwise, we use the name "access$N", for the
- // smallest value of N >= 0 yielding an unused name.
- for (int i = 0; ; i++) {
- anm = Identifier.lookup(prefixAccess + i);
- if (getFirstMatch(anm) == null) {
- break;
- }
- }
- }
-
- Type argTypes[];
- Type t = field.getType();
-
- if (isStatic) {
- if (!isMethod) {
- if (!isUpdate) {
- Type at[] = { };
- argTypes = at;
- t = Type.tMethod(t); // nullary getter
- } else {
- Type at[] = { t };
- argTypes = at;
- t = Type.tMethod(Type.tVoid, argTypes); // unary setter
- }
- } else {
- // Since constructors are never static, we don't
- // have to worry about a dummy argument here.
- argTypes = t.getArgumentTypes();
- }
- } else {
- // All access methods for non-static members get an explicit
- // 'this' pointer as an extra argument, as the access methods
- // themselves must be static. EXCEPTION: Access methods for
- // constructors are non-static.
- Type classType = this.getType();
- if (!isMethod) {
- if (!isUpdate) {
- Type at[] = { classType };
- argTypes = at;
- t = Type.tMethod(t, argTypes); // nullary getter
- } else {
- Type at[] = { classType, t };
- argTypes = at;
- t = Type.tMethod(Type.tVoid, argTypes); // unary setter
- }
- } else {
- // Target is a method, possibly a constructor.
- Type at[] = t.getArgumentTypes();
- int nargs = at.length;
- if (field.isConstructor()) {
- // Access method is a constructor.
- // Requires a dummy argument.
- MemberDefinition outerThisArg =
- ((SourceMember)field).getOuterThisArg();
- if (outerThisArg != null) {
- // Outer instance link must be the first argument.
- // The following is a sanity check that will catch
- // most cases in which in this requirement is violated.
- if (at[0] != outerThisArg.getType()) {
- throw new CompilerError("misplaced outer this");
- }
- // Strip outer 'this' argument.
- // It will be added back when the access method is checked.
- argTypes = new Type[nargs];
- argTypes[0] = dummyType;
- for (int i = 1; i < nargs; i++) {
- argTypes[i] = at[i];
- }
- } else {
- // There is no outer instance.
- argTypes = new Type[nargs+1];
- argTypes[0] = dummyType;
- for (int i = 0; i < nargs; i++) {
- argTypes[i+1] = at[i];
- }
- }
- } else {
- // Access method is static.
- // Requires an explicit 'this' argument.
- argTypes = new Type[nargs+1];
- argTypes[0] = classType;
- for (int i = 0; i < nargs; i++) {
- argTypes[i+1] = at[i];
- }
- }
- t = Type.tMethod(t.getReturnType(), argTypes);
- }
- }
-
- int nlen = argTypes.length;
- long where = field.getWhere();
- IdentifierToken names[] = new IdentifierToken[nlen];
- for (int i = 0; i < nlen; i++) {
- names[i] = new IdentifierToken(where, Identifier.lookup("$"+i));
- }
-
- Expression access = null;
- Expression thisArg = null;
- Expression args[] = null;
-
- if (isStatic) {
- args = new Expression[nlen];
- for (int i = 0 ; i < nlen ; i++) {
- args[i] = new IdentifierExpression(names[i]);
- }
- } else {
- if (field.isConstructor()) {
- // Constructor access method is non-static, so
- // 'this' works normally.
- thisArg = new ThisExpression(where);
- // Remove dummy argument, as it is not
- // passed to the target method.
- args = new Expression[nlen-1];
- for (int i = 1 ; i < nlen ; i++) {
- args[i-1] = new IdentifierExpression(names[i]);
- }
- } else {
- // Non-constructor access method is static, so
- // we use the first argument as 'this'.
- thisArg = new IdentifierExpression(names[0]);
- // Remove first argument.
- args = new Expression[nlen-1];
- for (int i = 1 ; i < nlen ; i++) {
- args[i-1] = new IdentifierExpression(names[i]);
- }
- }
- access = thisArg;
- }
-
- if (!isMethod) {
- access = new FieldExpression(where, access, field);
- if (isUpdate) {
- access = new AssignExpression(where, access, args[0]);
- }
- } else {
- // If true, 'isSuper' forces a non-virtual call.
- access = new MethodExpression(where, access, field, args, isSuper);
- }
-
- Statement code;
- if (t.getReturnType().isType(TC_VOID)) {
- code = new ExpressionStatement(where, access);
- } else {
- code = new ReturnStatement(where, access);
- }
- Statement body[] = { code };
- code = new CompoundStatement(where, body);
-
- // Access methods are now static (constructors excepted), and no longer final.
- // This change was mandated by the interaction of the access method
- // naming conventions and the restriction against overriding final
- // methods.
- int mod = M_SYNTHETIC;
- if (!field.isConstructor()) {
- mod |= M_STATIC;
- }
-
- // Create the synthetic method within the class in which the referenced
- // private member appears. The 'env' argument to 'makeMemberDefinition'
- // is suspect because it represents the environment at the point at
- // which a reference takes place, while it should represent the
- // environment in which the definition of the synthetic method appears.
- // We get away with this because 'env' is used only to access globals
- // such as 'Environment.error', and also as an argument to
- // 'resolveTypeStructure', which immediately discards it using
- // 'setupEnv'. Apparently, the current definition of 'setupEnv'
- // represents a design change that has not been thoroughly propagated.
- // An access method is declared with same list of exceptions as its
- // target. As the exceptions are simply listed by name, the correctness
- // of this approach requires that the access method be checked
- // (name-resolved) in the same context as its target method This
- // should always be the case.
- SourceMember newf = (SourceMember)
- env.makeMemberDefinition(env, where, this,
- null, mod, t, anm, names,
- field.getExceptionIds(), code);
- // Just to be safe, copy over the name-resolved exceptions from the
- // target so that the context in which the access method is checked
- // doesn't matter.
- newf.setExceptions(field.getExceptions(env));
-
- newf.setAccessMethodTarget(field);
- if (isUpdate) {
- af.setAccessUpdateMember(newf);
- }
- newf.setIsSuperAccessMethod(isSuper);
-
- // The call to 'check' is not needed, as the access method will be
- // checked by the containing class after it is added. This is the
- // idiom followed in the implementation of class literals. (See
- // 'FieldExpression.java'.) In any case, the context is wrong in the
- // call below. The access method must be checked in the context in
- // which it is declared, i.e., the class containing the referenced
- // private member, not the (inner) class in which the original member
- // reference occurs.
- //
- // try {
- // newf.check(env, ctx, new Vset());
- // } catch (ClassNotFound ee) {
- // env.error(where, "class.not.found", ee.name, this);
- // }
-
- // The comment above is inaccurate. While it is often the case
- // that the containing class will check the access method, this is
- // by no means guaranteed. In fact, an access method may be added
- // after the checking of its class is complete. In this case, however,
- // the context in which the class was checked will have been saved in
- // the class definition object (by the fix for 4095716), allowing us
- // to check the field now, and in the correct context.
- // This fixes bug 4098093.
-
- Context checkContext = newf.getClassDefinition().getClassContext();
- if (checkContext != null) {
- //System.out.println("checking late addition: " + this);
- try {
- newf.check(env, checkContext, new Vset());
- } catch (ClassNotFound ee) {
- env.error(where, "class.not.found", ee.name, this);
- }
- }
-
-
- //System.out.println("[Access member '" +
- // newf + "' created for field '" +
- // field +"' in class '" + this + "']");
-
- return newf;
- }
-
- /**
- * Find an inner class of 'this', chosen arbitrarily.
- * Result is always an actual class, never an interface.
- * Returns null if none found.
- */
- SourceClass findLookupContext() {
- // Look for an immediate inner class.
- for (MemberDefinition f = getFirstMember();
- f != null;
- f = f.getNextMember()) {
- if (f.isInnerClass()) {
- SourceClass ic = (SourceClass)f.getInnerClass();
- if (!ic.isInterface()) {
- return ic;
- }
- }
- }
- // Look for a class nested within an immediate inner interface.
- // At this point, we have given up on finding a minimally-nested
- // class (which would require a breadth-first traversal). It doesn't
- // really matter which inner class we find.
- for (MemberDefinition f = getFirstMember();
- f != null;
- f = f.getNextMember()) {
- if (f.isInnerClass()) {
- SourceClass lc =
- ((SourceClass)f.getInnerClass()).findLookupContext();
- if (lc != null) {
- return lc;
- }
- }
- }
- // No inner classes.
- return null;
- }
-
- private MemberDefinition lookup = null;
-
- /**
- * Get helper method for class literal lookup.
- */
- public MemberDefinition getClassLiteralLookup(long fwhere) {
-
- // If we have already created a lookup method, reuse it.
- if (lookup != null) {
- return lookup;
- }
-
- // If the current class is a nested class, make sure we put the
- // lookup method in the outermost class. Set 'lookup' for the
- // intervening inner classes so we won't have to do the search
- // again.
- if (outerClass != null) {
- lookup = outerClass.getClassLiteralLookup(fwhere);
- return lookup;
- }
-
- // If we arrive here, there was no existing 'class$' method.
-
- ClassDefinition c = this;
- boolean needNewClass = false;
-
- if (isInterface()) {
- // The top-level type is an interface. Try to find an existing
- // inner class in which to create the helper method. Any will do.
- c = findLookupContext();
- if (c == null) {
- // The interface has no inner classes. Create an anonymous
- // inner class to hold the helper method, as an interface must
- // not have any methods. The tests above for prior creation
- // of a 'class$' method assure that only one such class is
- // allocated for each outermost class containing a class
- // literal embedded somewhere within. Part of fix for 4055017.
- needNewClass = true;
- IdentifierToken sup =
- new IdentifierToken(fwhere, idJavaLangObject);
- IdentifierToken interfaces[] = {};
- IdentifierToken t = new IdentifierToken(fwhere, idNull);
- int mod = M_PUBLIC | M_ANONYMOUS | M_STATIC | M_SYNTHETIC;
- c = (SourceClass)
- toplevelEnv.makeClassDefinition(toplevelEnv,
- fwhere, t, null, mod,
- sup, interfaces, this);
- }
- }
-
-
- // The name of the class-getter stub is "class$"
- Identifier idDClass = Identifier.lookup(prefixClass);
- Type strarg[] = { Type.tString };
-
- // Some sanity checks of questionable value.
- //
- // This check became useless after matchMethod() was modified
- // to not return synthetic methods.
- //
- //try {
- // lookup = c.matchMethod(toplevelEnv, c, idDClass, strarg);
- //} catch (ClassNotFound ee) {
- // throw new CompilerError("unexpected missing class");
- //} catch (AmbiguousMember ee) {
- // throw new CompilerError("synthetic name clash");
- //}
- //if (lookup != null && lookup.getClassDefinition() == c) {
- // // Error if method found was not inherited.
- // throw new CompilerError("unexpected duplicate");
- //}
- // Some sanity checks of questionable value.
-
- /* // The helper function looks like this.
- * // It simply maps a checked exception to an unchecked one.
- * static Class class$(String class$) {
- * try { return Class.forName(class$); }
- * catch (ClassNotFoundException forName) {
- * throw new NoClassDefFoundError(forName.getMessage());
- * }
- * }
- */
- long w = c.getWhere();
- IdentifierToken arg = new IdentifierToken(w, idDClass);
- Expression e = new IdentifierExpression(arg);
- Expression a1[] = { e };
- Identifier idForName = Identifier.lookup("forName");
- e = new MethodExpression(w, new TypeExpression(w, Type.tClassDesc),
- idForName, a1);
- Statement body = new ReturnStatement(w, e);
- // map the exceptions
- Identifier idClassNotFound =
- Identifier.lookup("java.lang.ClassNotFoundException");
- Identifier idNoClassDefFound =
- Identifier.lookup("java.lang.NoClassDefFoundError");
- Type ctyp = Type.tClass(idClassNotFound);
- Type exptyp = Type.tClass(idNoClassDefFound);
- Identifier idGetMessage = Identifier.lookup("getMessage");
- e = new IdentifierExpression(w, idForName);
- e = new MethodExpression(w, e, idGetMessage, new Expression[0]);
- Expression a2[] = { e };
- e = new NewInstanceExpression(w, new TypeExpression(w, exptyp), a2);
- Statement handler = new CatchStatement(w, new TypeExpression(w, ctyp),
- new IdentifierToken(idForName),
- new ThrowStatement(w, e));
- Statement handlers[] = { handler };
- body = new TryStatement(w, body, handlers);
-
- Type mtype = Type.tMethod(Type.tClassDesc, strarg);
- IdentifierToken args[] = { arg };
-
- // Use default (package) access. If private, an access method would
- // be needed in the event that the class literal belonged to an interface.
- // Also, making it private tickles bug 4098316.
- lookup = toplevelEnv.makeMemberDefinition(toplevelEnv, w,
- c, null,
- M_STATIC | M_SYNTHETIC,
- mtype, idDClass,
- args, null, body);
-
- // If a new class was created to contain the helper method,
- // check it now.
- if (needNewClass) {
- if (c.getClassDeclaration().getStatus() == CS_CHECKED) {
- throw new CompilerError("duplicate check");
- }
- c.getClassDeclaration().setDefinition(c, CS_PARSED);
- Expression argsX[] = {};
- Type argTypesX[] = {};
- try {
- ClassDefinition sup =
- toplevelEnv.getClassDefinition(idJavaLangObject);
- c.checkLocalClass(toplevelEnv, null,
- new Vset(), sup, argsX, argTypesX);
- } catch (ClassNotFound ee) {};
- }
-
- return lookup;
- }
-
-
- /**
- * A list of active ongoing compilations. This list
- * is used to stop two compilations from saving the
- * same class.
- */
- private static Vector active = new Vector<>();
-
- /**
- * Compile this class
- */
- public void compile(OutputStream out)
- throws InterruptedException, IOException {
- Environment env = toplevelEnv;
- synchronized (active) {
- while (active.contains(getName())) {
- active.wait();
- }
- active.addElement(getName());
- }
-
- try {
- compileClass(env, out);
- } catch (ClassNotFound e) {
- throw new CompilerError(e);
- } finally {
- synchronized (active) {
- active.removeElement(getName());
- active.notifyAll();
- }
- }
- }
-
- /**
- * Verify that the modifier bits included in 'required' are
- * all present in 'mods', otherwise signal an internal error.
- * Note that errors in the source program may corrupt the modifiers,
- * thus we rely on the fact that 'CompilerError' exceptions are
- * silently ignored after an error message has been issued.
- */
- private static void assertModifiers(int mods, int required) {
- if ((mods & required) != required) {
- throw new CompilerError("illegal class modifiers");
- }
- }
-
- protected void compileClass(Environment env, OutputStream out)
- throws IOException, ClassNotFound {
- Vector variables = new Vector<>();
- Vector methods = new Vector<>();
- Vector innerClasses = new Vector<>();
- CompilerMember init = new CompilerMember(new MemberDefinition(getWhere(), this, M_STATIC, Type.tMethod(Type.tVoid), idClassInit, null, null), new Assembler());
- Context ctx = new Context((Context)null, init.field);
-
- for (ClassDefinition def = this; def.isInnerClass(); def = def.getOuterClass()) {
- innerClasses.addElement(def);
- }
- // Reverse the order, so that outer levels come first:
- int ncsize = innerClasses.size();
- for (int i = ncsize; --i >= 0; )
- innerClasses.addElement(innerClasses.elementAt(i));
- for (int i = ncsize; --i >= 0; )
- innerClasses.removeElementAt(i);
-
- // System.out.println("compile class " + getName());
-
- boolean haveDeprecated = this.isDeprecated();
- boolean haveSynthetic = this.isSynthetic();
- boolean haveConstantValue = false;
- boolean haveExceptions = false;
-
- // Generate code for all fields
- for (SourceMember field = (SourceMember)getFirstMember();
- field != null;
- field = (SourceMember)field.getNextMember()) {
-
- //System.out.println("compile field " + field.getName());
-
- haveDeprecated |= field.isDeprecated();
- haveSynthetic |= field.isSynthetic();
-
- try {
- if (field.isMethod()) {
- haveExceptions |=
- (field.getExceptions(env).length > 0);
-
- if (field.isInitializer()) {
- if (field.isStatic()) {
- field.code(env, init.asm);
- }
- } else {
- CompilerMember f =
- new CompilerMember(field, new Assembler());
- field.code(env, f.asm);
- methods.addElement(f);
- }
- } else if (field.isInnerClass()) {
- innerClasses.addElement(field.getInnerClass());
- } else if (field.isVariable()) {
- field.inline(env);
- CompilerMember f = new CompilerMember(field, null);
- variables.addElement(f);
- if (field.isStatic()) {
- field.codeInit(env, ctx, init.asm);
-
- }
- haveConstantValue |=
- (field.getInitialValue() != null);
- }
- } catch (CompilerError ee) {
- ee.printStackTrace();
- env.error(field, 0, "generic",
- field.getClassDeclaration() + ":" + field +
- "@" + ee.toString(), null, null);
- }
- }
- if (!init.asm.empty()) {
- init.asm.add(getWhere(), opc_return, true);
- methods.addElement(init);
- }
-
- // bail out if there were any errors
- if (getNestError()) {
- return;
- }
-
- int nClassAttrs = 0;
-
- // Insert constants
- if (methods.size() > 0) {
- tab.put("Code");
- }
- if (haveConstantValue) {
- tab.put("ConstantValue");
- }
-
- String sourceFile = null;
- if (env.debug_source()) {
- sourceFile = ((ClassFile)getSource()).getName();
- tab.put("SourceFile");
- tab.put(sourceFile);
- nClassAttrs += 1;
- }
-
- if (haveExceptions) {
- tab.put("Exceptions");
- }
-
- if (env.debug_lines()) {
- tab.put("LineNumberTable");
- }
- if (haveDeprecated) {
- tab.put("Deprecated");
- if (this.isDeprecated()) {
- nClassAttrs += 1;
- }
- }
- if (haveSynthetic) {
- tab.put("Synthetic");
- if (this.isSynthetic()) {
- nClassAttrs += 1;
- }
- }
-// JCOV
- if (env.coverage()) {
- nClassAttrs += 2; // AbsoluteSourcePath, TimeStamp
- tab.put("AbsoluteSourcePath");
- tab.put("TimeStamp");
- tab.put("CoverageTable");
- }
-// end JCOV
- if (env.debug_vars()) {
- tab.put("LocalVariableTable");
- }
- if (innerClasses.size() > 0) {
- tab.put("InnerClasses");
- nClassAttrs += 1; // InnerClasses
- }
-
-// JCOV
- String absoluteSourcePath = "";
- long timeStamp = 0;
-
- if (env.coverage()) {
- absoluteSourcePath = getAbsoluteName();
- timeStamp = System.currentTimeMillis();
- tab.put(absoluteSourcePath);
- }
-// end JCOV
- tab.put(getClassDeclaration());
- if (getSuperClass() != null) {
- tab.put(getSuperClass());
- }
- for (int i = 0 ; i < interfaces.length ; i++) {
- tab.put(interfaces[i]);
- }
-
- // Sort the methods in order to make sure both constant pool
- // entries and methods are in a deterministic order from run
- // to run (this allows comparing class files for a fixed point
- // to validate the compiler)
- CompilerMember[] ordered_methods =
- new CompilerMember[methods.size()];
- methods.copyInto(ordered_methods);
- java.util.Arrays.sort(ordered_methods);
- for (int i=0; i e = methods.elements() ; e.hasMoreElements() ; ) {
- CompilerMember f = e.nextElement();
- try {
- f.asm.optimize(env);
- f.asm.collect(env, f.field, tab);
- tab.put(f.name);
- tab.put(f.sig);
- ClassDeclaration exp[] = f.field.getExceptions(env);
- for (int i = 0 ; i < exp.length ; i++) {
- tab.put(exp[i]);
- }
- } catch (Exception ee) {
- ee.printStackTrace();
- env.error(f.field, -1, "generic", f.field.getName() + "@" + ee.toString(), null, null);
- f.asm.listing(System.out);
- }
- }
-
- // Collect field constants
- for (Enumeration e = variables.elements() ; e.hasMoreElements() ; ) {
- CompilerMember f = e.nextElement();
- tab.put(f.name);
- tab.put(f.sig);
-
- Object val = f.field.getInitialValue();
- if (val != null) {
- tab.put((val instanceof String) ? new StringExpression(f.field.getWhere(), (String)val) : val);
- }
- }
-
- // Collect inner class constants
- for (Enumeration e = innerClasses.elements();
- e.hasMoreElements() ; ) {
- ClassDefinition inner = e.nextElement();
- tab.put(inner.getClassDeclaration());
-
- // If the inner class is local, we do not need to add its
- // outer class here -- the outer_class_info_index is zero.
- if (!inner.isLocal()) {
- ClassDefinition outer = inner.getOuterClass();
- tab.put(outer.getClassDeclaration());
- }
-
- // If the local name of the class is idNull, don't bother to
- // add it to the constant pool. We won't need it.
- Identifier inner_local_name = inner.getLocalName();
- if (inner_local_name != idNull) {
- tab.put(inner_local_name.toString());
- }
- }
-
- // Write header
- DataOutputStream data = new DataOutputStream(out);
- data.writeInt(JAVA_MAGIC);
- data.writeShort(toplevelEnv.getMinorVersion());
- data.writeShort(toplevelEnv.getMajorVersion());
- tab.write(env, data);
-
- // Write class information
- int cmods = getModifiers() & MM_CLASS;
-
- // Certain modifiers are implied:
- // 1. Any interface (nested or not) is implicitly deemed to be abstract,
- // whether it is explicitly marked so or not. (Java 1.0.)
- // 2. A interface which is a member of a type is implicitly deemed to
- // be static, whether it is explicitly marked so or not.
- // 3a. A type which is a member of an interface is implicitly deemed
- // to be public, whether it is explicitly marked so or not.
- // 3b. A type which is a member of an interface is implicitly deemed
- // to be static, whether it is explicitly marked so or not.
- // All of these rules are implemented in 'BatchParser.beginClass',
- // but the results are verified here.
-
- if (isInterface()) {
- // Rule 1.
- // The VM spec states that ACC_ABSTRACT must be set when
- // ACC_INTERFACE is; this was not done by javac prior to 1.2,
- // and the runtime compensates by setting it. Making sure
- // it is set here will allow the runtime hack to eventually
- // be removed. Rule 2 doesn't apply to transformed modifiers.
- assertModifiers(cmods, ACC_ABSTRACT);
- } else {
- // Contrary to the JVM spec, we only set ACC_SUPER for classes,
- // not interfaces. This is a workaround for a bug in IE3.0,
- // which refuses interfaces with ACC_SUPER on.
- cmods |= ACC_SUPER;
- }
-
- // If this is a nested class, transform access modifiers.
- if (outerClass != null) {
- // If private, transform to default (package) access.
- // If protected, transform to public.
- // M_PRIVATE and M_PROTECTED are already masked off by MM_CLASS above.
- // cmods &= ~(M_PRIVATE | M_PROTECTED);
- if (isProtected()) cmods |= M_PUBLIC;
- // Rule 3a. Note that Rule 3b doesn't apply to transformed modifiers.
- if (outerClass.isInterface()) {
- assertModifiers(cmods, M_PUBLIC);
- }
- }
-
- data.writeShort(cmods);
-
- if (env.dumpModifiers()) {
- Identifier cn = getName();
- Identifier nm =
- Identifier.lookup(cn.getQualifier(), cn.getFlatName());
- System.out.println();
- System.out.println("CLASSFILE " + nm);
- System.out.println("---" + classModifierString(cmods));
- }
-
- data.writeShort(tab.index(getClassDeclaration()));
- data.writeShort((getSuperClass() != null) ? tab.index(getSuperClass()) : 0);
- data.writeShort(interfaces.length);
- for (int i = 0 ; i < interfaces.length ; i++) {
- data.writeShort(tab.index(interfaces[i]));
- }
-
- // write variables
- ByteArrayOutputStream buf = new ByteArrayOutputStream(256);
- ByteArrayOutputStream attbuf = new ByteArrayOutputStream(256);
- DataOutputStream databuf = new DataOutputStream(buf);
-
- data.writeShort(variables.size());
- for (Enumeration e = variables.elements() ; e.hasMoreElements() ; ) {
- CompilerMember f = e.nextElement();
- Object val = f.field.getInitialValue();
-
- data.writeShort(f.field.getModifiers() & MM_FIELD);
- data.writeShort(tab.index(f.name));
- data.writeShort(tab.index(f.sig));
-
- int fieldAtts = (val != null ? 1 : 0);
- boolean dep = f.field.isDeprecated();
- boolean syn = f.field.isSynthetic();
- fieldAtts += (dep ? 1 : 0) + (syn ? 1 : 0);
-
- data.writeShort(fieldAtts);
- if (val != null) {
- data.writeShort(tab.index("ConstantValue"));
- data.writeInt(2);
- data.writeShort(tab.index((val instanceof String) ? new StringExpression(f.field.getWhere(), (String)val) : val));
- }
- if (dep) {
- data.writeShort(tab.index("Deprecated"));
- data.writeInt(0);
- }
- if (syn) {
- data.writeShort(tab.index("Synthetic"));
- data.writeInt(0);
- }
- }
-
- // write methods
-
- data.writeShort(methods.size());
- for (Enumeration e = methods.elements() ; e.hasMoreElements() ; ) {
- CompilerMember f = e.nextElement();
-
- int xmods = f.field.getModifiers() & MM_METHOD;
- // Transform floating point modifiers. M_STRICTFP
- // of member + status of enclosing class turn into
- // ACC_STRICT bit.
- if (((xmods & M_STRICTFP)!=0) || ((cmods & M_STRICTFP)!=0)) {
- xmods |= ACC_STRICT;
- } else {
- // Use the default
- if (env.strictdefault()) {
- xmods |= ACC_STRICT;
- }
- }
- data.writeShort(xmods);
-
- data.writeShort(tab.index(f.name));
- data.writeShort(tab.index(f.sig));
- ClassDeclaration exp[] = f.field.getExceptions(env);
- int methodAtts = ((exp.length > 0) ? 1 : 0);
- boolean dep = f.field.isDeprecated();
- boolean syn = f.field.isSynthetic();
- methodAtts += (dep ? 1 : 0) + (syn ? 1 : 0);
-
- if (!f.asm.empty()) {
- data.writeShort(methodAtts+1);
- f.asm.write(env, databuf, f.field, tab);
- int natts = 0;
- if (env.debug_lines()) {
- natts++;
- }
-// JCOV
- if (env.coverage()) {
- natts++;
- }
-// end JCOV
- if (env.debug_vars()) {
- natts++;
- }
- databuf.writeShort(natts);
-
- if (env.debug_lines()) {
- f.asm.writeLineNumberTable(env, new DataOutputStream(attbuf), tab);
- databuf.writeShort(tab.index("LineNumberTable"));
- databuf.writeInt(attbuf.size());
- attbuf.writeTo(buf);
- attbuf.reset();
- }
-
-//JCOV
- if (env.coverage()) {
- f.asm.writeCoverageTable(env, (ClassDefinition)this, new DataOutputStream(attbuf), tab, f.field.getWhere());
- databuf.writeShort(tab.index("CoverageTable"));
- databuf.writeInt(attbuf.size());
- attbuf.writeTo(buf);
- attbuf.reset();
- }
-// end JCOV
- if (env.debug_vars()) {
- f.asm.writeLocalVariableTable(env, f.field, new DataOutputStream(attbuf), tab);
- databuf.writeShort(tab.index("LocalVariableTable"));
- databuf.writeInt(attbuf.size());
- attbuf.writeTo(buf);
- attbuf.reset();
- }
-
- data.writeShort(tab.index("Code"));
- data.writeInt(buf.size());
- buf.writeTo(data);
- buf.reset();
- } else {
-//JCOV
- if ((env.coverage()) && ((f.field.getModifiers() & M_NATIVE) > 0))
- f.asm.addNativeToJcovTab(env, (ClassDefinition)this);
-// end JCOV
- data.writeShort(methodAtts);
- }
-
- if (exp.length > 0) {
- data.writeShort(tab.index("Exceptions"));
- data.writeInt(2 + exp.length * 2);
- data.writeShort(exp.length);
- for (int i = 0 ; i < exp.length ; i++) {
- data.writeShort(tab.index(exp[i]));
- }
- }
- if (dep) {
- data.writeShort(tab.index("Deprecated"));
- data.writeInt(0);
- }
- if (syn) {
- data.writeShort(tab.index("Synthetic"));
- data.writeInt(0);
- }
- }
-
- // class attributes
- data.writeShort(nClassAttrs);
-
- if (env.debug_source()) {
- data.writeShort(tab.index("SourceFile"));
- data.writeInt(2);
- data.writeShort(tab.index(sourceFile));
- }
-
- if (this.isDeprecated()) {
- data.writeShort(tab.index("Deprecated"));
- data.writeInt(0);
- }
- if (this.isSynthetic()) {
- data.writeShort(tab.index("Synthetic"));
- data.writeInt(0);
- }
-
-// JCOV
- if (env.coverage()) {
- data.writeShort(tab.index("AbsoluteSourcePath"));
- data.writeInt(2);
- data.writeShort(tab.index(absoluteSourcePath));
- data.writeShort(tab.index("TimeStamp"));
- data.writeInt(8);
- data.writeLong(timeStamp);
- }
-// end JCOV
-
- if (innerClasses.size() > 0) {
- data.writeShort(tab.index("InnerClasses"));
- data.writeInt(2 + 2*4*innerClasses.size());
- data.writeShort(innerClasses.size());
- for (Enumeration e = innerClasses.elements() ;
- e.hasMoreElements() ; ) {
- // For each inner class name transformation, we have a record
- // with the following fields:
- //
- // u2 inner_class_info_index; // CONSTANT_Class_info index
- // u2 outer_class_info_index; // CONSTANT_Class_info index
- // u2 inner_name_index; // CONSTANT_Utf8_info index
- // u2 inner_class_access_flags; // access_flags bitmask
- //
- // The spec states that outer_class_info_index is 0 iff
- // the inner class is not a member of its enclosing class (i.e.
- // it is a local or anonymous class). The spec also states
- // that if a class is anonymous then inner_name_index should
- // be 0.
- //
- // See also the initInnerClasses() method in BinaryClass.java.
-
- // Generate inner_class_info_index.
- ClassDefinition inner = e.nextElement();
- data.writeShort(tab.index(inner.getClassDeclaration()));
-
- // Generate outer_class_info_index.
- //
- // Checking isLocal() should probably be enough here,
- // but the check for isAnonymous is added for good
- // measure.
- if (inner.isLocal() || inner.isAnonymous()) {
- data.writeShort(0);
- } else {
- // Query: what about if inner.isInsideLocal()?
- // For now we continue to generate a nonzero
- // outer_class_info_index.
- ClassDefinition outer = inner.getOuterClass();
- data.writeShort(tab.index(outer.getClassDeclaration()));
- }
-
- // Generate inner_name_index.
- Identifier inner_name = inner.getLocalName();
- if (inner_name == idNull) {
- if (!inner.isAnonymous()) {
- throw new CompilerError("compileClass(), anonymous");
- }
- data.writeShort(0);
- } else {
- data.writeShort(tab.index(inner_name.toString()));
- }
-
- // Generate inner_class_access_flags.
- int imods = inner.getInnerClassMember().getModifiers()
- & ACCM_INNERCLASS;
-
- // Certain modifiers are implied for nested types.
- // See rules 1, 2, 3a, and 3b enumerated above.
- // All of these rules are implemented in 'BatchParser.beginClass',
- // but are verified here.
-
- if (inner.isInterface()) {
- // Rules 1 and 2.
- assertModifiers(imods, M_ABSTRACT | M_STATIC);
- }
- if (inner.getOuterClass().isInterface()) {
- // Rules 3a and 3b.
- imods &= ~(M_PRIVATE | M_PROTECTED); // error recovery
- assertModifiers(imods, M_PUBLIC | M_STATIC);
- }
-
- data.writeShort(imods);
-
- if (env.dumpModifiers()) {
- Identifier fn = inner.getInnerClassMember().getName();
- Identifier nm =
- Identifier.lookup(fn.getQualifier(), fn.getFlatName());
- System.out.println("INNERCLASS " + nm);
- System.out.println("---" + classModifierString(imods));
- }
-
- }
- }
-
- // Cleanup
- data.flush();
- tab = null;
-
-// JCOV
- // generate coverage data
- if (env.covdata()) {
- Assembler CovAsm = new Assembler();
- CovAsm.GenVecJCov(env, (ClassDefinition)this, timeStamp);
- }
-// end JCOV
- }
-
- /**
- * Print out the dependencies for this class (-xdepend) option
- */
-
- public void printClassDependencies(Environment env) {
-
- // Only do this if the -xdepend flag is on
- if ( toplevelEnv.print_dependencies() ) {
-
- // Name of java source file this class was in (full path)
- // e.g. /home/ohair/Test.java
- String src = ((ClassFile)getSource()).getAbsoluteName();
-
- // Class name, fully qualified
- // e.g. "java.lang.Object" or "FooBar" or "sun.tools.javac.Main"
- // Inner class names must be mangled, as ordinary '.' qualification
- // is used internally where the spec requires '$' separators.
- // String className = getName().toString();
- String className = Type.mangleInnerType(getName()).toString();
-
- // Line number where class starts in the src file
- long startLine = getWhere() >> WHEREOFFSETBITS;
-
- // Line number where class ends in the src file (not used yet)
- long endLine = getEndPosition() >> WHEREOFFSETBITS;
-
- // First line looks like:
- // CLASS:src,startLine,endLine,className
- System.out.println( "CLASS:"
- + src + ","
- + startLine + ","
- + endLine + ","
- + className);
-
- // For each class this class is dependent on:
- // CLDEP:className1,className2
- // where className1 is the name of the class we are in, and
- // classname2 is the name of the class className1
- // is dependent on.
- for(Enumeration e = deps.elements(); e.hasMoreElements(); ) {
- ClassDeclaration data = e.nextElement();
- // Mangle name of class dependend on.
- String depName =
- Type.mangleInnerType(data.getName()).toString();
- env.output("CLDEP:" + className + "," + depName);
- }
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/SourceMember.java b/src/jdk.rmic/share/classes/sun/tools/javac/SourceMember.java
deleted file mode 100644
index 1cfade9da2d..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/SourceMember.java
+++ /dev/null
@@ -1,907 +0,0 @@
-/*
- * Copyright (c) 1994, 2004, 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 sun.tools.javac;
-
-import sun.tools.java.*;
-import sun.tools.tree.*;
-import sun.tools.asm.*;
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.io.PrintStream;
-
-/**
- * A Source Member
- *
- * WARNING: The contents of this source file are not part of any
- * supported API. Code that depends on them does so at its own risk:
- * they are subject to change or removal without notice.
- */
-@Deprecated
-public
-class SourceMember extends MemberDefinition implements Constants {
- /**
- * The argument names (if it is a method)
- */
- Vector args;
-
- // set to the MemberDefinition in the interface if we have this field because
- // it has been forced on us
- MemberDefinition abstractSource;
-
- /**
- * The status of the field
- */
- int status;
-
- static final int PARSED = 0;
- static final int CHECKING = 1;
- static final int CHECKED = 2;
- static final int INLINING = 3;
- static final int INLINED = 4;
- static final int ERROR = 5;
-
- public Vector getArguments() {
- return args;
- }
-
- /**
- * Constructor
- * @param argNames a vector of IdentifierToken
- */
- public SourceMember(long where, ClassDefinition clazz,
- String doc, int modifiers, Type type,
- Identifier name, Vector argNames,
- IdentifierToken exp[], Node value) {
- super(where, clazz, modifiers, type, name, exp, value);
- this.documentation = doc;
- this.args = argNames; // for the moment
- // not until type names are resolved: createArgumentFields(argNames);
-
- if (ClassDefinition.containsDeprecated(documentation)) {
- this.modifiers |= M_DEPRECATED;
- }
- }
-
- void createArgumentFields(Vector argNames) {
- // Create a list of arguments
- if (isMethod()) {
- args = new Vector<>();
-
- if (isConstructor() || !(isStatic() || isInitializer())) {
- args.addElement(((SourceClass)clazz).getThisArgument());
- }
-
- if (argNames != null) {
- Enumeration e = argNames.elements();
- Type argTypes[] = getType().getArgumentTypes();
- for (int i = 0 ; i < argTypes.length ; i++) {
- Object x = e.nextElement();
- if (x instanceof LocalMember) {
- // This should not happen, but it does
- // in cases of vicious cyclic inheritance.
- args = argNames;
- return;
- }
- Identifier id;
- int mod;
- long where;
- if (x instanceof Identifier) {
- // allow argNames to be simple Identifiers (deprecated!)
- id = (Identifier)x;
- mod = 0;
- where = getWhere();
- } else {
- IdentifierToken token = (IdentifierToken)x;
- id = token.getName();
- mod = token.getModifiers();
- where = token.getWhere();
- }
- args.addElement(new LocalMember(where, clazz, mod,
- argTypes[i], id));
- }
- }
- }
- }
-
- // The methods addOuterThis() and addUplevelArguments() were
- // both originally part of a single method called addUplevelArguments()
- // which took a single boolean parameter describing which of the
- // two behaviors it wanted.
- //
- // The original addUplevelArguments() claimed to keep the arguments in
- // the following order:
- //
- // (1)
- //
- // (By I am referring to the clientOuterField added
- // to some constructors when they are created. If an outer this is
- // added later, on demand, then this is mixed in with the rest of the
- // uplevel arguments and is added by addUplevelArguments.)
- //
- // In reality, the `args' Vector was generated in this order, but the
- // Type array `argTypes' was generated as:
- //
- // (2)
- //
- // This didn't make a difference in the common case -- that is, when
- // a class had an or but not both.
- // Both can happen in the case that a member class is declared inside
- // of a local class. It seems that the calling sequences, generated
- // in places like NewInstanceExpression.codeCommon(), use order (2),
- // so I have changed the code below to stick with that order. Since
- // the only time this happens is in classes which are insideLocal, no
- // one should be able to tell the difference between these orders.
- // (bug number 4085633)
-
- LocalMember outerThisArg = null;
-
- /**
- * Get outer instance link, or null if none.
- */
-
- public LocalMember getOuterThisArg() {
- return outerThisArg;
- }
-
- /**
- * Add the outer.this argument to the list of arguments for this
- * constructor. This is called from resolveTypeStructure. Any
- * additional uplevel arguments get added later by addUplevelArguments().
- */
-
- void addOuterThis() {
- UplevelReference refs = clazz.getReferences();
-
- // See if we have a client outer field.
- while (refs != null &&
- !refs.isClientOuterField()) {
- refs = refs.getNext();
- }
-
- // There is no outer this argument. Quit.
- if (refs == null) {
- return;
- }
-
- // Get the old arg types.
- Type oldArgTypes[] = type.getArgumentTypes();
-
- // And make an array for the new ones with space for one more.
- Type argTypes[] = new Type[oldArgTypes.length + 1];
-
- LocalMember arg = refs.getLocalArgument();
- outerThisArg = arg;
-
- // args is our list of arguments. It contains a `this', so
- // we insert at position 1. The list of types does not have a
- // this, so we insert at position 0.
- args.insertElementAt(arg, 1);
- argTypes[0] = arg.getType();
-
- // Add on the rest of the constructor arguments.
- for (int i = 0; i < oldArgTypes.length; i++) {
- argTypes[i + 1] = oldArgTypes[i];
- }
-
- type = Type.tMethod(type.getReturnType(), argTypes);
- }
-
- /**
- * Prepend argument names and argument types for local variable references.
- * This information is never seen by the type-check phase,
- * but it affects code generation, which is the earliest moment
- * we have comprehensive information on uplevel references.
- * The code() methods tweaks the constructor calls, prepending
- * the proper values to the argument list.
- */
- void addUplevelArguments() {
- UplevelReference refs = clazz.getReferences();
- clazz.getReferencesFrozen();
-
- // Count how many uplevels we have to add.
- int count = 0;
- for (UplevelReference r = refs; r != null; r = r.getNext()) {
- if (!r.isClientOuterField()) {
- count += 1;
- }
- }
-
- if (count == 0) {
- // None to add, quit.
- return;
- }
-
- // Get the old argument types.
- Type oldArgTypes[] = type.getArgumentTypes();
-
- // Make an array with enough room for the new.
- Type argTypes[] = new Type[oldArgTypes.length + count];
-
- // Add all of the late uplevel references to args and argTypes.
- // Note that they are `off-by-one' because of the `this'.
- int ins = 0;
- for (UplevelReference r = refs; r != null; r = r.getNext()) {
- if (!r.isClientOuterField()) {
- LocalMember arg = r.getLocalArgument();
-
- args.insertElementAt(arg, 1 + ins);
- argTypes[ins] = arg.getType();
-
- ins++;
- }
- }
-
- // Add the rest of the old arguments.
- for (int i = 0; i < oldArgTypes.length; i++) {
- argTypes[ins + i] = oldArgTypes[i];
- }
-
- type = Type.tMethod(type.getReturnType(), argTypes);
- }
-
- /**
- * Constructor for an inner class.
- */
- public SourceMember(ClassDefinition innerClass) {
- super(innerClass);
- }
-
- /**
- * Constructor.
- * Used only to generate an abstract copy of a method that a class
- * inherits from an interface
- */
- public SourceMember(MemberDefinition f, ClassDefinition c, Environment env) {
- this(f.getWhere(), c, f.getDocumentation(),
- f.getModifiers() | M_ABSTRACT, f.getType(), f.getName(), null,
- f.getExceptionIds(), null);
- this.args = f.getArguments();
- this.abstractSource = f;
- this.exp = f.getExceptions(env);
- }
-
- /**
- * Get exceptions
- */
- public ClassDeclaration[] getExceptions(Environment env) {
- if ((!isMethod()) || (exp != null)) {
- return exp;
- }
- if (expIds == null) {
- // (should not happen)
- exp = new ClassDeclaration[0];
- return exp;
- }
- // be sure to get the imports right:
- env = ((SourceClass)getClassDefinition()).setupEnv(env);
- exp = new ClassDeclaration[expIds.length];
- for (int i = 0; i < exp.length; i++) {
- Identifier e = expIds[i].getName();
- Identifier rexp = getClassDefinition().resolveName(env, e);
- exp[i] = env.getClassDeclaration(rexp);
- }
- return exp;
- }
-
- /**
- * Set array of name-resolved exceptions directly, e.g., for access methods.
- */
- public void setExceptions(ClassDeclaration[] exp) {
- this.exp = exp;
- }
-
- /**
- * Resolve types in a field, after parsing.
- * @see ClassDefinition.resolveTypeStructure
- */
-
- public boolean resolved = false;
-
- public void resolveTypeStructure(Environment env) {
- if (tracing) env.dtEnter("SourceMember.resolveTypeStructure: " + this);
-
- // A member should only be resolved once. For a constructor, it is imperative
- // that 'addOuterThis' be called only once, else the outer instance argument may
- // be inserted into the argument list multiple times.
-
- if (resolved) {
- if (tracing) env.dtEvent("SourceMember.resolveTypeStructure: OK " + this);
- // This case shouldn't be happening. It is the responsibility
- // of our callers to avoid attempting multiple resolutions of a member.
- // *** REMOVE FOR SHIPMENT? ***
- throw new CompilerError("multiple member type resolution");
- //return;
- } else {
- if (tracing) env.dtEvent("SourceMember.resolveTypeStructure: RESOLVING " + this);
- resolved = true;
- }
-
- super.resolveTypeStructure(env);
- if (isInnerClass()) {
- ClassDefinition nc = getInnerClass();
- if (nc instanceof SourceClass && !nc.isLocal()) {
- ((SourceClass)nc).resolveTypeStructure(env);
- }
- type = innerClass.getType();
- } else {
- // Expand all class names in 'type', including those that are not
- // fully-qualified or refer to inner classes, into fully-qualified
- // names. Local and anonymous classes get synthesized names here,
- // corresponding to the class files that will be generated. This is
- // currently the only place where 'resolveNames' is used.
- type = env.resolveNames(getClassDefinition(), type, isSynthetic());
-
- // do the throws also:
- getExceptions(env);
-
- if (isMethod()) {
- Vector argNames = args; args = null;
- createArgumentFields(argNames);
- // Add outer instance argument for constructors.
- if (isConstructor()) {
- addOuterThis();
- }
- }
- }
- if (tracing) env.dtExit("SourceMember.resolveTypeStructure: " + this);
- }
-
- /**
- * Get the class declaration in which the field is actually defined
- */
- public ClassDeclaration getDefiningClassDeclaration() {
- if (abstractSource == null)
- return super.getDefiningClassDeclaration();
- else
- return abstractSource.getDefiningClassDeclaration();
- }
-
- /**
- * A source field never reports deprecation, since the compiler
- * allows access to deprecated features that are being compiled
- * in the same job.
- */
- public boolean reportDeprecated(Environment env) {
- return false;
- }
-
- /**
- * Check this field.
- *
- * This is the method which requests checking.
- * The real work is done by
- * {@code Vset check(Environment, Context, Vset)}.
- */
- public void check(Environment env) throws ClassNotFound {
- if (tracing) env.dtEnter("SourceMember.check: " +
- getName() + ", status = " + status);
- // rely on the class to check all fields in the proper order
- if (status == PARSED) {
- if (isSynthetic() && getValue() == null) {
- // break a big cycle for small synthetic variables
- status = CHECKED;
- if (tracing)
- env.dtExit("SourceMember.check: BREAKING CYCLE");
- return;
- }
- if (tracing) env.dtEvent("SourceMember.check: CHECKING CLASS");
- clazz.check(env);
- if (status == PARSED) {
- if (getClassDefinition().getError()) {
- status = ERROR;
- } else {
- if (tracing)
- env.dtExit("SourceMember.check: CHECK FAILED");
- throw new CompilerError("check failed");
- }
- }
- }
- if (tracing) env.dtExit("SourceMember.check: DONE " +
- getName() + ", status = " + status);
- }
-
- /**
- * Check a field.
- * @param vset tells which uplevel variables are definitely assigned
- * The vset is also used to track the initialization of blank finals
- * by whichever fields which are relevant to them.
- */
- public Vset check(Environment env, Context ctx, Vset vset) throws ClassNotFound {
- if (tracing) env.dtEvent("SourceMember.check: MEMBER " +
- getName() + ", status = " + status);
- if (status == PARSED) {
- if (isInnerClass()) {
- // some classes are checked separately
- ClassDefinition nc = getInnerClass();
- if (nc instanceof SourceClass && !nc.isLocal()
- && nc.isInsideLocal()) {
- status = CHECKING;
- vset = ((SourceClass)nc).checkInsideClass(env, ctx, vset);
- }
- status = CHECKED;
- return vset;
- }
- if (env.dump()) {
- System.out.println("[check field " + getClassDeclaration().getName() + "." + getName() + "]");
- if (getValue() != null) {
- getValue().print(System.out);
- System.out.println();
- }
- }
- env = new Environment(env, this);
-
- // This is where all checking of names appearing within the type
- // of the member is done. Includes return type and argument types.
- // Since only one location ('where') for error messages is provided,
- // localization of errors is poor. Throws clauses are handled below.
- env.resolve(where, getClassDefinition(), getType());
-
- // Make sure that all the classes that we claim to throw really
- // are subclasses of Throwable, and are classes that we can reach
- if (isMethod()) {
- ClassDeclaration throwable =
- env.getClassDeclaration(idJavaLangThrowable);
- ClassDeclaration exp[] = getExceptions(env);
- for (int i = 0 ; i < exp.length ; i++) {
- ClassDefinition def;
- long where = getWhere();
- if (expIds != null && i < expIds.length) {
- where = IdentifierToken.getWhere(expIds[i], where);
- }
- try {
- def = exp[i].getClassDefinition(env);
-
- // Validate access for all inner-class components
- // of a qualified name, not just the last one, which
- // is checked below. Yes, this is a dirty hack...
- // Part of fix for 4094658.
- env.resolveByName(where, getClassDefinition(), def.getName());
-
- } catch (ClassNotFound e) {
- env.error(where, "class.not.found", e.name, "throws");
- break;
- }
- def.noteUsedBy(getClassDefinition(), where, env);
- if (!getClassDefinition().
- canAccess(env, def.getClassDeclaration())) {
- env.error(where, "cant.access.class", def);
- } else if (!def.subClassOf(env, throwable)) {
- env.error(where, "throws.not.throwable", def);
- }
- }
- }
-
- status = CHECKING;
-
- if (isMethod() && args != null) {
- int length = args.size();
- outer_loop:
- for (int i = 0; i < length; i++) {
- LocalMember lf = (LocalMember)(args.elementAt(i));
- Identifier name_i = lf.getName();
- for (int j = i + 1; j < length; j++) {
- LocalMember lf2 = (LocalMember)(args.elementAt(j));
- Identifier name_j = lf2.getName();
- if (name_i.equals(name_j)) {
- env.error(lf2.getWhere(), "duplicate.argument",
- name_i);
- break outer_loop;
- }
- }
- }
- }
-
- if (getValue() != null) {
- ctx = new Context(ctx, this);
-
- if (isMethod()) {
- Statement s = (Statement)getValue();
- // initialize vset, indication that each of the arguments
- // to the function has a value
-
- for (Enumeration e = args.elements(); e.hasMoreElements();){
- LocalMember f = (LocalMember)e.nextElement();
- vset.addVar(ctx.declare(env, f));
- }
-
- if (isConstructor()) {
- // Undefine "this" in some constructors, until after
- // the super constructor has been called.
- vset.clearVar(ctx.getThisNumber());
-
- // If the first thing in the definition isn't a call
- // to either super() or this(), then insert one.
- Expression supCall = s.firstConstructor();
- if ((supCall == null)
- && (getClassDefinition().getSuperClass() != null)) {
- supCall = getDefaultSuperCall(env);
- Statement scs = new ExpressionStatement(where,
- supCall);
- s = Statement.insertStatement(scs, s);
- setValue(s);
- }
- }
-
- //System.out.println("VSET = " + vset);
- ClassDeclaration exp[] = getExceptions(env);
- int htsize = (exp.length > 3) ? 17 : 7;
- Hashtable thrown = new Hashtable<>(htsize);
-
- vset = s.checkMethod(env, ctx, vset, thrown);
-
- ClassDeclaration ignore1 =
- env.getClassDeclaration(idJavaLangError);
- ClassDeclaration ignore2 =
- env.getClassDeclaration(idJavaLangRuntimeException);
-
- for (Enumeration e = thrown.keys(); e.hasMoreElements();) {
- ClassDeclaration c = (ClassDeclaration)e.nextElement();
- ClassDefinition def = c.getClassDefinition(env);
- if (def.subClassOf(env, ignore1)
- || def.subClassOf(env, ignore2)) {
- continue;
- }
-
- boolean ok = false;
- if (!isInitializer()) {
- for (int i = 0 ; i < exp.length ; i++) {
- if (def.subClassOf(env, exp[i])) {
- ok = true;
- }
- }
- }
- if (!ok) {
- Node n = (Node)thrown.get(c);
- long where = n.getWhere();
- String errorMsg;
-
- if (isConstructor()) {
- if (where ==
- getClassDefinition().getWhere()) {
-
- // If this message is being generated for
- // a default constructor, we should give
- // a different error message. Currently
- // we check for this by seeing if the
- // constructor has the same "where" as
- // its class. This is a bit kludgy, but
- // works. (bug id 4034836)
- errorMsg = "def.constructor.exception";
- } else {
- // Constructor with uncaught exception.
- errorMsg = "constructor.exception";
- }
- } else if (isInitializer()) {
- // Initializer with uncaught exception.
- errorMsg = "initializer.exception";
- } else {
- // Method with uncaught exception.
- errorMsg = "uncaught.exception";
- }
- env.error(where, errorMsg, c.getName());
- }
- }
- } else {
- Hashtable thrown = new Hashtable<>(3); // small & throw-away
- Expression val = (Expression)getValue();
-
- vset = val.checkInitializer(env, ctx, vset,
- getType(), thrown);
- setValue(val.convert(env, ctx, getType(), val));
-
- // Complain about static final members of inner classes that
- // do not have an initializer that is a constant expression.
- // In general, static members are not permitted for inner
- // classes, but an exception is made for named constants.
- // Other cases of static members, including non-final ones,
- // are handled in 'SourceClass'. Part of fix for 4095568.
- if (isStatic() && isFinal() && !clazz.isTopLevel()) {
- if (!((Expression)getValue()).isConstant()) {
- env.error(where, "static.inner.field", getName(), this);
- setValue(null);
- }
- }
-
-
- // Both RuntimeExceptions and Errors should be
- // allowed in initializers. Fix for bug 4102541.
- ClassDeclaration except =
- env.getClassDeclaration(idJavaLangThrowable);
- ClassDeclaration ignore1 =
- env.getClassDeclaration(idJavaLangError);
- ClassDeclaration ignore2 =
- env.getClassDeclaration(idJavaLangRuntimeException);
-
- for (Enumeration e = thrown.keys(); e.hasMoreElements(); ) {
- ClassDeclaration c = (ClassDeclaration)e.nextElement();
- ClassDefinition def = c.getClassDefinition(env);
-
- if (!def.subClassOf(env, ignore1)
- && !def.subClassOf(env, ignore2)
- && def.subClassOf(env, except)) {
- Node n = (Node)thrown.get(c);
- env.error(n.getWhere(),
- "initializer.exception", c.getName());
- }
- }
- }
- if (env.dump()) {
- getValue().print(System.out);
- System.out.println();
- }
- }
- status = getClassDefinition().getError() ? ERROR : CHECKED;
- }
-
-
- // Initializers (static and instance) must be able to complete normally.
- if (isInitializer() && vset.isDeadEnd()) {
- env.error(where, "init.no.normal.completion");
- vset = vset.clearDeadEnd();
- }
-
- return vset;
- }
-
- // helper to check(): synthesize a missing super() call
- private Expression getDefaultSuperCall(Environment env) {
- Expression se = null;
- ClassDefinition sclass = getClassDefinition().getSuperClass().getClassDefinition();
- // does the superclass constructor require an enclosing instance?
- ClassDefinition reqc = (sclass == null) ? null
- : sclass.isTopLevel() ? null
- : sclass.getOuterClass();
- ClassDefinition thisc = getClassDefinition();
- if (reqc != null && !Context.outerLinkExists(env, reqc, thisc)) {
- se = new SuperExpression(where, new NullExpression(where));
- env.error(where, "no.default.outer.arg", reqc, getClassDefinition());
- }
- if (se == null) {
- se = new SuperExpression(where);
- }
- return new MethodExpression(where, se, idInit, new Expression[0]);
- }
-
- /**
- * Inline the field
- */
- void inline(Environment env) throws ClassNotFound {
- switch (status) {
- case PARSED:
- check(env);
- inline(env);
- break;
-
- case CHECKED:
- if (env.dump()) {
- System.out.println("[inline field " + getClassDeclaration().getName() + "." + getName() + "]");
- }
- status = INLINING;
- env = new Environment(env, this);
-
- if (isMethod()) {
- if ((!isNative()) && (!isAbstract())) {
- Statement s = (Statement)getValue();
- Context ctx = new Context((Context)null, this);
- for (Enumeration e = args.elements() ; e.hasMoreElements() ;) {
- LocalMember local = (LocalMember)e.nextElement();
- ctx.declare(env, local);
- }
- setValue(s.inline(env, ctx));
- }
- } else if (isInnerClass()) {
- // some classes are checked and inlined separately
- ClassDefinition nc = getInnerClass();
- if (nc instanceof SourceClass && !nc.isLocal()
- && nc.isInsideLocal()) {
- status = INLINING;
- ((SourceClass)nc).inlineLocalClass(env);
- }
- status = INLINED;
- break;
- } else {
- if (getValue() != null) {
- Context ctx = new Context((Context)null, this);
- if (!isStatic()) {
- // Cf. "thisArg" in SourceClass.checkMembers().
- Context ctxInst = new Context(ctx, this);
- LocalMember thisArg =
- ((SourceClass)clazz).getThisArgument();
- ctxInst.declare(env, thisArg);
- setValue(((Expression)getValue())
- .inlineValue(env, ctxInst));
- } else {
- setValue(((Expression)getValue())
- .inlineValue(env, ctx));
- }
- }
- }
- if (env.dump()) {
- System.out.println("[inlined field " + getClassDeclaration().getName() + "." + getName() + "]");
- if (getValue() != null) {
- getValue().print(System.out);
- System.out.println();
- } else {
- System.out.println("");
- }
- }
- status = INLINED;
- break;
- }
- }
-
- /**
- * Get the value of the field (or null if the value can't be determined)
- */
- public Node getValue(Environment env) throws ClassNotFound {
- Node value = getValue();
- if (value != null && status != INLINED) {
- // be sure to get the imports right:
- env = ((SourceClass)clazz).setupEnv(env);
- inline(env);
- value = (status == INLINED) ? getValue() : null;
- }
- return value;
- }
-
- public boolean isInlineable(Environment env, boolean fromFinal) throws ClassNotFound {
- if (super.isInlineable(env, fromFinal)) {
- getValue(env);
- return (status == INLINED) && !getClassDefinition().getError();
- }
- return false;
- }
-
-
- /**
- * Get the initial value of the field
- */
- public Object getInitialValue() {
- if (isMethod() || (getValue() == null) || (!isFinal()) || (status != INLINED)) {
- return null;
- }
- return ((Expression)getValue()).getValue();
- }
-
- /**
- * Generate code
- */
- public void code(Environment env, Assembler asm) throws ClassNotFound {
- switch (status) {
- case PARSED:
- check(env);
- code(env, asm);
- return;
-
- case CHECKED:
- inline(env);
- code(env, asm);
- return;
-
- case INLINED:
- // Actually generate code
- if (env.dump()) {
- System.out.println("[code field " + getClassDeclaration().getName() + "." + getName() + "]");
- }
- if (isMethod() && (!isNative()) && (!isAbstract())) {
- env = new Environment(env, this);
- Context ctx = new Context((Context)null, this);
- Statement s = (Statement)getValue();
-
- for (Enumeration e = args.elements() ; e.hasMoreElements() ; ) {
- LocalMember f = (LocalMember)e.nextElement();
- ctx.declare(env, f);
- //ctx.declare(env, (LocalMember)e.nextElement());
- }
-
- /*
- if (isConstructor() && ((s == null) || (s.firstConstructor() == null))) {
- ClassDeclaration c = getClassDefinition().getSuperClass();
- if (c != null) {
- MemberDefinition field = c.getClassDefinition(env).matchMethod(env, getClassDefinition(), idInit);
- asm.add(getWhere(), opc_aload, new Integer(0));
- asm.add(getWhere(), opc_invokespecial, field);
- asm.add(getWhere(), opc_pop);
- }
-
- // Output initialization code
- for (MemberDefinition f = getClassDefinition().getFirstMember() ; f != null ; f = f.getNextMember()) {
- if (!f.isStatic()) {
- f.codeInit(env, ctx, asm);
- }
- }
- }
- */
- if (s != null) {
- s.code(env, ctx, asm);
- }
- if (getType().getReturnType().isType(TC_VOID) && !isInitializer()) {
- asm.add(getWhere(), opc_return, true);
- }
- }
- return;
- }
- }
-
- public void codeInit(Environment env, Context ctx, Assembler asm) throws ClassNotFound {
- if (isMethod()) {
- return;
- }
- switch (status) {
- case PARSED:
- check(env);
- codeInit(env, ctx, asm);
- return;
-
- case CHECKED:
- inline(env);
- codeInit(env, ctx, asm);
- return;
-
- case INLINED:
- // Actually generate code
- if (env.dump()) {
- System.out.println("[code initializer " + getClassDeclaration().getName() + "." + getName() + "]");
- }
- if (getValue() != null) {
- Expression e = (Expression)getValue();
- // The JLS Section 8.5 specifies that static (non-final)
- // initializers should be executed in textual order. Eliding
- // initializations to default values can interfere with this,
- // so the tests for !e.equalsDefault() have been eliminated,
- // below.
- if (isStatic()) {
- if (getInitialValue() == null) {
- // removed: && !e.equalsDefault()) {
- e.codeValue(env, ctx, asm);
- asm.add(getWhere(), opc_putstatic, this);
- }
- } else { // removed: if (!e.equalsDefault()) {
- // This code doesn't appear to be reached for
- // instance initializers. Code for these is generated
- // in the makeVarInits() method of the class
- // MethodExpression.
- asm.add(getWhere(), opc_aload, 0);
- e.codeValue(env, ctx, asm);
- asm.add(getWhere(), opc_putfield, this);
- }
- }
- return;
- }
- }
-
- /**
- * Print for debugging
- */
- public void print(PrintStream out) {
- super.print(out);
- if (getValue() != null) {
- getValue().print(out);
- out.println();
- }
- }
-}
diff --git a/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties b/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties
deleted file mode 100644
index 910361de49a..00000000000
--- a/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties
+++ /dev/null
@@ -1,638 +0,0 @@
-#
-# Copyright (c) 1996, 2019, 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.
-#
-
-javac.err.internal=\
- Internal error.
-javac.err.eof.in.comment=\
- Comment not terminated at end of input.
-javac.err.eof.in.string=\
- String not terminated at end of input.
-javac.err.newline.in.string=\
- String not terminated at end of line.
-javac.err.invalid.char.constant=\
- Invalid character constant.
-javac.err.unbalanced.paren=\
- Unbalanced parentheses.
-javac.err.invalid.escape.char=\
- Invalid escape character.
-javac.err.invalid.hex.number=\
- Hexadecimal numbers must contain at least one hexadecimal digit.
-javac.err.invalid.octal.number=\
- Invalid character in octal number.
-javac.err.invalid.number=\
- Invalid character in number.
-javac.err.funny.char=\
- Invalid character in input.
-javac.err.float.format=\
- Invalid floating point format.
-javac.err.overflow.int.oct=\
- Integer literal out of range. Octal int literals must be in \
- the range 00 to 037777777777.
-javac.err.overflow.int.dec=\
- Integer literal out of range. Decimal int literals must be in \
- the range -2147483648 to 2147483647.
-javac.err.overflow.int.hex=\
- Integer literal out of range. Hexadecimal int literals must be in \
- the range 0x0 to 0xffffffff.
-javac.err.overflow.long.oct=\
- Integer literal out of range. Octal long literals must be in \
- the range 00L to 01777777777777777777777L.
-javac.err.overflow.long.dec=\
- Integer literal out of range. Decimal long literals must be in \
- the range -9223372036854775808L to 9223372036854775807L.
-javac.err.overflow.long.hex=\
- Integer literal out of range. Hexadecimal long literals must be in \
- the range 0x0L to 0xffffffffffffffffL.
-javac.err.overflow.float=\
- Numeric overflow: float literal too large.
-javac.err.overflow.double=\
- Numeric overflow: double literal too large.
-javac.err.underflow.float=\
- Numeric underflow: float literal too small.
-javac.err.underflow.double=\
- Numeric underflow: double literal too small.
-javac.err.token.expected=\
- ''{0}'' expected.
-javac.err.statement.expected=\
- Statement expected.
-javac.err.type.expected=\
- Type expected.
-javac.err.identifier.expected=\
- Identifier expected.
-javac.err.class.expected=\
- ''class'' or ''interface'' keyword expected.
-javac.err.toplevel.expected=\
- Class or interface declaration expected.
-javac.err.missing.term=\
- Missing term.
-javac.err.assign.in.conditionalexpr=\
- Assignment expressions are not permitted as the third subexpression \
- of a conditional expression (that is, a ? : expression). \
- Try parenthesizing this assignment expression.
-javac.err.else.without.if=\
- ''else'' without ''if''.
-javac.err.catch.without.try=\
- ''catch'' without ''try''.
-javac.err.finally.without.try=\
- ''finally'' without ''try''.
-javac.err.try.without.catch.finally=\
- ''try'' without ''catch'' or ''finally''.
-javac.err.case.without.switch=\
- ''case'' outside switch statement.
-javac.err.default.without.switch=\
- ''default'' outside switch statement.
-javac.err.io.exception=\
- I/O error in {0}.
-javac.err.io.exception.package=\
- I/O error while checking for existence of package {0}.
-javac.err.malformed.attribute=\
- The class file containing {0} has a malformed ''{1}'' attribute.
-javac.err.array.index.required=\
- Array index required.
-javac.err.not.array=\
- [] can only be applied to arrays. It can''t be applied to {0}.
-javac.err.array.dim.in.decl=\
- Can''t specify array dimension in a declaration.
-javac.err.array.dim.in.type=\
- Can''t specify array dimension in a type expression.
-javac.err.invalid.array.expr=\
- Array constants can only be used in initializers.
-javac.err.invalid.array.init=\
- Invalid initializer for type {0}.
-javac.err.invalid.lhs.assignment=\
- Invalid left hand side of assignment.
-javac.err.invalid.args=\
- Invalid arguments to {0}.
-javac.err.invalid.cast=\
- Invalid cast from {0} to {1}.
-javac.err.invalid.instanceof=\
- Impossible for {0} to be instance of {1}.
-javac.err.invalid.type.expr=\
- Invalid type expression.
-javac.err.anonymous.extends=\
- Only named classes can have ''extends'' or ''implements'' clauses.
-javac.err.invalid.field.reference=\
- Attempt to reference field {0} in a {1}.
-javac.err.no.such.field=\
- No variable {0} defined in {1}.
-javac.err.no.field.access=\
- Variable {0} in {1} not accessible from {2}.
-javac.err.no.type.access=\
- Inner type {0} in {1} not accessible from {2}.
-javac.err.cant.access.member.type=\
- The type {1} to which the member {0} belongs is not accessible from {2}.
-javac.err.inner.class.expected=\
- No inner class {0} found in {1}.
-javac.err.no.static.field.access=\
- Can''t make a static reference to nonstatic variable {0} in {1}.
-javac.err.inner.static.ref=\
- Can''t make a static reference to inner class {0}.
-javac.err.ambig.field=\
- Reference to {0} is ambiguous. It is defined in {1} and {2}.
-javac.err.invalid.field=\
- Attempt to reference method {0} in {1} as an instance variable.
-javac.err.assign.to.final=\
- Can''t assign a value to a final variable: {0}
-javac.err.assign.to.blank.final=\
- Can''t assign a second value to a blank final variable: {0}
-javac.err.qualified.static.final.assign=\
- The variable in an assignment to a static blank final must be a simple name (it may not follow a dot ''.'').
-javac.err.bad.qualified.final.assign=\
- The variable in an assignment to a blank final must be a simple name or a simple name qualified by ''this'': ''{0}'' or ''this.{0}''.
-javac.err.assign.to.blank.final.in.loop=\
- Attempt to assign a blank final variable {0} in a loop. The initialization must occur exactly once.
-javac.err.assign.to.uplevel=\
- Attempt to assign to a variable {0} in a different method. From enclosing blocks, only final local variables are available.
-javac.err.invalid.uplevel=\
- Attempt to use a non-final variable {0} from a different method. From enclosing blocks, only final local variables are available.
-javac.err.undef.var=\
- Undefined variable: {0}
-javac.err.undef.var.super=\
- Undefined variable: {0}. The "super" keyword may only be used for member access and constructor invocation.
-javac.err.undef.var.or.package=\
- Undefined variable or package name: {0}
-javac.err.undef.class.or.package=\
- Undefined class or package name: {0}
-javac.err.undef.var.class.or.package=\
- Undefined variable, class, or package name: {0}
-javac.err.undef.class=\
- Undefined class name: {0}
-javac.err.undef.var.or.class=\
- Undefined variable or class name: {0}
-javac.err.var.not.initialized=\
- Variable {0} may not have been initialized.
-javac.err.final.var.not.initialized=\
- Blank final variable ''{0}'' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
-javac.err.access.inst.before.super=\
- Can''t reference {0} before the superclass constructor has been called.
-javac.err.ambig.class=\
- Ambiguous class: {0} and {1}
-javac.err.invalid.arg=\
- Invalid argument to {0}.
-javac.err.invalid.arg.type=\
- Invalid argument type {0} for {1}.
-javac.err.invalid.length=\
- ''length'' applied to {0}, which is not an array.
-javac.err.invalid.constr.invoke=\
- Only constructors can invoke constructors.
-javac.err.constr.invoke.not.first=\
- Constructor invocation must be the first thing in a method.
-javac.err.invalid.method.invoke=\
- Can''t invoke a method on a {0}.
-javac.err.undef.meth=\
- Method {0} not found in {1}.
-javac.err.no.meth.access=\
- Method {0} in {1} is not accessible from {2}.
-#warning:
-javac.err.no.override.access=\
- Note: Method {0} in {1} does not override the corresponding method in {2}. If you are trying to override this method, you cannot do so because it is private to a different package.
-javac.err.no.static.meth.access=\
- Can''t make static reference to method {0} in {1}.
-javac.err.invalid.protected.method.use=\
- Can''t access protected method {0} in {1}. {2} is not a subclass of the current class.
-javac.err.invalid.protected.field.use=\
- Can''t access protected field {0} in {1}. {2} is not a subclass of the current class.
-javac.err.invalid.protected.type.use=\
- Can''t access protected inner type {0} in {1}. {2} is not a subclass of the current class.
-javac.err.invalid.protected.constructor.use=\
- Can''t access protected constructor of {0}. Instance creation is permitted only within the package in which the constructor is defined.
-javac.err.invalid.method=\
- Reference to variable {0} in {1} as if it were a method.
-javac.err.invalid.var=\
- Reference to method {0} in {1} as if it were a variable.
-javac.err.synchronized.null=\
- The null literal is not a legal argument for the synchronized statement.
-#all messages related to deprecation are warnings:
-javac.err.class.is.deprecated=\
- Note: {0} has been deprecated.
-javac.err.meth.is.deprecated=\
- Note: The method {0} in {1} has been deprecated.
-javac.err.constr.is.deprecated=\
- Note: The constructor {0} has been deprecated.
-javac.err.field.is.deprecated=\
- Note: The variable {0} in {1} has been deprecated.
-javac.err.note.deprecations=\
- Note: {0} files use or override a deprecated API. Please consult the documentation for a better alternative in each case.
-javac.err.note.1deprecation=\
- Note: {0} uses or overrides a deprecated API. Please consult the documentation for a better alternative.
-javac.err.note.deprecations.silent=\
- Note: {0} files use or override a deprecated API. Recompile with "-deprecation" for details.
-javac.err.note.1deprecation.silent=\
- Note: {0} uses or overrides a deprecated API. Recompile with "-deprecation" for details.
-javac.err.invalid.array.dim=\
- Invalid array dimension.
-javac.err.ambig.constr=\
- Constructor is ambiguous: {0}, {1}
-javac.err.explicit.cast.needed=\
- Incompatible type for {0}. Explicit cast needed to convert {1} to {2}.
-javac.err.incompatible.type=\
- Incompatible type for {0}. Can''t convert {1} to {2}.
-javac.err.invalid.term=\
- Invalid term.
-javac.err.abstract.class=\
- {0} must be declared abstract. It does not define {1} from {2}.
-javac.err.abstract.class.cannot.override=\
- {0} must be declared abstract. The package-private abstract method {1} in superclass {2} is inaccessible and cannot be overridden.
-javac.err.new.intf=\
- {0} is an interface. It can''t be instantiated.
-javac.err.invoke.abstract=\
- Can''t directly invoke abstract method {0} in {1}.
-javac.err.unmatched.meth=\
- No method matching {0} found in {1}.
-javac.err.unmatched.constr=\
- No constructor matching {0} found in {1}.
-javac.err.wrong.number.args=\
- Wrong number of arguments in {0}.
-javac.err.forward.ref=\
- Can''t make forward reference to {0} in {1}.
-javac.err.array.dim.missing=\
- Array dimension missing.
-javac.err.new.abstract=\
- {0} is an abstract class. It can''t be instantiated.
-javac.err.label.not.found=\
- No label definition found for {0}.
-javac.err.invalid.break=\
- ''break'' must be in loop or switch.
-javac.err.invalid.continue=\
- ''continue'' must be in loop.
-javac.err.branch.to.uplevel=\
- a ''break'' or ''continue'' must transfer control within the same method.
-javac.err.invalid.decl=\
- Invalid declaration.
-javac.err.return.with.value=\
- ''return'' with value from {0}.
-javac.err.return.without.value=\
- ''return'' without value from {0}.
-javac.err.return.inside.static.initializer=\
- ''return'' inside static initializer.
-javac.err.invalid.label=\
- Invalid label.
-javac.err.return.required.at.end=\
- Return required at end of {0}.
-javac.err.duplicate.label=\
- Duplicate case label: {0}
-javac.err.switch.overflow=\
- Case label {0} too large for ''switch'' on {1}
-javac.err.nested.duplicate.label=\
- A statement cannot be labeled with the same identifier as one of its enclosing statements: {0}
-javac.err.declaration.with.label=\
- A declaration cannot be labeled: {0}
-javac.err.const.expr.required=\
- Constant expression required.
-javac.err.duplicate.default=\
- Duplicate ''default'' label.
-javac.err.not.supported=\
- ''{0}'' not supported.
-javac.err.return.with.value.constr=\
- ''return'' with value from constructor: {0}
-javac.err.package.repeated=\
- Only one package declaration allowed.
-javac.err.class.multidef=\
- Class {0} already defined in {1}.
-javac.err.class.multidef.import=\
- Class name {0} clashes with imported class {1}.
-javac.err.intf.constructor=\
- Interfaces can''t have constructors.
-javac.err.constr.modifier=\
- Constructors can''t be native, abstract, static, synchronized, or final: {0}
-javac.err.intf.initializer=\
- Interfaces can''t have static initializers.
-javac.err.intf.modifier.method=\
- Interface methods can''t be native, static, synchronized, final, private, or protected : {0}
-javac.err.intf.modifier.field=\
- Interface fields can''t be private or protected: {0}
-javac.err.transient.meth=\
- Method {0} can''t be transient. Only variables can be transient.
-javac.err.volatile.meth=\
- Method {0} can''t be volatile. Only variables can be volatile.
-javac.err.abstract.private.modifier=\
- Abstract methods can''t be private: {0}
-javac.err.abstract.static.modifier=\
- Abstract methods can''t be static: {0}
-javac.err.abstract.final.modifier=\
- Abstract methods can''t be final: {0}
-javac.err.abstract.native.modifier=\
- Abstract methods can''t be native: {0}
-javac.err.abstract.synchronized.modifier=\
- Abstract methods can''t be synchronized: {0}
-javac.err.invalid.meth.body=\
- Abstract and native methods can''t have a body: {0}
-javac.err.var.modifier=\
- Variables can''t be synchronized, abstract or native: {0}
-javac.err.var.floatmodifier=\
- Variables can''t be declared strict: {0}
-javac.err.inner.modifier=\
- Inner classes can''t be volatile, transient, native, or synchronized: {0}
-javac.err.transient.modifier=\
- Transient variables can''t be members of interfaces: {0}
-javac.err.volatile.modifier=\
- Volatile variables can''t be final or members of interfaces: {0}
-javac.err.initializer.needed=\
- This final variable must be initialized: {0}
-javac.err.meth.multidef=\
- Duplicate method declaration: {0}
-javac.err.meth.redef.rettype=\
- Methods can''t be redefined with a different return type: {0} was {1}
-javac.err.var.multidef=\
- Duplicate variable declaration: {0} was {1}
-javac.err.inner.class.multidef=\
- Duplicate inner class declaration: {0} is already defined in this scope.
-javac.err.intf.super.class=\
- Superclass of {0} can''t be an interface: {1}
-javac.err.cant.access.class=\
- Can''t access {0}. Class or interface must be public, in same package, or an accessible member class.
-javac.err.unqualified.name.required=\
- The type name in a qualified 'new' expression must be an unqualified identifier.
-javac.err.repeated.modifier=\
- Repeated modifier.
-javac.err.inconsistent.modifier=\
- Inconsistent member declaration. At most one of public, private, or protected may be specified.
-javac.err.super.is.final=\
- Can''t subclass final classes: {0}
-javac.err.super.is.intf=\
- Can''t subclass interfaces: {0}
-javac.err.cyclic.super=\
- Cyclic class inheritance.
-javac.err.super.is.inner=\
- Cyclic class inheritance: A subclass cannot enclose a superclass.
-javac.err.cyclic.intf=\
- Cyclic interface inheritance.
-javac.err.cyclic.scoping=\
- Cyclic class inheritance or scoping.
-javac.err.not.intf=\
- {0} must be an interface.
-javac.err.final.intf=\
- Interfaces can''t be final: {0}
-javac.err.intf.impl.intf=\
- An interface can''t implement anything; it can only extend other interfaces.
-javac.err.multiple.inherit=\
- Multiple inheritance is not supported.
-javac.err.intf.repeated=\
- Interface {0} repeated.
-javac.err.class.format=\
- Invalid class file format in {0}. {1}
-javac.err.truncated.class=\
- Unexpected end of file encountered while reading the class file {0}.
-javac.err.no.meth.body=\
- Method {0} requires a method body. Otherwise declare it as abstract.
-javac.err.no.constructor.body=\
- Constructor {0} requires a method body.
-javac.err.bad.constructor.modifier=\
- Constructors may not be modified by strictfp.
-javac.err.void.inst.var=\
- Instance variables can''t be void: {0}
-javac.err.invalid.method.decl=\
- Invalid method declaration; return type required.
-javac.err.invalid.method.decl.name=\
- Invalid method declaration; method name required.
-javac.err.invalid.method.decl.qual=\
- Invalid qualified constructor name.
-javac.err.super.not.found=\
- Superclass {0} of {1} not found.
-javac.err.intf.not.found=\
- Interface {0} of {1} not found.
-javac.err.final.abstract=\
- Class {0} can''t be declared both abstract and final.
-javac.err.void.array=\
- Array of void is not a valid type.
-javac.err.void.argument=\
- Argument can''t have type void: {0}
-javac.err.invalid.expr=\
- Invalid expression statement.
-javac.err.catch.not.reached=\
- catch not reached.
-javac.err.stat.not.reached=\
- Statement not reached.
-javac.err.init.no.normal.completion=\
- Initializer must be able to complete normally.
-javac.err.arithmetic.exception=\
- Arithmetic exception.
-javac.err.generic=\
- {0}
-javac.err.public.class.file=\
- Public {0} must be defined in a file called "{1}".
-javac.err.package.class.file=\
- {0} is defined in {1}. Because it is used outside of its source file, it should be defined in a file called "{2}".
-javac.err.lose.precision=\
- Possible loss of precision. Use an explicit cast to convert {0} to {1}.
-javac.err.duplicate.argument=\
- Variable ''{0}'' is used twice in the argument list of this method.
-javac.err.local.redefined=\
- Variable ''{0}'' is already defined in this method.
-javac.err.local.class.redefined=\
- Local class ''{0}'' is already defined in this method.
-javac.err.inner.redefined=\
- The class name ''{0}'' is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes.
-javac.err.inherited.hides.field=\
- Variable ''{0}'' is inherited in {1}, and hides a variable of the same name in {2}. An explicit ''this'' qualifier must be used to select the desired instance.
-javac.err.inherited.hides.local=\
- Variable ''{0}'' is inherited in {1}, and hides a local variable of the same name. An explicit ''this'' qualifier must be used to select the variable, or the local must be renamed.
-javac.err.inherited.hides.method=\
- Method ''{0}'' is inherited in {1}, and hides a method of the same name in {2}. An explicit ''this'' qualifier must be used to select the desired instance.
-javac.err.inherited.hides.type=\
- Type ''{0}'' is inherited in {1}, and hides a type of the same name in an enclosing scope. An explicit qualifier prefix must be used to name this type.
-javac.err.private.class=\
- The type {0} can''t be private. Package members are always accessible within the current package.
-javac.err.static.class=\
- The type {0} can''t be declared static. It is already top-level, since it is a member of a package.
-javac.err.protected.class=\
- The type {0} can''t be made protected. Package members can either be public or local to the current package.
-javac.err.recursive.constr=\
- Recursive constructor invocation: {0}.
-javac.err.wrong.class=\
- File {0} does not contain {1} as expected, but {2}. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
-javac.err.wrong.source=\
- File {0} does not contain {1} as expected. Please adjust the class path so that the file does not appear in the {2}.
-javac.err.class.not.found=\
- Class {0} not found in {1}.
-javac.err.class.not.found.no.context=\
- Class {0} not found.
-javac.err.package.not.found=\
- Package {0} not found in {1}.
-javac.err.package.not.found.strong=\
- Package {0} not found. Please adjust the classpath so that package {0} is accessible.
-javac.err.class.package.conflict=\
- A type and a package cannot have the same name. The name {0} cannot be used to name a class while the package {0} is accessible.
-javac.err.package.class.conflict=\
- A type and a package cannot have the same name. The name {0} cannot be used to name a package while the class {1} is accessible.
-javac.err.package.class.conflict.strong=\
- The name {0} must refer to a package. It is illegal for there to be an accessible class named {1} because types and packages cannot have the same name. The class {1} should be renamed or taken off the classpath.
-javac.err.illegal.mangled.name=\
- Invalid name {0} for {1}.
-javac.err.class.and.package=\
- Ambiguous name: {0} is both a class and a package.
-javac.err.throws.not.throwable=\
- {0} in throws clause must be a subclass of class java.lang.Throwable.
-javac.err.throw.not.throwable=\
- Can''t throw {0}; it must be a subclass of class java.lang.Throwable.
-javac.err.catch.not.throwable=\
- Can''t catch {0}; it must be a subclass of class java.lang.Throwable.
-javac.err.initializer.exception=\
- Exception {0} can''t be thrown in initializer.
-javac.err.cant.read=\
- Can''t read: {0}
-javac.err.cant.write=\
- Can''t write: {0}
-javac.err.fatal.error=\
- An error has occurred in the compiler; please file a bug report (http://bugreport.java.com/bugreport/).
-javac.err.fatal.exception=\
- An exception has occurred in the compiler; please file a bug report (http://bugreport.java.com/bugreport/).
-javac.err.no.inner.classes=\
- Support for inner classes has been disabled.
-javac.err.uncaught.exception=\
- Exception {0} must be caught, or it must be declared in the throws clause of this method.
-javac.err.constructor.exception=\
- Exception {0} must be caught, or it must be declared in the throws clause of this constructor.
-javac.err.def.constructor.exception=\
- A default constructor cannot be created for this class because the constructor of its superclass throws the exception {0}. Define the constructor for this class explicitly.
-javac.err.catch.not.thrown=\
- Exception {0} is never thrown in the body of the corresponding try statement.
-#warning:
-javac.err.array.clone.supported=\
- Note: The cloning of an array does not throw any checked exceptions, and therefore does not require any catch clauses. Please remove unused catch clauses, or if you wish to retain compatibility with older compilers, you may insert an artificial throw as follows: if (false) throw new CloneNotSupportedException();
-javac.err.no.outer.arg=\
- No enclosing instance of {0} is in scope; \
- an explicit one must be provided when creating {1}, \
- as in "outer. new Inner()" or "outer. super()".
-javac.err.no.default.outer.arg=\
- No enclosing instance of {0} is in scope; \
- cannot create a default constructor for {1}.
-javac.err.no.outer.base=\
- No enclosing instance of {0} is in scope; \
- an explicit one must be provided when accessing {1}, \
- as in "outer.member".
-javac.err.inner.interface=\
- Member interfaces can only occur in interfaces and top-level classes.
-javac.err.static.inner.class=\
- The type {0} can''t be static. Static members can only occur in interfaces and top-level classes.
-javac.err.static.inner.field=\
- Variable {0} can''t be static in {1}. Only members of interfaces and top-level classes can be static.
-javac.err.static.inner.method=\
- Method {0} can''t be static in {1}. Only members of interfaces and top-level classes can be static.
-javac.err.too.many.errors=\
- Too many errors. (The limit on reported errors is {0}.)
-javac.err.override.static.with.instance=\
- The instance method {0} declared in {1} cannot override the static \
- method of the same signature declared in {2}. It is illegal to \
- override a static method.
-javac.err.hide.instance.with.static=\
- The static method {0} declared in {1} cannot hide the instance \
- method of the same signature declared in {2}. It is illegal to \
- hide an instance method.
-javac.err.override.final.method=\
- The method {0} declared in {1} cannot override the final method of \
- the same signature declared in {2}. Final methods cannot be \
- overridden.
-javac.err.override.is.deprecated=\
- The method {0} declared in {1} is not deprecated, but \
- overrides a deprecated method of the \
- same signature declared in {2}.
-javac.err.override.more.restrictive=\
- The method {0} declared in {1} cannot override the method of the \
- same signature declared in {2}. The access modifier is made more \
- restrictive.
-javac.err.override.different.return=\
- The method {0} declared in {1} cannot override the method of the \
- same signature declared in {2}. They must have the same return \
- type.
-javac.err.override.incompatible.exceptions=\
- The method {0} declared in {1} cannot override the method of the \
- same signature declared in {2}. Their throws clauses are \
- incompatible.
-javac.err.meet.different.return=\
- The method {0} inherited from {1} is incompatible with the method of \
- the same signature inherited from {2}. They must have the same \
- return type.
-javac.err.nontrivial.meet=\
- The definitions of method {0} inherited from {1} and {2} are \
- compatible, but the combination of them is nontrivial and has not \
- been implemented. As a workaround, declare {0} explicitly in this \
- class.
-javac.err.method.too.long=\
- This code requires generating a method with more than \
- 64K bytes. Virtual machines may refuse the resulting class file.
-#
-javac.err.version.too.old=\
- The major version ''{0}'' is too old for this tool to understand.
-javac.err.version.too.recent=\
- The major.minor version ''{0}'' is too recent for this tool \
- to understand.
-javac.err.version.preview=\
- The major.minor version ''{0}'' indicates the class was compiled with \
- preview features enabled, which this tool does not support.
-#
-benv.parsed_in=[parsed {0} in {1} ms]
-benv.loaded_in=[loaded {0} in {1} ms]
-benv.failed_to_close_class_path=failed to close class path: {0}
-#
-main.usage=\
-Usage: {0} \n\
-\n\
-where includes:\n\
-\ \ -g Generate all debugging info\n\
-\ \ -g:none Generate no debugging info\n\
-\ \ -g:'{'lines,vars,source'}' Generate only some debugging info\n\
-\ \ -O Optimize; may hinder debugging or enlarge class files\n\
-\ \ -nowarn Generate no warnings\n\
-\ \ -verbose Output messages about what the compiler is doing\n\
-\ \ -deprecation Output source locations where deprecated APIs are used\n\
-\ \ -classpath Specify where to find user class files\n\
-\ \ -sourcepath Specify where to find input source files\n\
-\ \ -bootclasspath Override location of bootstrap class files\n\
-\ \ -extdirs Override location of installed extensions\n\
-\ \ -d Specify where to place generated class files\n\
-\ \ -encoding Specify character encoding used by source files\n\
-\ \ -target Generate class files for specific VM version
-#
-main.unsupported.usage=\
-\ \ -Xdepend Recursively search for more recent source files to recompile\n\
-\ \ -Xstdout Send messages to System.out\n\
-\ \ -Xverbosepath Describe how paths and standard extensions were searched\n\
-\ \ -J