Merge
This commit is contained in:
commit
a850cbc5d5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -368,6 +368,10 @@ public final class Channels {
|
||||
|
||||
@Override
|
||||
public int read(ByteBuffer dst) throws IOException {
|
||||
if (!isOpen()) {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
int len = dst.remaining();
|
||||
int totalRead = 0;
|
||||
int bytesRead = 0;
|
||||
@ -442,6 +446,10 @@ public final class Channels {
|
||||
|
||||
@Override
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
if (!isOpen()) {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
int len = src.remaining();
|
||||
int totalWritten = 0;
|
||||
synchronized (writeLock) {
|
||||
|
@ -2401,7 +2401,7 @@ public final class Files {
|
||||
*
|
||||
* <p> Note that the result of this method is immediately outdated. If this
|
||||
* method indicates the file exists then there is no guarantee that a
|
||||
* subsequence access will succeed. Care should be taken when using this
|
||||
* subsequent access will succeed. Care should be taken when using this
|
||||
* method in security sensitive applications.
|
||||
*
|
||||
* @param path
|
||||
@ -2458,7 +2458,7 @@ public final class Files {
|
||||
* or not then both methods return {@code false}. As with the {@code exists}
|
||||
* method, the result of this method is immediately outdated. If this
|
||||
* method indicates the file does exist then there is no guarantee that a
|
||||
* subsequence attempt to create the file will succeed. Care should be taken
|
||||
* subsequent attempt to create the file will succeed. Care should be taken
|
||||
* when using this method in security sensitive applications.
|
||||
*
|
||||
* @param path
|
||||
|
@ -139,21 +139,6 @@ public class Main implements sun.rmi.rmic.Constants {
|
||||
*/
|
||||
public synchronized boolean compile(String argv[]) {
|
||||
|
||||
/*
|
||||
* Handle internal option to use the new (and incomplete) rmic
|
||||
* implementation. This option is handled here, rather than
|
||||
* in parseArgs, so that none of the arguments will be nulled
|
||||
* before delegating to the new implementation.
|
||||
*/
|
||||
// disable the -Xnew option as per JDK-8146299 and JDK-8145980
|
||||
// to allow further discussion how to progress with this feature
|
||||
//for (int i = 0; i < argv.length; i++) {
|
||||
// if (argv[i].equals("-Xnew")) {
|
||||
// return (new sun.rmi.rmic.newrmic.Main(out,
|
||||
// program)).compile(argv);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (!parseArgs(argv)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import com.sun.javadoc.RootDoc;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static sun.rmi.rmic.newrmic.Constants.*;
|
||||
|
||||
/**
|
||||
* The environment for an rmic compilation batch.
|
||||
*
|
||||
* A BatchEnvironment contains a RootDoc, which is the entry point
|
||||
* into the doclet environment for the associated rmic compilation
|
||||
* batch. A BatchEnvironment collects the source files generated
|
||||
* during the batch's execution, for eventual source code compilation
|
||||
* and, possibly, deletion. Errors that occur during generation
|
||||
* activity should be reported through the BatchEnvironment's "error"
|
||||
* method.
|
||||
*
|
||||
* A protocol-specific generator class may require the use of a
|
||||
* particular BatchEnvironment subclass for enhanced environment
|
||||
* functionality. A BatchEnvironment subclass must declare a
|
||||
* public constructor with one parameter of type RootDoc.
|
||||
*
|
||||
* 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 BatchEnvironment {
|
||||
|
||||
private final RootDoc rootDoc;
|
||||
|
||||
/** cached ClassDoc for certain types used by rmic */
|
||||
private final ClassDoc docRemote;
|
||||
private final ClassDoc docException;
|
||||
private final ClassDoc docRemoteException;
|
||||
private final ClassDoc docRuntimeException;
|
||||
|
||||
private boolean verbose = false;
|
||||
private final List<File> generatedFiles = new ArrayList<File>();
|
||||
|
||||
/**
|
||||
* Creates a new BatchEnvironment with the specified RootDoc.
|
||||
**/
|
||||
public BatchEnvironment(RootDoc rootDoc) {
|
||||
this.rootDoc = rootDoc;
|
||||
|
||||
/*
|
||||
* Initialize cached ClassDoc for types used by rmic. Note
|
||||
* that any of these could be null if the boot class path is
|
||||
* incorrect, which could cause a NullPointerException later.
|
||||
*/
|
||||
docRemote = rootDoc().classNamed(REMOTE);
|
||||
docException = rootDoc().classNamed(EXCEPTION);
|
||||
docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
|
||||
docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RootDoc for this environment.
|
||||
**/
|
||||
public RootDoc rootDoc() {
|
||||
return rootDoc;
|
||||
}
|
||||
|
||||
public ClassDoc docRemote() { return docRemote; }
|
||||
public ClassDoc docException() { return docException; }
|
||||
public ClassDoc docRemoteException() { return docRemoteException; }
|
||||
public ClassDoc docRuntimeException() { return docRuntimeException; }
|
||||
|
||||
/**
|
||||
* Sets this environment's verbosity status.
|
||||
**/
|
||||
public void setVerbose(boolean verbose) {
|
||||
this.verbose = verbose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this environment's verbosity status.
|
||||
**/
|
||||
public boolean verbose() {
|
||||
return verbose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified file to the list of source files generated
|
||||
* during this batch.
|
||||
**/
|
||||
public void addGeneratedFile(File file) {
|
||||
generatedFiles.add(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of files generated during this batch.
|
||||
**/
|
||||
public List<File> generatedFiles() {
|
||||
return Collections.unmodifiableList(generatedFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the specified (non-error) message.
|
||||
**/
|
||||
public void output(String msg) {
|
||||
rootDoc.printNotice(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports an error using the specified resource key and text
|
||||
* formatting arguments.
|
||||
**/
|
||||
public void error(String key, String... args) {
|
||||
rootDoc.printError(Resources.getText(key, args));
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic;
|
||||
|
||||
/**
|
||||
* Constants potentially useful to all rmic generators.
|
||||
*
|
||||
* 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 final class Constants {
|
||||
|
||||
private Constants() { throw new AssertionError(); }
|
||||
|
||||
/*
|
||||
* fully-qualified names of types used by rmic
|
||||
*/
|
||||
public static final String REMOTE = "java.rmi.Remote";
|
||||
public static final String EXCEPTION = "java.lang.Exception";
|
||||
public static final String REMOTE_EXCEPTION = "java.rmi.RemoteException";
|
||||
public static final String RUNTIME_EXCEPTION = "java.lang.RuntimeException";
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The interface to rmic back end implementations. Classes that
|
||||
* implement this interface correspond to the various generation modes
|
||||
* of rmic (JRMP, IIOP, IDL, etc.).
|
||||
*
|
||||
* A Generator instance corresponds to a particular rmic compilation
|
||||
* batch, and its instance state represents the generator-specific
|
||||
* command line options for that batch. Main will instantiate a
|
||||
* generator class when the command line arguments indicate selection
|
||||
* of the corresponding generation mode. Main will then invoke the
|
||||
* "parseArgs" method to allow the generator to process any
|
||||
* generator-specific command line options and set its instance state
|
||||
* accordingly.
|
||||
*
|
||||
* 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 interface Generator {
|
||||
|
||||
/**
|
||||
* Processes the command line options specific to this generator.
|
||||
* Processed options are set to null in the specified array.
|
||||
* Returns true if successful or false if an error occurs. Errors
|
||||
* are output to the specific Main instance.
|
||||
**/
|
||||
public boolean parseArgs(String[] args, Main main);
|
||||
|
||||
/**
|
||||
* Returns the most specific environment class required by this
|
||||
* generator.
|
||||
**/
|
||||
public Class<? extends BatchEnvironment> envClass();
|
||||
|
||||
/**
|
||||
* Returns the names of the classes that must be available through
|
||||
* the doclet API in order for this generator to function.
|
||||
**/
|
||||
public Set<String> bootstrapClassNames();
|
||||
|
||||
/**
|
||||
* Generates the protocol-specific rmic output files for the
|
||||
* specified remote class. This method is invoked once for each
|
||||
* class or interface specified on the command line for the rmic
|
||||
* compilation batch associated with this instance.
|
||||
*
|
||||
* Any generated source files (to be compiled with javac) are
|
||||
* passed to the addGeneratedFile method of the specified
|
||||
* BatchEnvironment.
|
||||
**/
|
||||
public void generate(BatchEnvironment env,
|
||||
ClassDoc inputClass,
|
||||
File destDir);
|
||||
}
|
@ -1,291 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A BufferedWriter that supports automatic indentation of lines of
|
||||
* text written to the underlying Writer.
|
||||
*
|
||||
* Methods are provided for compact/convenient indenting in and out,
|
||||
* writing text, and writing lines of text 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.
|
||||
*
|
||||
* @author Peter Jones
|
||||
**/
|
||||
public class IndentingWriter extends BufferedWriter {
|
||||
|
||||
/** number of spaces to change indent when indenting in or out */
|
||||
private final int indentStep;
|
||||
|
||||
/** number of spaces to convert into tabs (use MAX_VALUE to disable) */
|
||||
private final int tabSize;
|
||||
|
||||
/** 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;
|
||||
|
||||
/**
|
||||
* Creates a new IndentingWriter that writes indented text to the
|
||||
* given Writer. Use the default indent step of four spaces.
|
||||
**/
|
||||
public IndentingWriter(Writer out) {
|
||||
this(out, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new IndentingWriter that writes indented text to the
|
||||
* given Writer and uses the supplied indent step.
|
||||
**/
|
||||
public IndentingWriter(Writer out, int indentStep) {
|
||||
this(out, indentStep, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates 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 indentStep, int tabSize) {
|
||||
super(out);
|
||||
if (indentStep < 0) {
|
||||
throw new IllegalArgumentException("negative indent step");
|
||||
}
|
||||
if (tabSize < 0) {
|
||||
throw new IllegalArgumentException("negative tab size");
|
||||
}
|
||||
this.indentStep = indentStep;
|
||||
this.tabSize = tabSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a single character.
|
||||
**/
|
||||
public void write(int c) throws IOException {
|
||||
checkWrite();
|
||||
super.write(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line separator. The next character written will be
|
||||
* preceded by an indent.
|
||||
**/
|
||||
public void newLine() throws IOException {
|
||||
super.newLine();
|
||||
beginningOfLine = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks 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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the current indent by the indent step.
|
||||
**/
|
||||
protected void indentIn() {
|
||||
currentIndent += indentStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases the current indent by the indent step.
|
||||
**/
|
||||
protected void indentOut() {
|
||||
currentIndent -= indentStep;
|
||||
if (currentIndent < 0)
|
||||
currentIndent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents in.
|
||||
**/
|
||||
public void pI() {
|
||||
indentIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out.
|
||||
**/
|
||||
public void pO() {
|
||||
indentOut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes string.
|
||||
**/
|
||||
public void p(String s) throws IOException {
|
||||
write(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends current line.
|
||||
**/
|
||||
public void pln() throws IOException {
|
||||
newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes string; ends current line.
|
||||
**/
|
||||
public void pln(String s) throws IOException {
|
||||
p(s);
|
||||
pln();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes string; ends current line; indents in.
|
||||
**/
|
||||
public void plnI(String s) throws IOException {
|
||||
p(s);
|
||||
pln();
|
||||
pI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes string.
|
||||
**/
|
||||
public void pO(String s) throws IOException {
|
||||
pO();
|
||||
p(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes string; ends current line.
|
||||
**/
|
||||
public void pOln(String s) throws IOException {
|
||||
pO(s);
|
||||
pln();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes string; ends current line; indents 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes object.
|
||||
**/
|
||||
public void p(Object o) throws IOException {
|
||||
write(o.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes object; ends current line.
|
||||
**/
|
||||
public void pln(Object o) throws IOException {
|
||||
p(o.toString());
|
||||
pln();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes object; ends current line; indents in.
|
||||
**/
|
||||
public void plnI(Object o) throws IOException {
|
||||
p(o.toString());
|
||||
pln();
|
||||
pI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes object.
|
||||
**/
|
||||
public void pO(Object o) throws IOException {
|
||||
pO();
|
||||
p(o.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes object; ends current line.
|
||||
**/
|
||||
public void pOln(Object o) throws IOException {
|
||||
pO(o.toString());
|
||||
pln();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents out; writes object; ends current line; indents 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();
|
||||
}
|
||||
}
|
@ -1,689 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.rmi.rmic.newrmic;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import com.sun.javadoc.RootDoc;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import sun.rmi.rmic.newrmic.jrmp.JrmpGenerator;
|
||||
import sun.tools.util.CommandLine;
|
||||
|
||||
/**
|
||||
* The rmic front end. This class contains the "main" method for rmic
|
||||
* command line invocation.
|
||||
*
|
||||
* A Main instance contains the stream to output error messages and
|
||||
* other diagnostics to.
|
||||
*
|
||||
* An rmic compilation batch (for example, one rmic command line
|
||||
* invocation) is executed by invoking the "compile" method of a Main
|
||||
* instance.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* NOTE: If and when there is a J2SE API for invoking SDK tools, this
|
||||
* class should be updated to support that API.
|
||||
*
|
||||
* NOTE: This class is the front end for a "new" rmic implementation,
|
||||
* which uses javadoc and the doclet API for reading class files and
|
||||
* javac for compiling generated source files. This implementation is
|
||||
* incomplete: it lacks any CORBA-based back end implementations, and
|
||||
* thus the command line options "-idl", "-iiop", and their related
|
||||
* options are not yet supported. The front end for the "old",
|
||||
* oldjavac-based rmic implementation is sun.rmi.rmic.Main.
|
||||
*
|
||||
* @author Peter Jones
|
||||
**/
|
||||
public class Main {
|
||||
|
||||
/*
|
||||
* Implementation note:
|
||||
*
|
||||
* In order to use the doclet API to read class files, much of
|
||||
* this implementation of rmic executes as a doclet within an
|
||||
* invocation of javadoc. This class is used as the doclet class
|
||||
* for such javadoc invocations, via its static "start" and
|
||||
* "optionLength" methods. There is one javadoc invocation per
|
||||
* rmic compilation batch.
|
||||
*
|
||||
* The only guaranteed way to pass data to a doclet through a
|
||||
* javadoc invocation is through doclet-specific options on the
|
||||
* javadoc "command line". Rather than passing numerous pieces of
|
||||
* individual data in string form as javadoc options, we use a
|
||||
* single doclet-specific option ("-batchID") to pass a numeric
|
||||
* identifier that uniquely identifies the rmic compilation batch
|
||||
* that the javadoc invocation is for, and that identifier can
|
||||
* then be used as a key in a global table to retrieve an object
|
||||
* containing all of batch-specific data (rmic command line
|
||||
* arguments, etc.).
|
||||
*/
|
||||
|
||||
/** guards "batchCount" */
|
||||
private static final Object batchCountLock = new Object();
|
||||
|
||||
/** number of batches run; used to generated batch IDs */
|
||||
private static long batchCount = 0;
|
||||
|
||||
/** maps batch ID to batch data */
|
||||
private static final Map<Long,Batch> batchTable =
|
||||
Collections.synchronizedMap(new HashMap<Long,Batch>());
|
||||
|
||||
/** stream to output error messages and other diagnostics to */
|
||||
private final PrintStream out;
|
||||
|
||||
/** name of this program, to use in error messages */
|
||||
private final String program;
|
||||
|
||||
/**
|
||||
* Command line entry point.
|
||||
**/
|
||||
public static void main(String[] args) {
|
||||
Main rmic = new Main(System.err, "rmic");
|
||||
System.exit(rmic.compile(args) ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Main instance that writes output to the specified
|
||||
* stream. The specified program name is used in error messages.
|
||||
**/
|
||||
public Main(OutputStream out, String program) {
|
||||
this.out = out instanceof PrintStream ?
|
||||
(PrintStream) out : new PrintStream(out);
|
||||
this.program = program;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles a batch of input classes, as given by the specified
|
||||
* command line arguments. Protocol-specific generators are
|
||||
* determined by the choice options on the command line. Returns
|
||||
* true if successful, or false if an error occurred.
|
||||
*
|
||||
* NOTE: This method is retained for transitional consistency with
|
||||
* previous implementations.
|
||||
**/
|
||||
public boolean compile(String[] args) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
long batchID;
|
||||
synchronized (batchCountLock) {
|
||||
batchID = batchCount++; // assign batch ID
|
||||
}
|
||||
|
||||
// process command line
|
||||
Batch batch = parseArgs(args);
|
||||
if (batch == null) {
|
||||
return false; // terminate if error occurred
|
||||
}
|
||||
|
||||
/*
|
||||
* With the batch data retrievable in the global table, run
|
||||
* javadoc to continue the rest of the batch's compliation as
|
||||
* a doclet.
|
||||
*/
|
||||
boolean status;
|
||||
try {
|
||||
batchTable.put(batchID, batch);
|
||||
status = invokeJavadoc(batch, batchID);
|
||||
} finally {
|
||||
batchTable.remove(batchID);
|
||||
}
|
||||
|
||||
if (batch.verbose) {
|
||||
long deltaTime = System.currentTimeMillis() - startTime;
|
||||
output(Resources.getText("rmic.done_in",
|
||||
Long.toString(deltaTime)));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the specified string to the output stream of this Main
|
||||
* instance.
|
||||
**/
|
||||
public void output(String msg) {
|
||||
out.println(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an error message to the output stream of this Main
|
||||
* instance. The first argument is used as a key in rmic's
|
||||
* resource bundle, and the rest of the arguments are used as
|
||||
* arguments in the formatting of the resource string.
|
||||
**/
|
||||
public void error(String msg, String... args) {
|
||||
output(Resources.getText(msg, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints rmic's usage message to the output stream of this Main
|
||||
* instance.
|
||||
*
|
||||
* This method is public so that it can be used by the "parseArgs"
|
||||
* methods of Generator implementations.
|
||||
**/
|
||||
public void usage() {
|
||||
error("rmic.usage", program);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes rmic command line arguments. Returns a Batch object
|
||||
* representing the command line arguments if successful, or null
|
||||
* if an error occurred. Processed elements of the args array are
|
||||
* set to null.
|
||||
**/
|
||||
private Batch parseArgs(String[] args) {
|
||||
Batch batch = new Batch();
|
||||
|
||||
/*
|
||||
* Pre-process command line for @file arguments.
|
||||
*/
|
||||
try {
|
||||
args = CommandLine.parse(args);
|
||||
} catch (FileNotFoundException e) {
|
||||
error("rmic.cant.read", e.getMessage());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(out);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
|
||||
if (args[i] == null) {
|
||||
// already processed by a generator
|
||||
continue;
|
||||
|
||||
} else if (args[i].equals("-Xnew")) {
|
||||
// we're already using the "new" implementation
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-show")) {
|
||||
// obselete: fail
|
||||
error("rmic.option.unsupported", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
|
||||
} else if (args[i].equals("-O")) {
|
||||
// obselete: warn but tolerate
|
||||
error("rmic.option.unsupported", args[i]);
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-debug")) {
|
||||
// obselete: warn but tolerate
|
||||
error("rmic.option.unsupported", args[i]);
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-depend")) {
|
||||
// obselete: warn but tolerate
|
||||
// REMIND: should this fail instead?
|
||||
error("rmic.option.unsupported", args[i]);
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-keep") ||
|
||||
args[i].equals("-keepgenerated"))
|
||||
{
|
||||
batch.keepGenerated = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-g")) {
|
||||
batch.debug = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-nowarn")) {
|
||||
batch.noWarn = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-nowrite")) {
|
||||
batch.noWrite = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-verbose")) {
|
||||
batch.verbose = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-Xnocompile")) {
|
||||
batch.noCompile = true;
|
||||
batch.keepGenerated = true;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-bootclasspath")) {
|
||||
if ((i + 1) >= args.length) {
|
||||
error("rmic.option.requires.argument", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
if (batch.bootClassPath != null) {
|
||||
error("rmic.option.already.seen", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
args[i] = null;
|
||||
batch.bootClassPath = args[++i];
|
||||
assert batch.bootClassPath != null;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-extdirs")) {
|
||||
if ((i + 1) >= args.length) {
|
||||
error("rmic.option.requires.argument", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
if (batch.extDirs != null) {
|
||||
error("rmic.option.already.seen", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
args[i] = null;
|
||||
batch.extDirs = args[++i];
|
||||
assert batch.extDirs != null;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-classpath")) {
|
||||
if ((i + 1) >= args.length) {
|
||||
error("rmic.option.requires.argument", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
if (batch.classPath != null) {
|
||||
error("rmic.option.already.seen", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
args[i] = null;
|
||||
batch.classPath = args[++i];
|
||||
assert batch.classPath != null;
|
||||
args[i] = null;
|
||||
|
||||
} else if (args[i].equals("-d")) {
|
||||
if ((i + 1) >= args.length) {
|
||||
error("rmic.option.requires.argument", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
if (batch.destDir != null) {
|
||||
error("rmic.option.already.seen", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
args[i] = null;
|
||||
batch.destDir = new File(args[++i]);
|
||||
assert batch.destDir != null;
|
||||
args[i] = null;
|
||||
if (!batch.destDir.exists()) {
|
||||
error("rmic.no.such.directory", batch.destDir.getPath());
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
|
||||
} else if (args[i].equals("-v1.1") ||
|
||||
args[i].equals("-vcompat") ||
|
||||
args[i].equals("-v1.2"))
|
||||
{
|
||||
Generator gen = new JrmpGenerator();
|
||||
batch.generators.add(gen);
|
||||
// JrmpGenerator only requires base BatchEnvironment class
|
||||
if (!gen.parseArgs(args, this)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
} else if (args[i].equalsIgnoreCase("-iiop")) {
|
||||
error("rmic.option.unimplemented", args[i]);
|
||||
return null;
|
||||
|
||||
// Generator gen = new IiopGenerator();
|
||||
// batch.generators.add(gen);
|
||||
// if (!batch.envClass.isAssignableFrom(gen.envClass())) {
|
||||
// error("rmic.cannot.use.both",
|
||||
// batch.envClass.getName(), gen.envClass().getName());
|
||||
// return null;
|
||||
// }
|
||||
// batch.envClass = gen.envClass();
|
||||
// if (!gen.parseArgs(args, this)) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
} else if (args[i].equalsIgnoreCase("-idl")) {
|
||||
error("rmic.option.unimplemented", args[i]);
|
||||
return null;
|
||||
|
||||
// see implementation sketch above
|
||||
|
||||
} else if (args[i].equalsIgnoreCase("-xprint")) {
|
||||
error("rmic.option.unimplemented", args[i]);
|
||||
return null;
|
||||
|
||||
// see implementation sketch above
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, all that remains non-null in the args
|
||||
* array are input class names or illegal options.
|
||||
*/
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] != null) {
|
||||
if (args[i].startsWith("-")) {
|
||||
error("rmic.no.such.option", args[i]);
|
||||
usage();
|
||||
return null;
|
||||
} else {
|
||||
batch.classes.add(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (batch.classes.isEmpty()) {
|
||||
usage();
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* If options did not specify at least one protocol-specific
|
||||
* generator, then JRMP is the default.
|
||||
*/
|
||||
if (batch.generators.isEmpty()) {
|
||||
batch.generators.add(new JrmpGenerator());
|
||||
}
|
||||
return batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doclet class entry point.
|
||||
**/
|
||||
public static boolean start(RootDoc rootDoc) {
|
||||
|
||||
/*
|
||||
* Find batch ID among javadoc options, and retrieve
|
||||
* corresponding batch data from global table.
|
||||
*/
|
||||
long batchID = -1;
|
||||
for (String[] option : rootDoc.options()) {
|
||||
if (option[0].equals("-batchID")) {
|
||||
try {
|
||||
batchID = Long.parseLong(option[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Batch batch = batchTable.get(batchID);
|
||||
assert batch != null;
|
||||
|
||||
/*
|
||||
* Construct batch environment using class agreed upon by
|
||||
* generator implementations.
|
||||
*/
|
||||
BatchEnvironment env;
|
||||
try {
|
||||
Constructor<? extends BatchEnvironment> cons =
|
||||
batch.envClass.getConstructor(new Class<?>[] { RootDoc.class });
|
||||
env = cons.newInstance(rootDoc);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
env.setVerbose(batch.verbose);
|
||||
|
||||
/*
|
||||
* Determine the destination directory (the top of the package
|
||||
* hierarchy) for the output of this batch; if no destination
|
||||
* directory was specified on the command line, then the
|
||||
* default is the current working directory.
|
||||
*/
|
||||
File destDir = batch.destDir;
|
||||
if (destDir == null) {
|
||||
destDir = new File(System.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Run each input class through each generator.
|
||||
*/
|
||||
for (String inputClassName : batch.classes) {
|
||||
ClassDoc inputClass = rootDoc.classNamed(inputClassName);
|
||||
try {
|
||||
for (Generator gen : batch.generators) {
|
||||
gen.generate(env, inputClass, destDir);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
/*
|
||||
* We assume that this means that some class that was
|
||||
* needed (perhaps even a bootstrap class) was not
|
||||
* found, and that javadoc has already reported this
|
||||
* as an error. There is nothing for us to do here
|
||||
* but try to continue with the next input class.
|
||||
*
|
||||
* REMIND: More explicit error checking throughout
|
||||
* would be preferable, however.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile any generated source files, if configured to do so.
|
||||
*/
|
||||
boolean status = true;
|
||||
List<File> generatedFiles = env.generatedFiles();
|
||||
if (!batch.noCompile && !batch.noWrite && !generatedFiles.isEmpty()) {
|
||||
status = batch.enclosingMain().invokeJavac(batch, generatedFiles);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete any generated source files, if configured to do so.
|
||||
*/
|
||||
if (!batch.keepGenerated) {
|
||||
for (File file : generatedFiles) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doclet class method that indicates that this doclet class
|
||||
* recognizes (only) the "-batchID" option on the javadoc command
|
||||
* line, and that the "-batchID" option comprises two arguments on
|
||||
* the javadoc command line.
|
||||
**/
|
||||
public static int optionLength(String option) {
|
||||
if (option.equals("-batchID")) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the javadoc tool to invoke this class as a doclet, passing
|
||||
* command line options derived from the specified batch data and
|
||||
* indicating the specified batch ID.
|
||||
*
|
||||
* NOTE: This method currently uses a J2SE-internal API to run
|
||||
* javadoc. If and when there is a J2SE API for invoking SDK
|
||||
* tools, this method should be updated to use that API instead.
|
||||
**/
|
||||
private boolean invokeJavadoc(Batch batch, long batchID) {
|
||||
List<String> javadocArgs = new ArrayList<String>();
|
||||
|
||||
// include all types, regardless of language-level access
|
||||
javadocArgs.add("-private");
|
||||
|
||||
// inputs are class names, not source files
|
||||
javadocArgs.add("-Xclasses");
|
||||
|
||||
// reproduce relevant options from rmic invocation
|
||||
if (batch.verbose) {
|
||||
javadocArgs.add("-verbose");
|
||||
}
|
||||
if (batch.bootClassPath != null) {
|
||||
javadocArgs.add("-bootclasspath");
|
||||
javadocArgs.add(batch.bootClassPath);
|
||||
}
|
||||
if (batch.extDirs != null) {
|
||||
javadocArgs.add("-extdirs");
|
||||
javadocArgs.add(batch.extDirs);
|
||||
}
|
||||
if (batch.classPath != null) {
|
||||
javadocArgs.add("-classpath");
|
||||
javadocArgs.add(batch.classPath);
|
||||
}
|
||||
|
||||
// specify batch ID
|
||||
javadocArgs.add("-batchID");
|
||||
javadocArgs.add(Long.toString(batchID));
|
||||
|
||||
/*
|
||||
* Run javadoc on union of rmic input classes and all
|
||||
* generators' bootstrap classes, so that they will all be
|
||||
* available to the doclet code.
|
||||
*/
|
||||
Set<String> classNames = new HashSet<String>();
|
||||
for (Generator gen : batch.generators) {
|
||||
classNames.addAll(gen.bootstrapClassNames());
|
||||
}
|
||||
classNames.addAll(batch.classes);
|
||||
for (String s : classNames) {
|
||||
javadocArgs.add(s);
|
||||
}
|
||||
|
||||
// run javadoc with our program name and output stream
|
||||
int status = com.sun.tools.javadoc.Main.execute(
|
||||
program,
|
||||
new PrintWriter(out, true),
|
||||
new PrintWriter(out, true),
|
||||
new PrintWriter(out, true),
|
||||
this.getClass().getName(), // doclet class is this class
|
||||
javadocArgs.toArray(new String[javadocArgs.size()]));
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the javac tool to compile the specified source files,
|
||||
* passing command line options derived from the specified batch
|
||||
* data.
|
||||
*
|
||||
* NOTE: This method currently uses a J2SE-internal API to run
|
||||
* javac. If and when there is a J2SE API for invoking SDK tools,
|
||||
* this method should be updated to use that API instead.
|
||||
**/
|
||||
private boolean invokeJavac(Batch batch, List<File> files) {
|
||||
List<String> javacArgs = new ArrayList<String>();
|
||||
|
||||
// rmic never wants to display javac warnings
|
||||
javacArgs.add("-nowarn");
|
||||
|
||||
// reproduce relevant options from rmic invocation
|
||||
if (batch.debug) {
|
||||
javacArgs.add("-g");
|
||||
}
|
||||
if (batch.verbose) {
|
||||
javacArgs.add("-verbose");
|
||||
}
|
||||
if (batch.bootClassPath != null) {
|
||||
javacArgs.add("-bootclasspath");
|
||||
javacArgs.add(batch.bootClassPath);
|
||||
}
|
||||
if (batch.extDirs != null) {
|
||||
javacArgs.add("-extdirs");
|
||||
javacArgs.add(batch.extDirs);
|
||||
}
|
||||
if (batch.classPath != null) {
|
||||
javacArgs.add("-classpath");
|
||||
javacArgs.add(batch.classPath);
|
||||
}
|
||||
|
||||
/*
|
||||
* For now, rmic still always produces class files that have a
|
||||
* class file format version compatible with JDK 1.1.
|
||||
*/
|
||||
javacArgs.add("-source");
|
||||
javacArgs.add("1.3");
|
||||
javacArgs.add("-target");
|
||||
javacArgs.add("1.1");
|
||||
|
||||
// add source files to compile
|
||||
for (File file : files) {
|
||||
javacArgs.add(file.getPath());
|
||||
}
|
||||
|
||||
// run javac with our output stream
|
||||
int status = com.sun.tools.javac.Main.compile(
|
||||
javacArgs.toArray(new String[javacArgs.size()]),
|
||||
new PrintWriter(out, true));
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The data for an rmic compliation batch: the processed command
|
||||
* line arguments.
|
||||
**/
|
||||
private class Batch {
|
||||
boolean keepGenerated = false; // -keep or -keepgenerated
|
||||
boolean debug = false; // -g
|
||||
boolean noWarn = false; // -nowarn
|
||||
boolean noWrite = false; // -nowrite
|
||||
boolean verbose = false; // -verbose
|
||||
boolean noCompile = false; // -Xnocompile
|
||||
String bootClassPath = null; // -bootclasspath
|
||||
String extDirs = null; // -extdirs
|
||||
String classPath = null; // -classpath
|
||||
File destDir = null; // -d
|
||||
List<Generator> generators = new ArrayList<Generator>();
|
||||
Class<? extends BatchEnvironment> envClass = BatchEnvironment.class;
|
||||
List<String> classes = new ArrayList<String>();
|
||||
|
||||
Batch() { }
|
||||
|
||||
/**
|
||||
* Returns the Main instance for this batch.
|
||||
**/
|
||||
Main enclosingMain() {
|
||||
return Main.this;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.rmi.rmic.newrmic;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Provides resource support for rmic.
|
||||
*
|
||||
* 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 final class Resources {
|
||||
|
||||
private static ResourceBundle resources = null;
|
||||
private static ResourceBundle resourcesExt = null;
|
||||
static {
|
||||
try {
|
||||
resources =
|
||||
ResourceBundle.getBundle("sun.rmi.rmic.resources.rmic");
|
||||
} catch (MissingResourceException e) {
|
||||
// gracefully handle this later
|
||||
}
|
||||
try {
|
||||
resourcesExt =
|
||||
ResourceBundle.getBundle("sun.rmi.rmic.resources.rmicext");
|
||||
} catch (MissingResourceException e) {
|
||||
// OK if this isn't found
|
||||
}
|
||||
}
|
||||
|
||||
private Resources() { throw new AssertionError(); }
|
||||
|
||||
/**
|
||||
* Returns the text of the rmic resource for the specified key
|
||||
* formatted with the specified arguments.
|
||||
**/
|
||||
public static String getText(String key, String... args) {
|
||||
String format = getString(key);
|
||||
if (format == null) {
|
||||
format = "missing resource key: key = \"" + key + "\", " +
|
||||
"arguments = \"{0}\", \"{1}\", \"{2}\"";
|
||||
}
|
||||
return MessageFormat.format(format, (Object[]) args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rmic resource string for the specified key.
|
||||
**/
|
||||
private static String getString(String key) {
|
||||
if (resourcesExt != null) {
|
||||
try {
|
||||
return resourcesExt.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
}
|
||||
}
|
||||
if (resources != null) {
|
||||
try {
|
||||
return resources.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return "missing resource bundle: key = \"" + key + "\", " +
|
||||
"arguments = \"{0}\", \"{1}\", \"{2}\"";
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic.jrmp;
|
||||
|
||||
/**
|
||||
* Constants specific to the JRMP rmic generator.
|
||||
*
|
||||
* 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
|
||||
**/
|
||||
final class Constants {
|
||||
|
||||
private Constants() { throw new AssertionError(); }
|
||||
|
||||
/*
|
||||
* fully-qualified names of types used by rmic
|
||||
*/
|
||||
static final String REMOTE_OBJECT = "java.rmi.server.RemoteObject";
|
||||
static final String REMOTE_STUB = "java.rmi.server.RemoteStub";
|
||||
static final String REMOTE_REF = "java.rmi.server.RemoteRef";
|
||||
static final String OPERATION = "java.rmi.server.Operation";
|
||||
static final String SKELETON = "java.rmi.server.Skeleton";
|
||||
static final String SKELETON_MISMATCH_EXCEPTION =
|
||||
"java.rmi.server.SkeletonMismatchException";
|
||||
static final String REMOTE_CALL = "java.rmi.server.RemoteCall";
|
||||
static final String MARSHAL_EXCEPTION = "java.rmi.MarshalException";
|
||||
static final String UNMARSHAL_EXCEPTION = "java.rmi.UnmarshalException";
|
||||
static final String UNEXPECTED_EXCEPTION = "java.rmi.UnexpectedException";
|
||||
|
||||
/*
|
||||
* stub protocol versions
|
||||
*/
|
||||
enum StubVersion { V1_1, VCOMPAT, V1_2 };
|
||||
|
||||
/*
|
||||
* serialVersionUID for all stubs that can use 1.2 protocol
|
||||
*/
|
||||
static final long STUB_SERIAL_VERSION_UID = 2;
|
||||
|
||||
/*
|
||||
* version number used to seed interface hash computation
|
||||
*/
|
||||
static final int INTERFACE_HASH_STUB_VERSION = 1;
|
||||
}
|
@ -1,226 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.newrmic.jrmp;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import sun.rmi.rmic.newrmic.BatchEnvironment;
|
||||
import sun.rmi.rmic.newrmic.Generator;
|
||||
import sun.rmi.rmic.newrmic.IndentingWriter;
|
||||
import sun.rmi.rmic.newrmic.Main;
|
||||
import sun.rmi.rmic.newrmic.Resources;
|
||||
|
||||
import static sun.rmi.rmic.newrmic.jrmp.Constants.*;
|
||||
|
||||
/**
|
||||
* JRMP rmic back end; generates source code for JRMP stub and
|
||||
* skeleton 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 Peter Jones
|
||||
**/
|
||||
public class JrmpGenerator implements Generator {
|
||||
|
||||
private static final Map<String,StubVersion> versionOptions =
|
||||
new HashMap<String,StubVersion>();
|
||||
static {
|
||||
versionOptions.put("-v1.1", StubVersion.V1_1);
|
||||
versionOptions.put("-vcompat", StubVersion.VCOMPAT);
|
||||
versionOptions.put("-v1.2", StubVersion.V1_2);
|
||||
}
|
||||
|
||||
private static final Set<String> bootstrapClassNames =
|
||||
new HashSet<String>();
|
||||
static {
|
||||
bootstrapClassNames.add("java.lang.Exception");
|
||||
bootstrapClassNames.add("java.rmi.Remote");
|
||||
bootstrapClassNames.add("java.rmi.RemoteException");
|
||||
bootstrapClassNames.add("java.lang.RuntimeException");
|
||||
};
|
||||
|
||||
/** version of the JRMP stub protocol to generate code for */
|
||||
private StubVersion version = StubVersion.V1_2; // default is -v1.2
|
||||
|
||||
/**
|
||||
* Creates a new JrmpGenerator.
|
||||
**/
|
||||
public JrmpGenerator() { }
|
||||
|
||||
/**
|
||||
* The JRMP generator recognizes command line options for
|
||||
* selecting the JRMP stub protocol version to generate classes
|
||||
* for. Only one such option is allowed.
|
||||
**/
|
||||
public boolean parseArgs(String[] args, Main main) {
|
||||
String explicitVersion = null;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
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);
|
||||
args[i] = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The JRMP generator does not require an environment class more
|
||||
* specific than BatchEnvironment.
|
||||
**/
|
||||
public Class<? extends BatchEnvironment> envClass() {
|
||||
return BatchEnvironment.class;
|
||||
}
|
||||
|
||||
public Set<String> bootstrapClassNames() {
|
||||
return Collections.unmodifiableSet(bootstrapClassNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the source file(s) for the JRMP stub class and
|
||||
* (optionally) skeleton class for the specified remote
|
||||
* implementation class.
|
||||
**/
|
||||
public void generate(BatchEnvironment env,
|
||||
ClassDoc inputClass,
|
||||
File destDir)
|
||||
{
|
||||
RemoteClass remoteClass = RemoteClass.forClass(env, inputClass);
|
||||
if (remoteClass == null) {
|
||||
return; // an error must have occurred
|
||||
}
|
||||
|
||||
StubSkeletonWriter writer =
|
||||
new StubSkeletonWriter(env, remoteClass, version);
|
||||
|
||||
File stubFile = sourceFileForClass(writer.stubClassName(), destDir);
|
||||
try {
|
||||
IndentingWriter out = new IndentingWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(stubFile)));
|
||||
writer.writeStub(out);
|
||||
out.close();
|
||||
if (env.verbose()) {
|
||||
env.output(Resources.getText("rmic.wrote",
|
||||
stubFile.getPath()));
|
||||
}
|
||||
env.addGeneratedFile(stubFile);
|
||||
} catch (IOException e) {
|
||||
env.error("rmic.cant.write", stubFile.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
File skeletonFile =
|
||||
sourceFileForClass(writer.skeletonClassName(), destDir);
|
||||
if (version == StubVersion.V1_1 ||
|
||||
version == StubVersion.VCOMPAT)
|
||||
{
|
||||
try {
|
||||
IndentingWriter out = new IndentingWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(skeletonFile)));
|
||||
writer.writeSkeleton(out);
|
||||
out.close();
|
||||
if (env.verbose()) {
|
||||
env.output(Resources.getText("rmic.wrote",
|
||||
skeletonFile.getPath()));
|
||||
}
|
||||
env.addGeneratedFile(skeletonFile);
|
||||
} catch (IOException e) {
|
||||
env.error("rmic.cant.write", skeletonFile.toString());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* If skeleton files are not being generated for this 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 skeletonClassFile =
|
||||
classFileForClass(writer.skeletonClassName(), destDir);
|
||||
|
||||
skeletonFile.delete(); // ignore failures (no big deal)
|
||||
skeletonClassFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the File object to be used as the source file for a
|
||||
* class with the specified binary name, with the specified
|
||||
* destination directory as the top of the package hierarchy.
|
||||
**/
|
||||
private File sourceFileForClass(String binaryName, File destDir) {
|
||||
return fileForClass(binaryName, destDir, ".java");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the File object to be used as the class file for a
|
||||
* class with the specified binary name, with the supplied
|
||||
* destination directory as the top of the package hierarchy.
|
||||
**/
|
||||
private File classFileForClass(String binaryName, File destDir) {
|
||||
return fileForClass(binaryName, destDir, ".class");
|
||||
}
|
||||
|
||||
private File fileForClass(String binaryName, File destDir, String ext) {
|
||||
int i = binaryName.lastIndexOf('.');
|
||||
String classFileName = binaryName.substring(i + 1) + ext;
|
||||
if (i != -1) {
|
||||
String packageName = binaryName.substring(0, i);
|
||||
String packagePath = packageName.replace('.', File.separatorChar);
|
||||
File packageDir = new File(destDir, packagePath);
|
||||
/*
|
||||
* Make sure that the directory for this package exists.
|
||||
* We assume that the caller has verified that the top-
|
||||
* level destination directory exists, so we need not
|
||||
* worry about creating it unintentionally.
|
||||
*/
|
||||
if (!packageDir.exists()) {
|
||||
packageDir.mkdirs();
|
||||
}
|
||||
return new File(packageDir, classFileName);
|
||||
} else {
|
||||
return new File(destDir, classFileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,710 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, 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.newrmic.jrmp;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import com.sun.javadoc.MethodDoc;
|
||||
import com.sun.javadoc.Parameter;
|
||||
import com.sun.javadoc.Type;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import sun.rmi.rmic.newrmic.BatchEnvironment;
|
||||
|
||||
import static sun.rmi.rmic.newrmic.Constants.*;
|
||||
import static sun.rmi.rmic.newrmic.jrmp.Constants.*;
|
||||
|
||||
/**
|
||||
* Encapsulates RMI-specific information about a remote implementation
|
||||
* class (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
|
||||
**/
|
||||
final class RemoteClass {
|
||||
|
||||
/** rmic environment for this object */
|
||||
private final BatchEnvironment env;
|
||||
|
||||
/** the remote implementation class this object represents */
|
||||
private final ClassDoc implClass;
|
||||
|
||||
/** remote interfaces implemented by this class */
|
||||
private ClassDoc[] remoteInterfaces;
|
||||
|
||||
/** the remote methods of this class */
|
||||
private Method[] remoteMethods;
|
||||
|
||||
/** stub/skeleton "interface hash" for this class */
|
||||
private long interfaceHash;
|
||||
|
||||
/**
|
||||
* Creates a RemoteClass instance that represents the RMI-specific
|
||||
* information about the specified remote implementation class.
|
||||
*
|
||||
* If the class is not a valid 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.
|
||||
**/
|
||||
static RemoteClass forClass(BatchEnvironment env, ClassDoc implClass) {
|
||||
RemoteClass remoteClass = new RemoteClass(env, implClass);
|
||||
if (remoteClass.init()) {
|
||||
return remoteClass;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a RemoteClass instance for the specified class. The
|
||||
* resulting object is not yet initialized.
|
||||
**/
|
||||
private RemoteClass(BatchEnvironment env, ClassDoc implClass) {
|
||||
this.env = env;
|
||||
this.implClass = implClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ClassDoc for this remote implementation class.
|
||||
**/
|
||||
ClassDoc classDoc() {
|
||||
return implClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote interfaces implemented by this remote
|
||||
* implementation class.
|
||||
*
|
||||
* A remote interface is an interface that is a subinterface of
|
||||
* java.rmi.Remote. The remote interfaces of a class are the
|
||||
* direct superinterfaces of the class and all 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).
|
||||
**/
|
||||
ClassDoc[] remoteInterfaces() {
|
||||
return remoteInterfaces.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of RemoteClass.Method objects representing all
|
||||
* of the remote methods of this remote implementation class (all
|
||||
* of the member methods of the class's remote interfaces).
|
||||
*
|
||||
* The methods in the array are ordered according to a comparison
|
||||
* of strings consisting of their name followed by their
|
||||
* descriptor, so each method's index in the array corresponds to
|
||||
* its "operation number" in the JDK 1.1 version of the JRMP
|
||||
* stub/skeleton protocol.
|
||||
**/
|
||||
Method[] remoteMethods() {
|
||||
return remoteMethods.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the "interface hash" used to match a stub/skeleton pair
|
||||
* for this remote implementation class in the JDK 1.1 version of
|
||||
* the JRMP stub/skeleton protocol.
|
||||
**/
|
||||
long interfaceHash() {
|
||||
return interfaceHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates this remote implementation class and computes the
|
||||
* RMI-specific information. Returns true if successful, or false
|
||||
* if an error occurred.
|
||||
**/
|
||||
private boolean init() {
|
||||
/*
|
||||
* Verify that it is really a class, not an interface.
|
||||
*/
|
||||
if (implClass.isInterface()) {
|
||||
env.error("rmic.cant.make.stubs.for.interface",
|
||||
implClass.qualifiedName());
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
List<ClassDoc> remotesImplemented = new ArrayList<ClassDoc>();
|
||||
for (ClassDoc cl = implClass; cl != null; cl = cl.superclass()) {
|
||||
for (ClassDoc intf : cl.interfaces()) {
|
||||
/*
|
||||
* Add interface to the list if it extends Remote and
|
||||
* it is not already there.
|
||||
*/
|
||||
if (!remotesImplemented.contains(intf) &&
|
||||
intf.subclassOf(env.docRemote()))
|
||||
{
|
||||
remotesImplemented.add(intf);
|
||||
if (env.verbose()) {
|
||||
env.output("[found remote interface: " +
|
||||
intf.qualifiedName() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that the candidate remote implementation class
|
||||
* implements at least one remote interface directly.
|
||||
*/
|
||||
if (cl == implClass && remotesImplemented.isEmpty()) {
|
||||
if (implClass.subclassOf(env.docRemote())) {
|
||||
/*
|
||||
* This error message is used if the class does
|
||||
* implement a remote interface through one of its
|
||||
* superclasses, but not directly.
|
||||
*/
|
||||
env.error("rmic.must.implement.remote.directly",
|
||||
implClass.qualifiedName());
|
||||
} else {
|
||||
/*
|
||||
* This error message is used if the class does
|
||||
* not implement a remote interface at all.
|
||||
*/
|
||||
env.error("rmic.must.implement.remote",
|
||||
implClass.qualifiedName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert list of remote interfaces to an array
|
||||
* (order is not important for this array).
|
||||
*/
|
||||
remoteInterfaces =
|
||||
remotesImplemented.toArray(
|
||||
new ClassDoc[remotesImplemented.size()]);
|
||||
|
||||
/*
|
||||
* Collect the methods from all of the remote interfaces into
|
||||
* a table, which maps from method name-and-descriptor string
|
||||
* to Method object.
|
||||
*/
|
||||
Map<String,Method> methods = new HashMap<String,Method>();
|
||||
boolean errors = false;
|
||||
for (ClassDoc intf : remotesImplemented) {
|
||||
if (!collectRemoteMethods(intf, methods)) {
|
||||
/*
|
||||
* Continue iterating despite errors in order to
|
||||
* generate more complete error report.
|
||||
*/
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
if (errors) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort table of remote methods into an array. The elements
|
||||
* are sorted in ascending order of the string of the method's
|
||||
* name and descriptor, so that each elements index is equal
|
||||
* to its operation number in the JDK 1.1 version of the JRMP
|
||||
* stub/skeleton protocol.
|
||||
*/
|
||||
String[] orderedKeys =
|
||||
methods.keySet().toArray(new String[methods.size()]);
|
||||
Arrays.sort(orderedKeys);
|
||||
remoteMethods = new Method[methods.size()];
|
||||
for (int i = 0; i < remoteMethods.length; i++) {
|
||||
remoteMethods[i] = methods.get(orderedKeys[i]);
|
||||
if (env.verbose()) {
|
||||
String msg = "[found remote method <" + i + ">: " +
|
||||
remoteMethods[i].operationString();
|
||||
ClassDoc[] exceptions = remoteMethods[i].exceptionTypes();
|
||||
if (exceptions.length > 0) {
|
||||
msg += " throws ";
|
||||
for (int j = 0; j < exceptions.length; j++) {
|
||||
if (j > 0) {
|
||||
msg += ", ";
|
||||
}
|
||||
msg += exceptions[j].qualifiedName();
|
||||
}
|
||||
}
|
||||
msg += "\n\tname and descriptor = \"" +
|
||||
remoteMethods[i].nameAndDescriptor();
|
||||
msg += "\n\tmethod hash = " +
|
||||
remoteMethods[i].methodHash() + "]";
|
||||
env.output(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, pre-compute the interface hash to be used by
|
||||
* stubs/skeletons for this remote class in the JDK 1.1
|
||||
* version of the JRMP stub/skeleton protocol.
|
||||
*/
|
||||
interfaceHash = computeInterfaceHash();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects and validates all methods from the specified interface
|
||||
* and all of its superinterfaces as remote methods. Remote
|
||||
* methods are added to the supplied table. Returns true if
|
||||
* successful, or false if an error occurred.
|
||||
**/
|
||||
private boolean collectRemoteMethods(ClassDoc intf,
|
||||
Map<String,Method> table)
|
||||
{
|
||||
if (!intf.isInterface()) {
|
||||
throw new AssertionError(
|
||||
intf.qualifiedName() + " not an interface");
|
||||
}
|
||||
|
||||
boolean errors = false;
|
||||
|
||||
/*
|
||||
* Search interface's declared methods.
|
||||
*/
|
||||
nextMethod:
|
||||
for (MethodDoc method : intf.methods()) {
|
||||
|
||||
/*
|
||||
* Verify that each method throws RemoteException (or a
|
||||
* superclass of RemoteException).
|
||||
*/
|
||||
boolean hasRemoteException = false;
|
||||
for (ClassDoc ex : method.thrownExceptions()) {
|
||||
if (env.docRemoteException().subclassOf(ex)) {
|
||||
hasRemoteException = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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("rmic.must.throw.remoteexception",
|
||||
intf.qualifiedName(),
|
||||
method.name() + method.signature());
|
||||
errors = true;
|
||||
continue nextMethod;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
MethodDoc implMethod = findImplMethod(method);
|
||||
if (implMethod != null) { // should not be null
|
||||
for (ClassDoc ex : implMethod.thrownExceptions()) {
|
||||
if (!ex.subclassOf(env.docException())) {
|
||||
env.error("rmic.must.only.throw.exception",
|
||||
implMethod.name() + implMethod.signature(),
|
||||
ex.qualifiedName());
|
||||
errors = true;
|
||||
continue nextMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create RemoteClass.Method object to represent this method
|
||||
* found in a remote interface.
|
||||
*/
|
||||
Method newMethod = new Method(method);
|
||||
|
||||
/*
|
||||
* Store remote method's representation in the table of
|
||||
* remote methods found, keyed by its name and descriptor.
|
||||
*
|
||||
* If the table already contains an entry with the same
|
||||
* method name and descriptor, 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
|
||||
* clause that contains (only) all of the checked
|
||||
* exceptions that can be thrown by both the old and the
|
||||
* new method (see bugid 4070653).
|
||||
*/
|
||||
String key = newMethod.nameAndDescriptor();
|
||||
Method oldMethod = table.get(key);
|
||||
if (oldMethod != null) {
|
||||
newMethod = newMethod.mergeWith(oldMethod);
|
||||
}
|
||||
table.put(key, newMethod);
|
||||
}
|
||||
|
||||
/*
|
||||
* Recursively collect methods for all superinterfaces.
|
||||
*/
|
||||
for (ClassDoc superintf : intf.interfaces()) {
|
||||
if (!collectRemoteMethods(superintf, table)) {
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MethodDoc for the method of this remote
|
||||
* implementation class that implements the specified remote
|
||||
* method of a remote interface. Returns null if no matching
|
||||
* method was found in this remote implementation class.
|
||||
**/
|
||||
private MethodDoc findImplMethod(MethodDoc interfaceMethod) {
|
||||
String name = interfaceMethod.name();
|
||||
String desc = Util.methodDescriptorOf(interfaceMethod);
|
||||
for (MethodDoc implMethod : implClass.methods()) {
|
||||
if (name.equals(implMethod.name()) &&
|
||||
desc.equals(Util.methodDescriptorOf(implMethod)))
|
||||
{
|
||||
return implMethod;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes 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 class and a
|
||||
* skeleton class in the JDK 1.1 version of the JRMP stub/skeleton
|
||||
* protocol.
|
||||
*
|
||||
* It is calculated using the first 64 bits of an SHA digest. The
|
||||
* digest is of a stream consisting of the following data:
|
||||
* (int) stub version number, always 1
|
||||
* for each remote method, in order of operation number:
|
||||
* (UTF-8) method name
|
||||
* (UTF-8) method descriptor
|
||||
* for each declared exception, in alphabetical name order:
|
||||
* (UTF-8) name of exception class
|
||||
* (where "UTF-8" includes a 16-bit length prefix as written by
|
||||
* java.io.DataOutput.writeUTF).
|
||||
**/
|
||||
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 (Method method : remoteMethods) {
|
||||
MethodDoc methodDoc = method.methodDoc();
|
||||
|
||||
out.writeUTF(methodDoc.name());
|
||||
out.writeUTF(Util.methodDescriptorOf(methodDoc));
|
||||
// descriptors already use binary names
|
||||
|
||||
ClassDoc exceptions[] = methodDoc.thrownExceptions();
|
||||
Arrays.sort(exceptions, new ClassDocComparator());
|
||||
for (ClassDoc ex : exceptions) {
|
||||
out.writeUTF(Util.binaryNameOf(ex));
|
||||
}
|
||||
}
|
||||
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 AssertionError(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares ClassDoc instances according to the lexicographic
|
||||
* order of their binary names.
|
||||
**/
|
||||
private static class ClassDocComparator implements Comparator<ClassDoc> {
|
||||
public int compare(ClassDoc o1, ClassDoc o2) {
|
||||
return Util.binaryNameOf(o1).compareTo(Util.binaryNameOf(o2));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates RMI-specific information about a particular remote
|
||||
* method in the remote implementation class represented by the
|
||||
* enclosing RemoteClass.
|
||||
**/
|
||||
final class Method implements Cloneable {
|
||||
|
||||
/**
|
||||
* MethodDoc for this remove method, from one of the remote
|
||||
* interfaces that this method was found in.
|
||||
*
|
||||
* Note that this MethodDoc may be only one of multiple that
|
||||
* correspond to this remote method object, if multiple of
|
||||
* this class's remote interfaces contain methods with the
|
||||
* same name and descriptor. Therefore, this MethodDoc may
|
||||
* declare more exceptions thrown that this remote method
|
||||
* does.
|
||||
**/
|
||||
private final MethodDoc methodDoc;
|
||||
|
||||
/** java.rmi.server.Operation string for this remote method */
|
||||
private final String operationString;
|
||||
|
||||
/** name and descriptor of this remote method */
|
||||
private final String nameAndDescriptor;
|
||||
|
||||
/** JRMP "method hash" for this remote method */
|
||||
private final long methodHash;
|
||||
|
||||
/**
|
||||
* Exceptions declared to be thrown by this remote method.
|
||||
*
|
||||
* This list may include superfluous entries, such as
|
||||
* unchecked exceptions and subclasses of other entries.
|
||||
**/
|
||||
private ClassDoc[] exceptionTypes;
|
||||
|
||||
/**
|
||||
* Creates a new Method instance for the specified method.
|
||||
**/
|
||||
Method(MethodDoc methodDoc) {
|
||||
this.methodDoc = methodDoc;
|
||||
exceptionTypes = methodDoc.thrownExceptions();
|
||||
/*
|
||||
* Sort exception types to improve consistency with
|
||||
* previous implementations.
|
||||
*/
|
||||
Arrays.sort(exceptionTypes, new ClassDocComparator());
|
||||
operationString = computeOperationString();
|
||||
nameAndDescriptor =
|
||||
methodDoc.name() + Util.methodDescriptorOf(methodDoc);
|
||||
methodHash = computeMethodHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MethodDoc object corresponding to this method
|
||||
* of a remote interface.
|
||||
**/
|
||||
MethodDoc methodDoc() {
|
||||
return methodDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameter types declared by this method.
|
||||
**/
|
||||
Type[] parameterTypes() {
|
||||
Parameter[] parameters = methodDoc.parameters();
|
||||
Type[] paramTypes = new Type[parameters.length];
|
||||
for (int i = 0; i < paramTypes.length; i++) {
|
||||
paramTypes[i] = parameters[i].type();
|
||||
}
|
||||
return paramTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception types declared to be thrown by this
|
||||
* remote method.
|
||||
*
|
||||
* For methods with the same name and descriptor 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 by all of them.
|
||||
**/
|
||||
ClassDoc[] exceptionTypes() {
|
||||
return exceptionTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JRMP "method hash" used to identify this remote
|
||||
* method in the JDK 1.2 version of the stub protocol.
|
||||
**/
|
||||
long methodHash() {
|
||||
return methodHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this method
|
||||
* appropriate for the construction of a
|
||||
* java.rmi.server.Operation object.
|
||||
**/
|
||||
String operationString() {
|
||||
return operationString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string consisting of this method's name followed
|
||||
* by its descriptor.
|
||||
**/
|
||||
String nameAndDescriptor() {
|
||||
return nameAndDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Method object that is a legal combination of
|
||||
* this Method object and another one.
|
||||
*
|
||||
* Doing 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.
|
||||
**/
|
||||
Method mergeWith(Method other) {
|
||||
if (!nameAndDescriptor().equals(other.nameAndDescriptor())) {
|
||||
throw new AssertionError(
|
||||
"attempt to merge method \"" +
|
||||
other.nameAndDescriptor() + "\" with \"" +
|
||||
nameAndDescriptor());
|
||||
}
|
||||
|
||||
List<ClassDoc> legalExceptions = new ArrayList<ClassDoc>();
|
||||
collectCompatibleExceptions(
|
||||
other.exceptionTypes, exceptionTypes, legalExceptions);
|
||||
collectCompatibleExceptions(
|
||||
exceptionTypes, other.exceptionTypes, legalExceptions);
|
||||
|
||||
Method merged = clone();
|
||||
merged.exceptionTypes =
|
||||
legalExceptions.toArray(new ClassDoc[legalExceptions.size()]);
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloning is supported by returning a shallow copy of this
|
||||
* object.
|
||||
**/
|
||||
protected Method clone() {
|
||||
try {
|
||||
return (Method) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the supplied list all exceptions in the "froms"
|
||||
* array that are subclasses of an exception in the "withs"
|
||||
* array.
|
||||
**/
|
||||
private void collectCompatibleExceptions(ClassDoc[] froms,
|
||||
ClassDoc[] withs,
|
||||
List<ClassDoc> list)
|
||||
{
|
||||
for (ClassDoc from : froms) {
|
||||
if (!list.contains(from)) {
|
||||
for (ClassDoc with : withs) {
|
||||
if (from.subclassOf(with)) {
|
||||
list.add(from);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the JRMP "method hash" of this remote method. The
|
||||
* method hash is a long containing the first 64 bits of the
|
||||
* SHA digest from the UTF-8 encoded string of the method name
|
||||
* and descriptor.
|
||||
**/
|
||||
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 = nameAndDescriptor();
|
||||
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 AssertionError(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the string representation of this method
|
||||
* appropriate for the construction of a
|
||||
* java.rmi.server.Operation object.
|
||||
**/
|
||||
private String computeOperationString() {
|
||||
/*
|
||||
* To be consistent with previous implementations, we use
|
||||
* the deprecated style of placing the "[]" for the return
|
||||
* type (if any) after the parameter list.
|
||||
*/
|
||||
Type returnType = methodDoc.returnType();
|
||||
String op = returnType.qualifiedTypeName() + " " +
|
||||
methodDoc.name() + "(";
|
||||
Parameter[] parameters = methodDoc.parameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (i > 0) {
|
||||
op += ", ";
|
||||
}
|
||||
op += parameters[i].type().toString();
|
||||
}
|
||||
op += ")" + returnType.dimension();
|
||||
return op;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.newrmic.jrmp;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import com.sun.javadoc.MethodDoc;
|
||||
import com.sun.javadoc.Parameter;
|
||||
import com.sun.javadoc.Type;
|
||||
|
||||
/**
|
||||
* Provides static utility methods.
|
||||
*
|
||||
* 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
|
||||
**/
|
||||
final class Util {
|
||||
|
||||
private Util() { throw new AssertionError(); }
|
||||
|
||||
/**
|
||||
* Returns the binary name of the class or interface represented
|
||||
* by the specified ClassDoc.
|
||||
**/
|
||||
static String binaryNameOf(ClassDoc cl) {
|
||||
String flat = cl.name().replace('.', '$');
|
||||
String packageName = cl.containingPackage().name();
|
||||
return packageName.equals("") ? flat : packageName + "." + flat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the method descriptor for the specified method.
|
||||
*
|
||||
* See section 4.3.3 of The Java Virtual Machine Specification
|
||||
* Second Edition for the definition of a "method descriptor".
|
||||
**/
|
||||
static String methodDescriptorOf(MethodDoc method) {
|
||||
String desc = "(";
|
||||
Parameter[] parameters = method.parameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
desc += typeDescriptorOf(parameters[i].type());
|
||||
}
|
||||
desc += ")" + typeDescriptorOf(method.returnType());
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor for the specified type, as appropriate
|
||||
* for either a parameter or return type in a method descriptor.
|
||||
**/
|
||||
private static String typeDescriptorOf(Type type) {
|
||||
String desc;
|
||||
ClassDoc classDoc = type.asClassDoc();
|
||||
if (classDoc == null) {
|
||||
/*
|
||||
* Handle primitive types.
|
||||
*/
|
||||
String name = type.typeName();
|
||||
if (name.equals("boolean")) {
|
||||
desc = "Z";
|
||||
} else if (name.equals("byte")) {
|
||||
desc = "B";
|
||||
} else if (name.equals("char")) {
|
||||
desc = "C";
|
||||
} else if (name.equals("short")) {
|
||||
desc = "S";
|
||||
} else if (name.equals("int")) {
|
||||
desc = "I";
|
||||
} else if (name.equals("long")) {
|
||||
desc = "J";
|
||||
} else if (name.equals("float")) {
|
||||
desc = "F";
|
||||
} else if (name.equals("double")) {
|
||||
desc = "D";
|
||||
} else if (name.equals("void")) {
|
||||
desc = "V";
|
||||
} else {
|
||||
throw new AssertionError(
|
||||
"unrecognized primitive type: " + name);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Handle non-array reference types.
|
||||
*/
|
||||
desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle array types.
|
||||
*/
|
||||
int dimensions = type.dimension().length() / 2;
|
||||
for (int i = 0; i < dimensions; i++) {
|
||||
desc = "[" + desc;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reader-friendly string representation of the
|
||||
* specified method's signature. Names of reference types are not
|
||||
* package-qualified.
|
||||
**/
|
||||
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
|
||||
String sig = method.name() + "(";
|
||||
Parameter[] parameters = method.parameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (i > 0) {
|
||||
sig += ", ";
|
||||
}
|
||||
Type paramType = parameters[i].type();
|
||||
sig += paramType.typeName() + paramType.dimension();
|
||||
}
|
||||
sig += ")";
|
||||
return sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified type is void.
|
||||
**/
|
||||
static boolean isVoid(Type type) {
|
||||
return type.asClassDoc() == null && type.typeName().equals("void");
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -167,6 +167,11 @@ public class Basic {
|
||||
readAndCheck(blah);
|
||||
blah.delete();
|
||||
|
||||
testNewChannelWriteAfterClose(blah);
|
||||
|
||||
testNewChannelReadAfterClose(blah);
|
||||
blah.delete();
|
||||
|
||||
writeOut(blah, ITERATIONS);
|
||||
testNewChannelIn(blah);
|
||||
test4481572(blah);
|
||||
@ -255,6 +260,7 @@ public class Basic {
|
||||
private static void testNewChannelOut(File blah) throws Exception {
|
||||
ExtendedFileOutputStream fos = new ExtendedFileOutputStream(blah);
|
||||
WritableByteChannel wbc = Channels.newChannel(fos);
|
||||
|
||||
for (int i=0; i<ITERATIONS; i++)
|
||||
wbc.write(ByteBuffer.wrap(message.getBytes(encoding)));
|
||||
wbc.close();
|
||||
@ -287,6 +293,37 @@ public class Basic {
|
||||
fis.close();
|
||||
}
|
||||
|
||||
private static void testNewChannelWriteAfterClose(File blah)
|
||||
throws Exception {
|
||||
try (ExtendedFileOutputStream fos =
|
||||
new ExtendedFileOutputStream(blah)) {
|
||||
WritableByteChannel wbc = Channels.newChannel(fos);
|
||||
|
||||
wbc.close();
|
||||
try {
|
||||
wbc.write(ByteBuffer.allocate(0));
|
||||
throw new RuntimeException
|
||||
("No ClosedChannelException on WritableByteChannel::write");
|
||||
} catch (ClosedChannelException expected) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testNewChannelReadAfterClose(File blah)
|
||||
throws Exception {
|
||||
try (ExtendedFileInputStream fis = new ExtendedFileInputStream(blah)) {
|
||||
ReadableByteChannel rbc = Channels.newChannel(fis);
|
||||
|
||||
rbc.close();
|
||||
try {
|
||||
rbc.read(ByteBuffer.allocate(0));
|
||||
throw new RuntimeException
|
||||
("No ClosedChannelException on ReadableByteChannel::read");
|
||||
} catch (ClosedChannelException expected) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Causes BufferOverflowException if bug 4481572 is present.
|
||||
private static void test4481572(File blah) throws Exception {
|
||||
ExtendedFileInputStream fis = new ExtendedFileInputStream(blah);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -114,7 +114,7 @@ public class Basic {
|
||||
failures++;
|
||||
} else if (!type.equals(expectedTypes[i])) {
|
||||
System.err.printf("Content type: %s; expected: %s%n",
|
||||
type, expectedTypes);
|
||||
type, expectedTypes[i]);
|
||||
failures++;
|
||||
}
|
||||
} finally {
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Object interface for agent
|
||||
*/
|
||||
|
||||
public interface Agent extends Serializable, Runnable {
|
||||
|
||||
/**
|
||||
* Run method controls the execution of agent and is called by servers.
|
||||
*/
|
||||
void run();
|
||||
|
||||
/**
|
||||
* getInfo method is called by home server to collect the information
|
||||
* that the agent has collected.
|
||||
*/
|
||||
Vector getInfo();
|
||||
|
||||
/**
|
||||
* getErrors returns String of errors encountered by Agent
|
||||
*/
|
||||
String getErrors();
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
|
||||
/**
|
||||
* Define the remote interface
|
||||
*/
|
||||
public interface AgentServer extends Remote {
|
||||
|
||||
/**
|
||||
* Accepts the agent, creates new thread and starts it.
|
||||
*/
|
||||
void accept (Agent agent)
|
||||
throws RemoteException; //, InvalidAgentException;
|
||||
|
||||
/**
|
||||
* Method for home server to accept agent returning home and
|
||||
* report gathered information to STDOUT.
|
||||
*/
|
||||
void returnHome (Agent agent)
|
||||
throws RemoteException; //, InvalidAgentException;
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.server.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* Server accepts agents and could test for validity. Acts as both a home
|
||||
* server and a regular server. The agent will jump to this host and
|
||||
* the server will create a thread and allow the agent to run inside of
|
||||
* it. The agent just queries the system.properties for machine info.
|
||||
*/
|
||||
public class AgentServerImpl
|
||||
extends UnicastRemoteObject
|
||||
implements AgentServer
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @exception RemoteException If a network problem occurs.
|
||||
*/
|
||||
public AgentServerImpl() throws RemoteException {
|
||||
// Could use to set up state of server
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates Agent Server Implementation and sets security
|
||||
* manager
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
|
||||
// Set the security Manager
|
||||
//System.setSecurityManager(new MyRMISecurityManager());
|
||||
|
||||
try {
|
||||
AgentServerImpl server = new AgentServerImpl();
|
||||
Naming.rebind("/AgentServer", server);
|
||||
System.out.println("Ready to receive agents.");
|
||||
System.err.println("DTI_DoneInitializing");
|
||||
} catch (Exception e) {
|
||||
System.err.println("DTI_Error");
|
||||
System.err.println("Did not establish server");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote method called by Agent to have server accept it.
|
||||
*/
|
||||
public synchronized void accept(Agent agent)
|
||||
throws RemoteException //, InvalidAgentException
|
||||
{
|
||||
Thread t;
|
||||
|
||||
// Could check validity of agent here
|
||||
// checkValid(agent);
|
||||
|
||||
// Create new thread to run agent
|
||||
t = new Thread(agent);
|
||||
|
||||
System.out.println("Agent Accepted: " + t);
|
||||
|
||||
// Start agent
|
||||
t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote method called by Agent to return to final server.
|
||||
*/
|
||||
public synchronized void returnHome(Agent agent)
|
||||
throws RemoteException //, InvalidAgentException
|
||||
{
|
||||
Enumeration info = null;
|
||||
boolean bErrorsOccurred = false;
|
||||
|
||||
// Could check validity of agent here
|
||||
// checkValid(agent);
|
||||
|
||||
// Grab and print collected info from agent
|
||||
info = agent.getInfo().elements();
|
||||
System.out.println("Collected information:");
|
||||
while (info.hasMoreElements()) {
|
||||
System.out.println(" " + (String) info.nextElement());
|
||||
}
|
||||
|
||||
System.out.println("\nErrors:");
|
||||
System.out.println(agent.getErrors());
|
||||
if(!(agent.getErrors()).equals(""))
|
||||
bErrorsOccurred = true;
|
||||
|
||||
if(bErrorsOccurred)
|
||||
{
|
||||
System.err.println("DTI_Error");
|
||||
System.err.println("DTI_DoneExecuting");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("DTI_DoneExecuting");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public interface Apple extends java.rmi.Remote {
|
||||
|
||||
public void notify(AppleEvent[] e) throws java.rmi.RemoteException;
|
||||
|
||||
public Orange newOrange(String name) throws java.rmi.RemoteException;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The AppleEvent class is simply an object to be passed back to a
|
||||
* remote objct exported by an applet to verify proper object
|
||||
* serialization.
|
||||
*/
|
||||
public class AppleEvent implements java.io.Serializable {
|
||||
|
||||
public static final int BUY = 0;
|
||||
public static final int EAT = 1;
|
||||
public static final int THROW = 2;
|
||||
|
||||
private int what;
|
||||
|
||||
private java.util.Date when;
|
||||
|
||||
public AppleEvent(int what)
|
||||
{
|
||||
this.what = what;
|
||||
this.when = new Date();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String desc = "[";
|
||||
switch (what) {
|
||||
case BUY:
|
||||
desc += "BUY";
|
||||
break;
|
||||
case EAT:
|
||||
desc += "EAT";
|
||||
break;
|
||||
case THROW:
|
||||
desc += "THROW";
|
||||
break;
|
||||
}
|
||||
desc += " @ " + when + "]";
|
||||
return desc;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The AppleImpl class implements the behavior of the remote "apple"
|
||||
* objects exported by the application.
|
||||
*/
|
||||
public class AppleImpl
|
||||
extends UnicastRemoteObject
|
||||
implements Apple
|
||||
{
|
||||
|
||||
private static Logger logger = Logger.getLogger("reliability.apple");
|
||||
private String name;
|
||||
|
||||
public AppleImpl(String name) throws RemoteException {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive an array of AppleEvent objects.
|
||||
*/
|
||||
public void notify(AppleEvent[] events) {
|
||||
try {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() + ".notify: BEGIN");
|
||||
|
||||
for (int i = 0; i < events.length; ++ i) {
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".notify(): events[" + i + "] = " +
|
||||
events[i].toString());
|
||||
}
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() + ".notify(): END");
|
||||
} catch (RuntimeException e) {
|
||||
logger.log(Level.SEVERE, toString() + ".notify():", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a newly created and exported orange implementation.
|
||||
*/
|
||||
public Orange newOrange(String name) throws RemoteException {
|
||||
try {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".newOrange(" + name + "): BEGIN");
|
||||
|
||||
Orange orange = new OrangeImpl(name);
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".newOrange(" + name + "): END");
|
||||
|
||||
return orange;
|
||||
} catch (RuntimeException e) {
|
||||
logger.log(Level.SEVERE, toString() + ".newOrange():", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface AppleUser extends Remote {
|
||||
public void startTest() throws RemoteException;
|
||||
public void reportException(Exception status) throws RemoteException;
|
||||
public void useApple(Apple apple) throws RemoteException;
|
||||
}
|
@ -1,317 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2016, 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The AppleUserImpl class implements the behavior of the remote
|
||||
* "apple user" objects exported by the server. The application server
|
||||
* passes each of its remote "apple" objects to an apple user, and an
|
||||
* AppleUserThread is created for each apple.
|
||||
*/
|
||||
public class AppleUserImpl
|
||||
extends UnicastRemoteObject
|
||||
implements AppleUser
|
||||
{
|
||||
private static Logger logger = Logger.getLogger("reliability.appleuser");
|
||||
private static int threadNum = 0;
|
||||
private static long testDuration = 0;
|
||||
private static int maxLevel = 7;
|
||||
private static Thread server = null;
|
||||
private static Exception status = null;
|
||||
private static Random random = new Random();
|
||||
|
||||
public AppleUserImpl() throws RemoteException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the other server process to indicate that it is ready
|
||||
* to start "juicing".
|
||||
*/
|
||||
public synchronized void startTest() throws RemoteException {
|
||||
this.notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the other server process to report an exception to this
|
||||
* process and thereby terminate the test.
|
||||
*/
|
||||
public void reportException(Exception status) throws RemoteException {
|
||||
synchronized (AppleUserImpl.class) {
|
||||
this.status = status;
|
||||
AppleUserImpl.class.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "Use" supplied apple object. Create an AppleUserThread to
|
||||
* stress it out.
|
||||
*/
|
||||
public synchronized void useApple(Apple apple) throws RemoteException {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": AppleUserImpl.useApple(): BEGIN");
|
||||
|
||||
AppleUserThread t =
|
||||
new AppleUserThread("AppleUserThread-" + (++threadNum), apple);
|
||||
t.start();
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": AppleUserImpl.useApple(): END");
|
||||
}
|
||||
|
||||
/**
|
||||
* The AppleUserThread class repeatedly invokes calls on its associated
|
||||
* Apple object to stress the RMI system.
|
||||
*/
|
||||
class AppleUserThread extends Thread {
|
||||
|
||||
Apple apple;
|
||||
|
||||
public AppleUserThread(String name, Apple apple) {
|
||||
super(name);
|
||||
this.apple = apple;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
int orangeNum = 0;
|
||||
long stopTime = System.currentTimeMillis() + testDuration;
|
||||
Logger logger = Logger.getLogger("reliability.appleuserthread");
|
||||
|
||||
try {
|
||||
do { // loop until stopTime is reached
|
||||
|
||||
/*
|
||||
* Notify apple with some apple events. This tests
|
||||
* serialization of arrays.
|
||||
*/
|
||||
int numEvents = Math.abs(random.nextInt() % 5);
|
||||
AppleEvent[] events = new AppleEvent[numEvents];
|
||||
for (int i = 0; i < events.length; ++ i) {
|
||||
events[i] = new AppleEvent(orangeNum % 3);
|
||||
}
|
||||
apple.notify(events);
|
||||
|
||||
/*
|
||||
* Request a new orange object be created in
|
||||
* the application server.
|
||||
*/
|
||||
Orange orange = apple.newOrange(
|
||||
"Orange(" + getName() + ")-" + (++orangeNum));
|
||||
|
||||
/*
|
||||
* Create a large message of random ints to pass to orange.
|
||||
*/
|
||||
int msgLength = 1000 + Math.abs(random.nextInt() % 3000);
|
||||
int[] message = new int[msgLength];
|
||||
for (int i = 0; i < message.length; ++ i) {
|
||||
message[i] = random.nextInt();
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoke recursive call on the orange. Base case
|
||||
* of recursion inverts messgage.
|
||||
*/
|
||||
OrangeEchoImpl echo = new OrangeEchoImpl(
|
||||
"OrangeEcho(" + getName() + ")-" + orangeNum);
|
||||
int[] response = orange.recurse(echo, message,
|
||||
2 + Math.abs(random.nextInt() % (maxLevel + 1)));
|
||||
|
||||
/*
|
||||
* Verify message was properly inverted and not corrupted
|
||||
* through all the recursive method invocations.
|
||||
*/
|
||||
if (response.length != message.length) {
|
||||
throw new RuntimeException(
|
||||
"ERROR: CORRUPTED RESPONSE: " +
|
||||
"wrong length of returned array " + "(should be " +
|
||||
message.length + ", is " + response.length + ")");
|
||||
}
|
||||
for (int i = 0; i < message.length; ++ i) {
|
||||
if (~message[i] != response[i]) {
|
||||
throw new RuntimeException(
|
||||
"ERROR: CORRUPTED RESPONSE: " +
|
||||
"at element " + i + "/" + message.length +
|
||||
" of returned array (should be " +
|
||||
Integer.toHexString(~message[i]) + ", is " +
|
||||
Integer.toHexString(response[i]) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(Math.abs(random.nextInt() % 10) * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
} while (System.currentTimeMillis() < stopTime);
|
||||
|
||||
} catch (Exception e) {
|
||||
status = e;
|
||||
}
|
||||
synchronized (AppleUserImpl.class) {
|
||||
AppleUserImpl.class.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Usage: AppleUserImpl [-hours <hours> | " +
|
||||
"-seconds <seconds>]");
|
||||
System.out.println(" [-maxLevel <maxLevel>]");
|
||||
System.out.println(" hours The number of hours to run the juicer.");
|
||||
System.out.println(" The default is 0 hours.");
|
||||
System.out.println(" seconds The number of seconds to run the juicer.");
|
||||
System.out.println(" The default is 0 seconds.");
|
||||
System.out.println(" maxLevel The maximum number of levels to ");
|
||||
System.out.println(" recurse on each call.");
|
||||
System.out.println(" The default is 7 levels.");
|
||||
//TestLibrary.bomb("Bad argument");
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for the "juicer" server process. Create and export
|
||||
* an apple user implementation in an rmiregistry running on localhost.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
|
||||
{
|
||||
//TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
|
||||
long startTime = 0;
|
||||
String durationString = null;
|
||||
|
||||
// parse command line args
|
||||
try {
|
||||
for (int i = 0; i < args.length ; i++ ) {
|
||||
String arg = args[i];
|
||||
if (arg.equals("-hours")) {
|
||||
if (durationString != null) {
|
||||
usage();
|
||||
}
|
||||
i++;
|
||||
int hours = Integer.parseInt(args[i]);
|
||||
durationString = hours + " hours";
|
||||
testDuration = hours * 60 * 60 * 1000;
|
||||
} else if (arg.equals("-seconds")) {
|
||||
if (durationString != null) {
|
||||
usage();
|
||||
}
|
||||
i++;
|
||||
long seconds = Long.parseLong(args[i]);
|
||||
durationString = seconds + " seconds";
|
||||
testDuration = seconds * 1000;
|
||||
} else if (arg.equals("-maxLevel")) {
|
||||
i++;
|
||||
maxLevel = Integer.parseInt(args[i]);
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
if (durationString == null) {
|
||||
durationString = testDuration + " milliseconds";
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
usage();
|
||||
}
|
||||
|
||||
AppleUserImpl user = null;
|
||||
try {
|
||||
user = new AppleUserImpl();
|
||||
} catch (RemoteException e) {
|
||||
//TestLibrary.bomb("Failed to create AppleUser", e);
|
||||
}
|
||||
|
||||
synchronized (user) {
|
||||
int port = -1;
|
||||
// create new registry and bind new AppleUserImpl in registry
|
||||
try {
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
port = TestLibrary.getRegistryPort(registry);
|
||||
Naming.rebind("rmi://localhost:" + port + "/AppleUser",user);
|
||||
} catch (RemoteException e) {
|
||||
//TestLibrary.bomb("Failed to bind AppleUser", e);
|
||||
} catch (java.net.MalformedURLException e) {
|
||||
//TestLibrary.bomb("Failed to bind AppleUser", e);
|
||||
}
|
||||
|
||||
// start the other server if available
|
||||
try {
|
||||
Class app = Class.forName("ApplicationServer");
|
||||
java.lang.reflect.Constructor appConstructor =
|
||||
app.getDeclaredConstructor(new Class[] {Integer.TYPE});
|
||||
server = new Thread((Runnable) appConstructor.newInstance(port));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// assume the other server is running in a separate process
|
||||
logger.log(Level.INFO, "Application server must be " +
|
||||
"started in separate process");
|
||||
} catch (Exception ie) {
|
||||
//TestLibrary.bomb("Could not instantiate server", ie);
|
||||
}
|
||||
|
||||
// wait for other server to call startTest method
|
||||
try {
|
||||
logger.log(Level.INFO, "Waiting for application server " +
|
||||
"process to start");
|
||||
user.wait();
|
||||
} catch (InterruptedException ie) {
|
||||
//TestLibrary.bomb("AppleUserImpl interrupted", ie);
|
||||
}
|
||||
}
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
logger.log(Level.INFO, "Test starting");
|
||||
|
||||
// wait for exception to be reported or first thread to complete
|
||||
try {
|
||||
logger.log(Level.INFO, "Waiting " + durationString + " for " +
|
||||
"test to complete or exception to be thrown");
|
||||
|
||||
synchronized (AppleUserImpl.class) {
|
||||
AppleUserImpl.class.wait();
|
||||
}
|
||||
|
||||
if (status != null) {
|
||||
//TestLibrary.bomb("juicer server reported an exception", status);
|
||||
} else {
|
||||
logger.log(Level.INFO, "TEST PASSED");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.INFO, "TEST FAILED");
|
||||
//TestLibrary.bomb("unexpected exception", e);
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Test finished");
|
||||
long actualDuration = System.currentTimeMillis() - startTime;
|
||||
logger.log(Level.INFO, "Test duration was " +
|
||||
(actualDuration/1000) + " seconds " +
|
||||
"(" + (actualDuration/3600000) + " hours)");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.registry.*;
|
||||
import java.rmi.server.*;
|
||||
|
||||
|
||||
|
||||
public interface Callback extends Remote
|
||||
{
|
||||
void callback() throws RemoteException;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
|
||||
/**
|
||||
* Remote interface for the Compute Server
|
||||
*/
|
||||
public interface ComputeServer extends Remote {
|
||||
|
||||
/**
|
||||
* Called by the task and passes itself as an object
|
||||
*/
|
||||
Object compute(Task task) throws RemoteException;
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.server.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Class accepts a task and runs it in its own space.
|
||||
*/
|
||||
public class ComputeServerImpl
|
||||
extends UnicastRemoteObject
|
||||
implements ComputeServer
|
||||
{
|
||||
public ComputeServerImpl() throws RemoteException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts task and runs it
|
||||
*/
|
||||
public Object compute(Task task) {
|
||||
return task.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds compute server and waits for tasks
|
||||
*/
|
||||
public static void main(String args[]) throws Exception
|
||||
{
|
||||
// use the default, restrictive security manager
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
|
||||
Naming.rebind("/ComputeServer", new ComputeServerImpl());
|
||||
System.out.println("Ready to receive tasks.");
|
||||
|
||||
System.err.println("DTI_DoneInitializing");
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
|
||||
// CountInterface
|
||||
|
||||
public interface CountInterface extends Remote {
|
||||
|
||||
public void ping() throws RemoteException;
|
||||
|
||||
public int incrementCount() throws RemoteException;
|
||||
|
||||
public int decrementCount() throws RemoteException;
|
||||
|
||||
public int getCount() throws RemoteException;
|
||||
|
||||
public int getClassCount() throws RemoteException;
|
||||
|
||||
public String getProperty(String s) throws RemoteException;
|
||||
|
||||
public void exit() throws RemoteException;
|
||||
|
||||
// Methods specific to dealing with activatable objects
|
||||
|
||||
public boolean unexportObject(boolean b) throws RemoteException;
|
||||
|
||||
public ActivationID getActivationID() throws RemoteException;
|
||||
|
||||
public ActivationGroupID getCurrentGroupID() throws RemoteException;
|
||||
|
||||
public void inactive()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
|
||||
public void register()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
|
||||
public void unregister()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.server.*;
|
||||
import java.rmi.activation.*;
|
||||
import java.util.*;
|
||||
|
||||
// CountServerImpl
|
||||
|
||||
public class CountServerImpl
|
||||
extends Activatable
|
||||
implements CountInterface {
|
||||
|
||||
private static final String PROG_NAME = "CountServerImpl";
|
||||
private static final String SERVER_OBJECT = "CountServer";
|
||||
private static final String CLASS_NAME = "activation.CountServerImpl";
|
||||
|
||||
private static final String POLICY_FILE = "policy_file";
|
||||
|
||||
private static final String USER_DIR =
|
||||
System.getProperty("user.dir").replace('\\', '/');
|
||||
|
||||
private static final String CODE_LOCATION = "file:"+USER_DIR+"/";
|
||||
|
||||
private static final MarshalledObject DATA = null;
|
||||
private static ActivationDesc ACTIVATION_DESC = null;
|
||||
|
||||
// Class variable
|
||||
private static int classCount = 0;
|
||||
|
||||
// Instance variable
|
||||
private int instanceCount;
|
||||
private TestInterface ref;
|
||||
|
||||
public CountServerImpl(ActivationID id, MarshalledObject data)
|
||||
throws RemoteException {
|
||||
super(id, 0);
|
||||
instanceCount = 0;
|
||||
classCount++;
|
||||
if (data != null) {
|
||||
try {
|
||||
ref = (TestInterface)data.get();
|
||||
ref.ping(SERVER_OBJECT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ping() throws RemoteException {}
|
||||
|
||||
public int getCount() throws RemoteException {
|
||||
return instanceCount;
|
||||
}
|
||||
|
||||
public int incrementCount() throws RemoteException {
|
||||
return ++instanceCount;
|
||||
}
|
||||
|
||||
public int decrementCount() throws RemoteException {
|
||||
return --instanceCount;
|
||||
}
|
||||
|
||||
public int getClassCount() throws RemoteException {
|
||||
return classCount;
|
||||
}
|
||||
|
||||
public String getProperty(String s) throws RemoteException {
|
||||
return System.getProperty(s);
|
||||
}
|
||||
|
||||
public void exit() throws RemoteException {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public boolean unexportObject(boolean force) {
|
||||
boolean succeeded = false;
|
||||
try {
|
||||
succeeded = Activatable.unexportObject(this, force);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
public ActivationID getActivationID() throws RemoteException {
|
||||
return super.getID();
|
||||
}
|
||||
|
||||
public void inactive()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
|
||||
//ShutDown s = new ShutDown(super.getID(),this,ShutDown.NORMAL_SHUTDOWN);
|
||||
}
|
||||
|
||||
public void unregister()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
unregister(super.getID());
|
||||
}
|
||||
|
||||
public void register()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
register(ACTIVATION_DESC);
|
||||
}
|
||||
|
||||
public ActivationGroupID getCurrentGroupID() throws RemoteException {
|
||||
return ActivationGroup.currentGroupID();
|
||||
}
|
||||
|
||||
private static void setup() {
|
||||
|
||||
try {
|
||||
|
||||
CountInterface rsi; // Remote server interface
|
||||
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
|
||||
rsi = (CountInterface)Activatable.register(ACTIVATION_DESC);
|
||||
System.out.println("Got stub for "+SERVER_OBJECT+" implementation");
|
||||
|
||||
Naming.rebind(SERVER_OBJECT, rsi);
|
||||
System.out.println("Exported "+SERVER_OBJECT+" implementation");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("java.security.policy", POLICY_FILE);
|
||||
|
||||
ActivationGroupDesc agd = new ActivationGroupDesc(props, null);
|
||||
|
||||
ActivationGroupID agid = ActivationGroup.getSystem().registerGroup(agd);
|
||||
|
||||
ACTIVATION_DESC = new ActivationDesc(agid,
|
||||
CLASS_NAME, CODE_LOCATION, DATA, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
setup();
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
|
||||
// DayTimeInterface
|
||||
|
||||
public interface DayTimeInterface extends Remote {
|
||||
|
||||
public void ping() throws RemoteException;
|
||||
|
||||
public java.util.Date getDayTime() throws java.rmi.RemoteException;
|
||||
|
||||
public void exit() throws RemoteException;
|
||||
|
||||
public ActivationID getActivationID() throws RemoteException;
|
||||
|
||||
public ActivationGroupID getCurrentGroupID() throws RemoteException;
|
||||
|
||||
public void inactive()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
|
||||
public void register()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
|
||||
public void unregister()
|
||||
throws RemoteException, UnknownObjectException, ActivationException;
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
import java.util.*;
|
||||
|
||||
// DayTimeServerImpl
|
||||
|
||||
public class DayTimeServerImpl
|
||||
extends Activatable
|
||||
implements DayTimeInterface {
|
||||
|
||||
private static final String PROG_NAME = "DayTimeServerImpl";
|
||||
private static final String SERVER_OBJECT = "DayTimeServer";
|
||||
private static final String CLASS_NAME = "activation.DayTimeServerImpl";
|
||||
|
||||
private static final String POLICY_FILE = "policy_file";
|
||||
|
||||
private static final String USER_DIR =
|
||||
System.getProperty("user.dir").replace('\\', '/');
|
||||
|
||||
private static final String CODE_LOCATION = "file:"+USER_DIR+"/";
|
||||
|
||||
private static final MarshalledObject DATA = null;
|
||||
private static ActivationDesc ACTIVATION_DESC = null;
|
||||
|
||||
private TestInterface ref;
|
||||
|
||||
public void ping() throws RemoteException {}
|
||||
|
||||
public ActivationID getActivationID() throws RemoteException {
|
||||
return super.getID();
|
||||
}
|
||||
|
||||
public DayTimeServerImpl(ActivationID id, MarshalledObject data)
|
||||
throws RemoteException {
|
||||
super(id, 0);
|
||||
if (data != null) {
|
||||
try {
|
||||
ref = (TestInterface)data.get();
|
||||
ref.ping(SERVER_OBJECT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Date getDayTime() throws RemoteException {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public void exit() throws RemoteException {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void inactive()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
|
||||
//ShutDown s = new ShutDown(super.getID(),this,ShutDown.NORMAL_SHUTDOWN);
|
||||
}
|
||||
|
||||
public void unregister()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
unregister(super.getID());
|
||||
}
|
||||
|
||||
public void register()
|
||||
throws RemoteException, ActivationException, UnknownObjectException {
|
||||
register(ACTIVATION_DESC);
|
||||
}
|
||||
|
||||
public ActivationGroupID getCurrentGroupID() throws RemoteException {
|
||||
return ActivationGroup.currentGroupID();
|
||||
}
|
||||
|
||||
private static void setup() {
|
||||
|
||||
try {
|
||||
|
||||
DayTimeInterface rsi; // Remote server interface
|
||||
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
|
||||
rsi = (DayTimeInterface)Activatable.register(ACTIVATION_DESC);
|
||||
System.out.println("Got stub for "+SERVER_OBJECT+" implementation");
|
||||
|
||||
Naming.rebind(SERVER_OBJECT, rsi);
|
||||
System.out.println("Exported "+SERVER_OBJECT+" implementation");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("java.security.policy", POLICY_FILE);
|
||||
|
||||
ActivationGroupDesc agd = new ActivationGroupDesc(props, null);
|
||||
|
||||
ActivationGroupID agid = ActivationGroup.getSystem().registerGroup(agd);
|
||||
|
||||
ACTIVATION_DESC = new ActivationDesc(agid,
|
||||
CLASS_NAME, CODE_LOCATION, DATA, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
setup();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface G1 extends Remote {
|
||||
void m() throws RemoteException;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class G1Impl implements G1 {
|
||||
public void m() { }
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
|
||||
public interface MyObject extends Remote {
|
||||
public void method1(MyObject obj) throws RemoteException;
|
||||
|
||||
public void method2(MyObject[] objs) throws RemoteException;
|
||||
|
||||
public void method3() throws RemoteException;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.server.*;
|
||||
|
||||
public class MyObjectImpl extends UnicastRemoteObject implements MyObject {
|
||||
private int clientNum = -1;
|
||||
private byte[] data = null;
|
||||
//private MyObjectFactory mof = null;
|
||||
private boolean AliveMyObjectsCounterWasIncremented = false;
|
||||
|
||||
public MyObjectImpl() throws RemoteException {
|
||||
super();
|
||||
}
|
||||
|
||||
public MyObjectImpl(int c, int size) //MyObjectFactory mof, int c, int size)
|
||||
throws RemoteException {
|
||||
super();
|
||||
//this.mof = mof;
|
||||
this.clientNum = c;
|
||||
this.data = new byte[size];
|
||||
//mof.incAliveMyObjects(1);
|
||||
AliveMyObjectsCounterWasIncremented = true;
|
||||
}
|
||||
|
||||
public void method1(MyObject obj) throws RemoteException {
|
||||
}
|
||||
|
||||
public void method2(MyObject[] objs) throws RemoteException {
|
||||
}
|
||||
|
||||
public void method3() throws RemoteException {
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
if(AliveMyObjectsCounterWasIncremented)
|
||||
; //mof.decAliveMyObjects(1);
|
||||
super.finalize();
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
// NotActivatableInterface
|
||||
|
||||
public interface NotActivatableInterface extends java.rmi.Remote {
|
||||
|
||||
public void ping() throws java.rmi.RemoteException;
|
||||
|
||||
public void exit() throws java.rmi.RemoteException;
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
import java.rmi.server.*;
|
||||
import java.util.*;
|
||||
|
||||
// NotActivatableServerImpl
|
||||
|
||||
public class NotActivatableServerImpl
|
||||
extends UnicastRemoteObject
|
||||
implements NotActivatableInterface {
|
||||
|
||||
private static final String PROG_NAME = "NotActivatableServerImpl";
|
||||
private static final String SERVER_OBJECT = "NotActivatableServer";
|
||||
private static final String CLASS_NAME = "activation.NotActivatableServerImpl";
|
||||
|
||||
private static final String POLICY_FILE = "policy_file";
|
||||
|
||||
private static final String USER_DIR =
|
||||
System.getProperty("user.dir").replace('\\', '/');
|
||||
|
||||
private static final String CODE_LOCATION = "file:"+USER_DIR+"/";
|
||||
|
||||
private static final MarshalledObject DATA = null;
|
||||
private static ActivationDesc ACTIVATION_DESC = null;
|
||||
|
||||
public NotActivatableServerImpl() throws RemoteException {}
|
||||
|
||||
public void ping() throws RemoteException {}
|
||||
|
||||
public void exit() throws RemoteException {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static void setup() {
|
||||
|
||||
try {
|
||||
|
||||
NotActivatableInterface rsi; // Remote server interface
|
||||
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
|
||||
rsi = (NotActivatableInterface)Activatable.register(ACTIVATION_DESC);
|
||||
System.out.println("Got stub for "+SERVER_OBJECT+" implementation");
|
||||
|
||||
Naming.rebind(SERVER_OBJECT, rsi);
|
||||
System.out.println("Exported "+SERVER_OBJECT+" implementation");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("java.security.policy", POLICY_FILE);
|
||||
|
||||
ActivationGroupDesc agd = new ActivationGroupDesc(props, null);
|
||||
|
||||
ActivationGroupID agid = ActivationGroup.getSystem().registerGroup(agd);
|
||||
|
||||
ACTIVATION_DESC = new ActivationDesc(agid,
|
||||
CLASS_NAME, CODE_LOCATION, DATA, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
setup();
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public interface Orange extends java.rmi.Remote {
|
||||
|
||||
public int[] recurse(OrangeEcho echo, int[] message, int level)
|
||||
throws java.rmi.RemoteException;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public interface OrangeEcho extends java.rmi.Remote {
|
||||
|
||||
public int[] recurse(Orange orange, int[] message, int level)
|
||||
throws java.rmi.RemoteException;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The OrangeEchoImpl class implements the behavior of the remote "orange
|
||||
* echo" objects exported by the server. The purpose of these objects
|
||||
* is simply to recursively call back to their caller.
|
||||
*/
|
||||
public class OrangeEchoImpl
|
||||
extends UnicastRemoteObject
|
||||
implements OrangeEcho
|
||||
{
|
||||
|
||||
private static Logger logger = Logger.getLogger("reliability.orangeecho");
|
||||
String name;
|
||||
|
||||
public OrangeEchoImpl(String name) throws RemoteException {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call back on supplied "orange" object (presumably the caller)
|
||||
* with the same message data and a decremented recursion level.
|
||||
*/
|
||||
public int[] recurse(Orange orange, int[] message, int level)
|
||||
throws RemoteException
|
||||
{
|
||||
String threadName = Thread.currentThread().getName();
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".recurse(message[" + message.length + "], " +
|
||||
level + "): BEGIN");
|
||||
|
||||
int[] response = orange.recurse(this, message, level - 1);
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".recurse(message[" + message.length + "], " +
|
||||
level + "): END");
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The OrangeImpl class implements the behavior of the remote "orange"
|
||||
* objects exported by the appplication.
|
||||
*/
|
||||
public class OrangeImpl
|
||||
extends UnicastRemoteObject
|
||||
implements Orange
|
||||
{
|
||||
|
||||
private static Logger logger = Logger.getLogger("reliability.orange");
|
||||
private String name;
|
||||
|
||||
public OrangeImpl(String name) throws RemoteException {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return inverted message data, call through supplied OrangeEcho
|
||||
* object if not at recursion level zero.
|
||||
*/
|
||||
public int[] recurse(OrangeEcho echo, int[] message, int level)
|
||||
throws RemoteException
|
||||
{
|
||||
try {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".recurse(message[" + message.length + "], " +
|
||||
level + "): BEGIN");
|
||||
|
||||
int[] response;
|
||||
if (level > 0)
|
||||
response = echo.recurse(this, message, level);
|
||||
else {
|
||||
for (int i = 0; i < message.length; ++ i)
|
||||
message[i] = ~message[i];
|
||||
response = message;
|
||||
}
|
||||
|
||||
logger.log(Level.FINEST,
|
||||
threadName + ": " + toString() +
|
||||
".recurse(message[" + message.length + "], " +
|
||||
level + "): END");
|
||||
|
||||
return response;
|
||||
} catch (RuntimeException e) {
|
||||
logger.log(Level.SEVERE, toString() + ".recurse():", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.registry.*;
|
||||
import java.rmi.server.*;
|
||||
|
||||
|
||||
|
||||
public interface Server extends Remote
|
||||
{
|
||||
public String sayHello(Callback c) throws RemoteException;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.rmi.*;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
|
||||
public class ServerImpl
|
||||
extends UnicastRemoteObject
|
||||
implements Server
|
||||
{
|
||||
private String name;
|
||||
Callback cLocal;
|
||||
|
||||
public ServerImpl(String s) throws java.rmi.RemoteException {
|
||||
super();
|
||||
name = s;
|
||||
}
|
||||
|
||||
public String sayHello(Callback c) throws RemoteException {
|
||||
System.out.println("Calling Callback method from the ServerImpl");
|
||||
cLocal = c;
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(
|
||||
"+ running a new thread in sayHello method!");
|
||||
try {
|
||||
cLocal.callback();
|
||||
} catch(RemoteException e) {
|
||||
System.out.println(
|
||||
"ServerImpl.main: exception while calling callback " +
|
||||
"method:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
return "Hello Callback!";
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
// Create and install the security manager
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
|
||||
ServerImpl obj = null;
|
||||
|
||||
try {
|
||||
obj = new ServerImpl("ServerImpl");
|
||||
Naming.rebind("/ServerImpl", obj);
|
||||
System.out.println("ServerImpl created and bound in the registry" +
|
||||
" to the name ServerImpl");
|
||||
System.err.println("DTI_DoneInitializing");
|
||||
} catch (Exception e) {
|
||||
System.out.println("ServerImpl.main: an exception occurred:");
|
||||
e.printStackTrace();
|
||||
System.err.println("DTI_Error");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface Task that must be serializable so that the task can be
|
||||
* passed to the compute server.
|
||||
*/
|
||||
public interface Task extends java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Called by compute server and returns an object.
|
||||
*/
|
||||
Object run();
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// RMI Activation Functional Test
|
||||
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
|
||||
// TestInterface
|
||||
|
||||
public interface TestInterface extends Remote {
|
||||
|
||||
public void ping(String s) throws RemoteException;
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 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.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#
|
||||
# Usage: batch.sh classpath classes...
|
||||
#
|
||||
|
||||
if [ $# -lt 2 ]
|
||||
then
|
||||
echo "Usage: `basename $0` classpath classes..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
refv11dir=./ref-v1.1-output
|
||||
refvcompatdir=./ref-vcompat-output
|
||||
refv12dir=./ref-v1.2-output
|
||||
|
||||
newv11dir=./new-v1.1-output
|
||||
newvcompatdir=./new-vcompat-output
|
||||
newv12dir=./new-v1.2-output
|
||||
|
||||
v11diffs=./diffs-v1.1
|
||||
vcompatdiffs=./diffs-vcompat
|
||||
v12diffs=./diffs-v1.2
|
||||
|
||||
difflines=./diff-lines
|
||||
|
||||
rm -rf $refv11dir $refvcompatdir $refv12dir
|
||||
rm -rf $newv11dir $newvcompatdir $newv12dir
|
||||
rm -f $v11diffs $vcompatdiffs $v12diffs $difflines
|
||||
|
||||
mkdir $refv11dir $refvcompatdir $refv12dir
|
||||
mkdir $newv11dir $newvcompatdir $newv12dir
|
||||
|
||||
set -ex
|
||||
|
||||
${TESTJAVA}/bin/rmic -keep -nowrite -v1.1 -d $refv11dir -classpath "$@"
|
||||
${TESTJAVA}/bin/rmic -keep -nowrite -vcompat -d $refvcompatdir -classpath "$@"
|
||||
${TESTJAVA}/bin/rmic -keep -nowrite -v1.2 -d $refv12dir -classpath "$@"
|
||||
|
||||
${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -v1.1 -d $newv11dir -classpath "$@"
|
||||
${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -vcompat -d $newvcompatdir -classpath "$@"
|
||||
${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -v1.2 -d $newv12dir -classpath "$@"
|
||||
|
||||
set +ex
|
||||
|
||||
diff -r $refv11dir $newv11dir > $v11diffs
|
||||
diff -r $refvcompatdir $newvcompatdir > $vcompatdiffs
|
||||
diff -r $refv12dir $newv12dir > $v12diffs
|
||||
|
||||
cat $v11diffs $vcompatdiffs $v12diffs | grep '^[<>O]' | fgrep -v ' server = (' > $difflines
|
||||
|
||||
if [ `cat $difflines | wc -l` -gt 0 ]
|
||||
then
|
||||
cat $v11diffs $vcompatdiffs $v12diffs
|
||||
echo "TEST FAILED: unexpected diffs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "TEST PASSED: new rmic output identical to reference rmic output"
|
||||
|
||||
rm -rf $refv11dir $refvcompatdir $refv12dir
|
||||
rm -rf $newv11dir $newvcompatdir $newv12dir
|
||||
rm -f $v11diffs $vcompatdiffs $v12diffs $difflines
|
@ -1,86 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2003, 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.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @ignore test is disabled, while further discussion on the rmic -Xnew feature
|
||||
# takes place (c.f JDK-8146299, JDK-8145980).
|
||||
# @bug 4911536
|
||||
# @summary This test verifies that the new implementation of rmic
|
||||
# generates equivalent classes as the old implementation, for a set
|
||||
# of sample input classes.
|
||||
# @author Peter Jones
|
||||
#
|
||||
# @library ../../../../../java/rmi/testlibrary
|
||||
#
|
||||
# @build TestLibrary
|
||||
# AgentServerImpl
|
||||
# AppleImpl
|
||||
# AppleUserImpl
|
||||
# ComputeServerImpl
|
||||
# CountServerImpl
|
||||
# DayTimeServerImpl
|
||||
# G1Impl
|
||||
# MyObjectImpl
|
||||
# NotActivatableServerImpl
|
||||
# OrangeEchoImpl
|
||||
# OrangeImpl
|
||||
# ServerImpl
|
||||
#
|
||||
# @run shell run.sh
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -ex
|
||||
|
||||
#
|
||||
# miscellaneous remote classes collected from other tests
|
||||
#
|
||||
|
||||
sh ${TESTSRC:-.}/batch.sh ${TESTCLASSES:-.} \
|
||||
AgentServerImpl \
|
||||
AppleImpl \
|
||||
AppleUserImpl \
|
||||
ComputeServerImpl \
|
||||
CountServerImpl \
|
||||
DayTimeServerImpl \
|
||||
G1Impl \
|
||||
MyObjectImpl \
|
||||
NotActivatableServerImpl \
|
||||
OrangeEchoImpl \
|
||||
OrangeImpl \
|
||||
ServerImpl
|
||||
|
||||
#
|
||||
# remote classes in the J2SE implementation
|
||||
#
|
||||
|
||||
sh ${TESTSRC:-.}/batch.sh ${TESTCLASSES:-.} \
|
||||
sun.rmi.registry.RegistryImpl \
|
||||
sun.rmi.server.Activation\$ActivationMonitorImpl \
|
||||
sun.rmi.server.Activation\$ActivationSystemImpl \
|
||||
sun.rmi.server.Activation\$ActivatorImpl \
|
||||
java.rmi.activation.ActivationGroup
|
Loading…
Reference in New Issue
Block a user