feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
205
jdkSrc/jdk8/sun/rmi/rmic/iiop/AbstractType.java
Normal file
205
jdkSrc/jdk8/sun/rmi/rmic/iiop/AbstractType.java
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* AbstractType represents any non-special interface which does not
|
||||
* inherit from java.rmi.Remote, for which all methods throw RemoteException.
|
||||
* <p>
|
||||
* The static forAbstract(...) method must be used to obtain an instance, and will
|
||||
* return null if the ClassDefinition is non-conforming.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class AbstractType extends RemoteType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an AbstractType for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static AbstractType forAbstract(ClassDefinition classDef,
|
||||
ContextStack stack,
|
||||
boolean quiet)
|
||||
{
|
||||
boolean doPop = false;
|
||||
AbstractType result = null;
|
||||
|
||||
try {
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
Type existing = getType(theType,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof AbstractType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (AbstractType) existing;
|
||||
|
||||
}
|
||||
|
||||
// Could this be an abstract?
|
||||
|
||||
if (couldBeAbstract(stack,classDef,quiet)) {
|
||||
|
||||
// Yes, so try it...
|
||||
|
||||
AbstractType it = new AbstractType(stack, classDef);
|
||||
putType(theType,it,stack);
|
||||
stack.push(it);
|
||||
doPop = true;
|
||||
|
||||
if (it.initialize(quiet,stack)) {
|
||||
stack.pop(true);
|
||||
result = it;
|
||||
} else {
|
||||
removeType(theType,stack);
|
||||
stack.pop(false);
|
||||
}
|
||||
}
|
||||
} catch (CompilerError e) {
|
||||
if (doPop) stack.pop(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Abstract interface";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal/Subclass Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a AbstractType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private AbstractType(ContextStack stack, ClassDefinition classDef) {
|
||||
super(stack,classDef,TYPE_ABSTRACT | TM_INTERFACE | TM_COMPOUND);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
|
||||
private static boolean couldBeAbstract(ContextStack stack, ClassDefinition classDef,
|
||||
boolean quiet) {
|
||||
|
||||
// Return true if interface and not remote...
|
||||
|
||||
boolean result = false;
|
||||
|
||||
if (classDef.isInterface()) {
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
|
||||
try {
|
||||
result = ! env.defRemote.implementedBy(env, classDef.getClassDeclaration());
|
||||
if (!result) failedConstraint(15,quiet,stack,classDef.getName());
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
} else {
|
||||
failedConstraint(14,quiet,stack,classDef.getName());
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (boolean quiet,ContextStack stack) {
|
||||
|
||||
boolean result = false;
|
||||
ClassDefinition self = getClassDefinition();
|
||||
|
||||
try {
|
||||
|
||||
// Get methods...
|
||||
|
||||
Vector directMethods = new Vector();
|
||||
|
||||
if (addAllMethods(self,directMethods,true,quiet,stack) != null) {
|
||||
|
||||
// Do we have any methods?
|
||||
|
||||
boolean validMethods = true;
|
||||
|
||||
if (directMethods.size() > 0) {
|
||||
|
||||
// Yes. Walk 'em, ensuring each is a valid remote method...
|
||||
|
||||
for (int i = 0; i < directMethods.size(); i++) {
|
||||
|
||||
if (! isConformingRemoteMethod((Method) directMethods.elementAt(i),true)) {
|
||||
validMethods = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (validMethods) {
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
result = initialize(null,directMethods,null,stack,quiet);
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
270
jdkSrc/jdk8/sun/rmi/rmic/iiop/ArrayType.java
Normal file
270
jdkSrc/jdk8/sun/rmi/rmic/iiop/ArrayType.java
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.HashSet;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
/**
|
||||
* ArrayType is a wrapper for any of the other types. The getElementType()
|
||||
* method can be used to get the array element type. The getArrayDimension()
|
||||
* method can be used to get the array dimension.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class ArrayType extends Type {
|
||||
|
||||
private Type type;
|
||||
private int arrayDimension;
|
||||
private String brackets;
|
||||
private String bracketsSig;
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an ArrayType object for the given type.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static ArrayType forArray( sun.tools.java.Type theType,
|
||||
ContextStack stack) {
|
||||
|
||||
|
||||
ArrayType result = null;
|
||||
sun.tools.java.Type arrayType = theType;
|
||||
|
||||
if (arrayType.getTypeCode() == TC_ARRAY) {
|
||||
|
||||
// Find real type...
|
||||
|
||||
while (arrayType.getTypeCode() == TC_ARRAY) {
|
||||
arrayType = arrayType.getElementType();
|
||||
}
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
Type existing = getType(theType,stack);
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof ArrayType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (ArrayType) existing;
|
||||
}
|
||||
|
||||
// Now try to make a Type from it...
|
||||
|
||||
Type temp = CompoundType.makeType(arrayType,null,stack);
|
||||
|
||||
if (temp != null) {
|
||||
|
||||
// Got a valid one. Make an array type...
|
||||
|
||||
result = new ArrayType(stack,temp,theType.getArrayDimension());
|
||||
|
||||
// Add it...
|
||||
|
||||
putType(theType,result,stack);
|
||||
|
||||
// Do the stack thing in case tracing on...
|
||||
|
||||
stack.push(result);
|
||||
stack.pop(true);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return signature for this type (e.g. com.acme.Dynamite
|
||||
* would return "com.acme.Dynamite", byte = "B")
|
||||
*/
|
||||
public String getSignature() {
|
||||
return bracketsSig + type.getSignature();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element type. Returns null if not an array.
|
||||
*/
|
||||
public Type getElementType () {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array dimension. Returns zero if not an array.
|
||||
*/
|
||||
public int getArrayDimension () {
|
||||
return arrayDimension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get brackets string. Returns "" if not an array.
|
||||
*/
|
||||
public String getArrayBrackets () {
|
||||
return brackets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of this type.
|
||||
*/
|
||||
public String toString () {
|
||||
return getQualifiedName() + brackets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Array of " + type.getTypeDescription();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of this type. For arrays, will include "[]" if useIDLNames == false.
|
||||
* @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names.
|
||||
* @param useIDLNames If true, print IDL names; otherwise, print java names.
|
||||
* @param globalIDLNames If true and useIDLNames true, prepends "::".
|
||||
*/
|
||||
public String getTypeName ( boolean useQualifiedNames,
|
||||
boolean useIDLNames,
|
||||
boolean globalIDLNames) {
|
||||
if (useIDLNames) {
|
||||
return super.getTypeName(useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
} else {
|
||||
return super.getTypeName(useQualifiedNames,useIDLNames,globalIDLNames) + brackets;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
|
||||
/**
|
||||
* Convert all invalid types to valid ones.
|
||||
*/
|
||||
protected void swapInvalidTypes () {
|
||||
if (type.getStatus() != STATUS_VALID) {
|
||||
type = getValidType(type);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add matching types to list. Return true if this type has not
|
||||
* been previously checked, false otherwise.
|
||||
*/
|
||||
protected boolean addTypes (int typeCodeFilter,
|
||||
HashSet checked,
|
||||
Vector matching) {
|
||||
|
||||
// Check self.
|
||||
|
||||
boolean result = super.addTypes(typeCodeFilter,checked,matching);
|
||||
|
||||
// Have we been checked before?
|
||||
|
||||
if (result) {
|
||||
|
||||
// No, so add element type...
|
||||
|
||||
getElementType().addTypes(typeCodeFilter,checked,matching);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ArrayType instance for the given type. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private ArrayType(ContextStack stack, Type type, int arrayDimension) {
|
||||
super(stack,TYPE_ARRAY);
|
||||
this.type = type;
|
||||
this.arrayDimension = arrayDimension;
|
||||
|
||||
// Create our brackets string...
|
||||
|
||||
brackets = "";
|
||||
bracketsSig = "";
|
||||
for (int i = 0; i < arrayDimension; i ++) {
|
||||
brackets += "[]";
|
||||
bracketsSig += "[";
|
||||
}
|
||||
|
||||
// Now set our names...
|
||||
|
||||
String idlName = IDLNames.getArrayName(type,arrayDimension);
|
||||
String[] module = IDLNames.getArrayModuleNames(type);
|
||||
setNames(type.getIdentifier(),module,idlName);
|
||||
|
||||
// Set our repositoryID...
|
||||
|
||||
setRepositoryID();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load a Class instance. Return null if fail.
|
||||
*/
|
||||
protected Class loadClass() {
|
||||
Class result = null;
|
||||
Class elementClass = type.getClassInstance();
|
||||
if (elementClass != null) {
|
||||
result = Array.newInstance(elementClass, new int[arrayDimension]).getClass();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release all resources
|
||||
*/
|
||||
protected void destroy () {
|
||||
super.destroy();
|
||||
if (type != null) {
|
||||
type.destroy();
|
||||
type = null;
|
||||
}
|
||||
brackets = null;
|
||||
bracketsSig = null;
|
||||
}
|
||||
}
|
||||
260
jdkSrc/jdk8/sun/rmi/rmic/iiop/BatchEnvironment.java
Normal file
260
jdkSrc/jdk8/sun/rmi/rmic/iiop/BatchEnvironment.java
Normal file
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.rmi.rmic.Main;
|
||||
import sun.tools.java.ClassPath;
|
||||
import java.io.OutputStream;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.tools.java.ClassDeclaration;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* BatchEnvironment for iiop extends rmic's version to add
|
||||
* parse state.
|
||||
*/
|
||||
public class BatchEnvironment extends sun.rmi.rmic.BatchEnvironment implements Constants {
|
||||
|
||||
/*
|
||||
* If the following flag is true, then the IDL generator can map
|
||||
* the methods and constants of non-conforming types. However,
|
||||
* this is very expensive, so the default should be false.
|
||||
*/
|
||||
private boolean parseNonConforming = false;
|
||||
|
||||
/**
|
||||
* This flag indicates that the stubs and ties need to be generated without
|
||||
* the package prefix (org.omg.stub).
|
||||
*/
|
||||
private boolean standardPackage;
|
||||
|
||||
/* Common objects used within package */
|
||||
|
||||
HashSet alreadyChecked = new HashSet();
|
||||
Hashtable allTypes = new Hashtable(3001, 0.5f);
|
||||
Hashtable invalidTypes = new Hashtable(256, 0.5f);
|
||||
DirectoryLoader loader = null;
|
||||
ClassPathLoader classPathLoader = null;
|
||||
Hashtable nameContexts = null;
|
||||
Hashtable namesCache = new Hashtable();
|
||||
NameContext modulesContext = new NameContext(false);
|
||||
|
||||
ClassDefinition defRemote = null;
|
||||
ClassDefinition defError = null;
|
||||
ClassDefinition defException = null;
|
||||
ClassDefinition defRemoteException = null;
|
||||
ClassDefinition defCorbaObject = null;
|
||||
ClassDefinition defSerializable = null;
|
||||
ClassDefinition defExternalizable = null;
|
||||
ClassDefinition defThrowable = null;
|
||||
ClassDefinition defRuntimeException = null;
|
||||
ClassDefinition defIDLEntity = null;
|
||||
ClassDefinition defValueBase = null;
|
||||
|
||||
sun.tools.java.Type typeRemoteException = null;
|
||||
sun.tools.java.Type typeIOException = null;
|
||||
sun.tools.java.Type typeException = null;
|
||||
sun.tools.java.Type typeThrowable = null;
|
||||
|
||||
ContextStack contextStack = null;
|
||||
|
||||
/**
|
||||
* Create a BatchEnvironment for rmic with the given class path,
|
||||
* stream for messages and Main.
|
||||
*/
|
||||
public BatchEnvironment(OutputStream out, ClassPath path, Main main) {
|
||||
|
||||
super(out,path,main);
|
||||
|
||||
// Make sure we have our definitions...
|
||||
|
||||
try {
|
||||
defRemote =
|
||||
getClassDeclaration(idRemote).getClassDefinition(this);
|
||||
defError =
|
||||
getClassDeclaration(idJavaLangError).getClassDefinition(this);
|
||||
defException =
|
||||
getClassDeclaration(idJavaLangException).getClassDefinition(this);
|
||||
defRemoteException =
|
||||
getClassDeclaration(idRemoteException).getClassDefinition(this);
|
||||
defCorbaObject =
|
||||
getClassDeclaration(idCorbaObject).getClassDefinition(this);
|
||||
defSerializable =
|
||||
getClassDeclaration(idJavaIoSerializable).getClassDefinition(this);
|
||||
defRuntimeException =
|
||||
getClassDeclaration(idJavaLangRuntimeException).getClassDefinition(this);
|
||||
defExternalizable =
|
||||
getClassDeclaration(idJavaIoExternalizable).getClassDefinition(this);
|
||||
defThrowable=
|
||||
getClassDeclaration(idJavaLangThrowable).getClassDefinition(this);
|
||||
defIDLEntity=
|
||||
getClassDeclaration(idIDLEntity).getClassDefinition(this);
|
||||
defValueBase=
|
||||
getClassDeclaration(idValueBase).getClassDefinition(this);
|
||||
typeRemoteException = defRemoteException.getClassDeclaration().getType();
|
||||
typeException = defException.getClassDeclaration().getType();
|
||||
typeIOException = getClassDeclaration(idJavaIoIOException).getType();
|
||||
typeThrowable = getClassDeclaration(idJavaLangThrowable).getType();
|
||||
|
||||
classPathLoader = new ClassPathLoader(path);
|
||||
|
||||
} catch (ClassNotFound e) {
|
||||
error(0, "rmic.class.not.found", e.name);
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not to parse non-conforming types.
|
||||
*/
|
||||
public boolean getParseNonConforming () {
|
||||
return parseNonConforming;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not to parse non-conforming types.
|
||||
*/
|
||||
public void setParseNonConforming (boolean parseEm) {
|
||||
|
||||
// If we are transitioning from not parsing to
|
||||
// parsing, we need to throw out any previously
|
||||
// parsed types...
|
||||
|
||||
if (parseEm && !parseNonConforming) {
|
||||
reset();
|
||||
}
|
||||
|
||||
parseNonConforming = parseEm;
|
||||
}
|
||||
|
||||
void setStandardPackage(boolean standardPackage) {
|
||||
this.standardPackage = standardPackage;
|
||||
}
|
||||
|
||||
boolean getStandardPackage() {
|
||||
return standardPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear out any data from previous executions.
|
||||
*/
|
||||
public void reset () {
|
||||
|
||||
// First, find all Type instances and call destroy()
|
||||
// on them...
|
||||
|
||||
for (Enumeration e = allTypes.elements() ; e.hasMoreElements() ;) {
|
||||
Type type = (Type) e.nextElement();
|
||||
type.destroy();
|
||||
}
|
||||
|
||||
for (Enumeration e = invalidTypes.keys() ; e.hasMoreElements() ;) {
|
||||
Type type = (Type) e.nextElement();
|
||||
type.destroy();
|
||||
}
|
||||
|
||||
for (Iterator e = alreadyChecked.iterator() ; e.hasNext() ;) {
|
||||
Type type = (Type) e.next();
|
||||
type.destroy();
|
||||
}
|
||||
|
||||
if (contextStack != null) contextStack.clear();
|
||||
|
||||
// Remove and clear all NameContexts in the
|
||||
// nameContexts cache...
|
||||
|
||||
if (nameContexts != null) {
|
||||
for (Enumeration e = nameContexts.elements() ; e.hasMoreElements() ;) {
|
||||
NameContext context = (NameContext) e.nextElement();
|
||||
context.clear();
|
||||
}
|
||||
nameContexts.clear();
|
||||
}
|
||||
|
||||
// Now remove all table entries...
|
||||
|
||||
allTypes.clear();
|
||||
invalidTypes.clear();
|
||||
alreadyChecked.clear();
|
||||
namesCache.clear();
|
||||
modulesContext.clear();
|
||||
|
||||
// Clean up remaining...
|
||||
loader = null;
|
||||
parseNonConforming = false;
|
||||
|
||||
// REVISIT - can't clean up classPathLoader here
|
||||
}
|
||||
|
||||
/**
|
||||
* Release resources, if any.
|
||||
*/
|
||||
public void shutdown() {
|
||||
if (alreadyChecked != null) {
|
||||
//System.out.println();
|
||||
//System.out.println("allTypes.size() = "+ allTypes.size());
|
||||
//System.out.println(" InstanceCount before reset = "+Type.instanceCount);
|
||||
reset();
|
||||
//System.out.println(" InstanceCount AFTER reset = "+Type.instanceCount);
|
||||
|
||||
alreadyChecked = null;
|
||||
allTypes = null;
|
||||
invalidTypes = null;
|
||||
nameContexts = null;
|
||||
namesCache = null;
|
||||
modulesContext = null;
|
||||
defRemote = null;
|
||||
defError = null;
|
||||
defException = null;
|
||||
defRemoteException = null;
|
||||
defCorbaObject = null;
|
||||
defSerializable = null;
|
||||
defExternalizable = null;
|
||||
defThrowable = null;
|
||||
defRuntimeException = null;
|
||||
defIDLEntity = null;
|
||||
defValueBase = null;
|
||||
typeRemoteException = null;
|
||||
typeIOException = null;
|
||||
typeException = null;
|
||||
typeThrowable = null;
|
||||
|
||||
super.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
117
jdkSrc/jdk8/sun/rmi/rmic/iiop/ClassPathLoader.java
Normal file
117
jdkSrc/jdk8/sun/rmi/rmic/iiop/ClassPathLoader.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.io.*;
|
||||
import sun.tools.java.ClassPath ;
|
||||
import sun.tools.java.ClassFile ;
|
||||
|
||||
/**
|
||||
* A ClassLoader that will ultimately use a given sun.tools.java.ClassPath to
|
||||
* find the desired file. This works for any JAR files specified in the given
|
||||
* ClassPath as well -- reusing all of that wonderful sun.tools.java code.
|
||||
*
|
||||
*@author Everett Anderson
|
||||
*/
|
||||
public class ClassPathLoader extends ClassLoader
|
||||
{
|
||||
private ClassPath classPath;
|
||||
|
||||
public ClassPathLoader(ClassPath classPath) {
|
||||
this.classPath = classPath;
|
||||
}
|
||||
|
||||
// Called by the super class
|
||||
protected Class findClass(String name) throws ClassNotFoundException
|
||||
{
|
||||
byte[] b = loadClassData(name);
|
||||
return defineClass(name, b, 0, b.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the class with the given fully qualified name from the ClassPath.
|
||||
*/
|
||||
private byte[] loadClassData(String className)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
// Build the file name and subdirectory from the
|
||||
// class name
|
||||
String filename = className.replace('.', File.separatorChar)
|
||||
+ ".class";
|
||||
|
||||
// Have ClassPath find the file for us, and wrap it in a
|
||||
// ClassFile. Note: This is where it looks inside jar files that
|
||||
// are specified in the path.
|
||||
ClassFile classFile = classPath.getFile(filename);
|
||||
|
||||
if (classFile != null) {
|
||||
|
||||
// Provide the most specific reason for failure in addition
|
||||
// to ClassNotFound
|
||||
Exception reportedError = null;
|
||||
byte data[] = null;
|
||||
|
||||
try {
|
||||
// ClassFile is beautiful because it shields us from
|
||||
// knowing if it's a separate file or an entry in a
|
||||
// jar file.
|
||||
DataInputStream input
|
||||
= new DataInputStream(classFile.getInputStream());
|
||||
|
||||
// Can't rely on input available() since it will be
|
||||
// something unusual if it's a jar file! May need
|
||||
// to worry about a possible problem if someone
|
||||
// makes a jar file entry with a size greater than
|
||||
// max int.
|
||||
data = new byte[(int)classFile.length()];
|
||||
|
||||
try {
|
||||
input.readFully(data);
|
||||
} catch (IOException ex) {
|
||||
// Something actually went wrong reading the file. This
|
||||
// is a real error so save it to report it.
|
||||
data = null;
|
||||
reportedError = ex;
|
||||
} finally {
|
||||
// Just don't care if there's an exception on close!
|
||||
// I hate that close can throw an IOException!
|
||||
try { input.close(); } catch (IOException ex) {}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// Couldn't get the input stream for the file. This is
|
||||
// probably also a real error.
|
||||
reportedError = ex;
|
||||
}
|
||||
|
||||
if (data == null)
|
||||
throw new ClassNotFoundException(className, reportedError);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
// Couldn't find the file in the class path.
|
||||
throw new ClassNotFoundException(className);
|
||||
}
|
||||
}
|
||||
215
jdkSrc/jdk8/sun/rmi/rmic/iiop/ClassType.java
Normal file
215
jdkSrc/jdk8/sun/rmi/rmic/iiop/ClassType.java
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDeclaration;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.rmi.rmic.IndentingWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* ClassType is an abstract base representing any non-special class
|
||||
* type.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public abstract class ClassType extends CompoundType {
|
||||
|
||||
private ClassType parent;
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Return the parent class of this type. Returns null if this
|
||||
* type is an interface or if there is no parent.
|
||||
*/
|
||||
public ClassType getSuperclass() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print this type.
|
||||
* @param writer The stream to print to.
|
||||
* @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names.
|
||||
* @param useIDLNames If true, print IDL names; otherwise, print java names.
|
||||
* @param globalIDLNames If true and useIDLNames true, prepends "::".
|
||||
*/
|
||||
public void print ( IndentingWriter writer,
|
||||
boolean useQualifiedNames,
|
||||
boolean useIDLNames,
|
||||
boolean globalIDLNames) throws IOException {
|
||||
|
||||
if (isInner()) {
|
||||
writer.p("// " + getTypeDescription() + " (INNER)");
|
||||
} else {
|
||||
writer.p("// " + getTypeDescription());
|
||||
}
|
||||
writer.pln(" (" + getRepositoryID() + ")\n");
|
||||
|
||||
printPackageOpen(writer,useIDLNames);
|
||||
|
||||
if (!useIDLNames) {
|
||||
writer.p("public ");
|
||||
}
|
||||
|
||||
String prefix = "";
|
||||
writer.p("class " + getTypeName(false,useIDLNames,false));
|
||||
if (printExtends(writer,useQualifiedNames,useIDLNames,globalIDLNames)) {
|
||||
prefix = ",";
|
||||
}
|
||||
printImplements(writer,prefix,useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
writer.plnI(" {");
|
||||
printMembers(writer,useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
writer.pln();
|
||||
printMethods(writer,useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
|
||||
if (useIDLNames) {
|
||||
writer.pOln("};");
|
||||
} else {
|
||||
writer.pOln("}");
|
||||
}
|
||||
|
||||
printPackageClose(writer,useIDLNames);
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
protected void destroy () {
|
||||
if (!destroyed) {
|
||||
super.destroy();
|
||||
if (parent != null) {
|
||||
parent.destroy();
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ClassType instance for the given class. NOTE: This constructor
|
||||
* is ONLY for SpecialClassType.
|
||||
*/
|
||||
protected ClassType(ContextStack stack, int typeCode, ClassDefinition classDef) {
|
||||
super(stack,typeCode,classDef); // Call special parent constructor.
|
||||
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
|
||||
throw new CompilerError("Not a class");
|
||||
}
|
||||
parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ClassType instance for the given class. NOTE: This constructor
|
||||
* is ONLY for ImplementationType. It does not walk the parent chain.
|
||||
*/
|
||||
protected ClassType(int typeCode, ClassDefinition classDef,ContextStack stack) {
|
||||
super(stack,classDef,typeCode);
|
||||
|
||||
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
|
||||
throw new CompilerError("Not a class");
|
||||
}
|
||||
parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ClassType instance for the given class. The resulting
|
||||
* object is not yet completely initialized. Subclasses must call
|
||||
* initialize(directInterfaces,directInterfaces,directConstants);
|
||||
*/
|
||||
protected ClassType(ContextStack stack,
|
||||
ClassDefinition classDef,
|
||||
int typeCode) {
|
||||
super(stack,classDef,typeCode);
|
||||
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
|
||||
throw new CompilerError("Not a class");
|
||||
}
|
||||
parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert all invalid types to valid ones.
|
||||
*/
|
||||
protected void swapInvalidTypes () {
|
||||
super.swapInvalidTypes();
|
||||
if (parent != null && parent.getStatus() != STATUS_VALID) {
|
||||
parent = (ClassType) getValidType(parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the type description with exception info.
|
||||
*/
|
||||
public String addExceptionDescription (String typeDesc) {
|
||||
if (isException) {
|
||||
if (isCheckedException) {
|
||||
typeDesc = typeDesc + " - Checked Exception";
|
||||
} else {
|
||||
typeDesc = typeDesc + " - Unchecked Exception";
|
||||
}
|
||||
}
|
||||
return typeDesc;
|
||||
}
|
||||
|
||||
|
||||
protected boolean initParents(ContextStack stack) {
|
||||
|
||||
stack.setNewContextCode(ContextStack.EXTENDS);
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
|
||||
// Init parent...
|
||||
|
||||
boolean result = true;
|
||||
|
||||
try {
|
||||
ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
|
||||
if (parentDecl != null) {
|
||||
ClassDefinition parentDef = parentDecl.getClassDefinition(env);
|
||||
parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
|
||||
if (parent == null) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
throw new CompilerError("ClassType constructor");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
2703
jdkSrc/jdk8/sun/rmi/rmic/iiop/CompoundType.java
Normal file
2703
jdkSrc/jdk8/sun/rmi/rmic/iiop/CompoundType.java
Normal file
File diff suppressed because it is too large
Load Diff
297
jdkSrc/jdk8/sun/rmi/rmic/iiop/Constants.java
Normal file
297
jdkSrc/jdk8/sun/rmi/rmic/iiop/Constants.java
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.Identifier;
|
||||
|
||||
public interface Constants extends sun.rmi.rmic.Constants {
|
||||
|
||||
// Identifiers for referenced classes:
|
||||
|
||||
public static final Identifier idReplyHandler =
|
||||
Identifier.lookup("org.omg.CORBA.portable.ResponseHandler");
|
||||
public static final Identifier idStubBase =
|
||||
Identifier.lookup("javax.rmi.CORBA.Stub");
|
||||
public static final Identifier idTieBase =
|
||||
Identifier.lookup("org.omg.CORBA.portable.ObjectImpl");
|
||||
public static final Identifier idTieInterface =
|
||||
Identifier.lookup("javax.rmi.CORBA.Tie");
|
||||
public static final Identifier idPOAServantType =
|
||||
Identifier.lookup( "org.omg.PortableServer.Servant" ) ;
|
||||
public static final Identifier idDelegate =
|
||||
Identifier.lookup("org.omg.CORBA.portable.Delegate");
|
||||
public static final Identifier idOutputStream =
|
||||
Identifier.lookup("org.omg.CORBA.portable.OutputStream");
|
||||
public static final Identifier idExtOutputStream =
|
||||
Identifier.lookup("org.omg.CORBA_2_3.portable.OutputStream");
|
||||
public static final Identifier idInputStream =
|
||||
Identifier.lookup("org.omg.CORBA.portable.InputStream");
|
||||
public static final Identifier idExtInputStream =
|
||||
Identifier.lookup("org.omg.CORBA_2_3.portable.InputStream");
|
||||
public static final Identifier idSystemException =
|
||||
Identifier.lookup("org.omg.CORBA.SystemException");
|
||||
public static final Identifier idBadMethodException =
|
||||
Identifier.lookup("org.omg.CORBA.BAD_OPERATION");
|
||||
public static final Identifier idPortableUnknownException =
|
||||
Identifier.lookup("org.omg.CORBA.portable.UnknownException");
|
||||
public static final Identifier idApplicationException =
|
||||
Identifier.lookup("org.omg.CORBA.portable.ApplicationException");
|
||||
public static final Identifier idRemarshalException =
|
||||
Identifier.lookup("org.omg.CORBA.portable.RemarshalException");
|
||||
public static final Identifier idJavaIoExternalizable =
|
||||
Identifier.lookup("java.io.Externalizable");
|
||||
public static final Identifier idCorbaObject =
|
||||
Identifier.lookup("org.omg.CORBA.Object");
|
||||
public static final Identifier idCorbaORB =
|
||||
Identifier.lookup("org.omg.CORBA.ORB");
|
||||
public static final Identifier idClassDesc =
|
||||
Identifier.lookup("javax.rmi.CORBA.ClassDesc");
|
||||
public static final Identifier idJavaIoIOException =
|
||||
Identifier.lookup("java.io.IOException");
|
||||
public static final Identifier idIDLEntity =
|
||||
Identifier.lookup("org.omg.CORBA.portable.IDLEntity");
|
||||
public static final Identifier idValueBase =
|
||||
Identifier.lookup("org.omg.CORBA.portable.ValueBase");
|
||||
public static final Identifier idBoxedRMI =
|
||||
Identifier.lookup("org.omg.boxedRMI");
|
||||
public static final Identifier idBoxedIDL =
|
||||
Identifier.lookup("org.omg.boxedIDL");
|
||||
public static final Identifier idCorbaUserException =
|
||||
Identifier.lookup("org.omg.CORBA.UserException");
|
||||
|
||||
|
||||
// Identifiers for primitive types:
|
||||
|
||||
public static final Identifier idBoolean =
|
||||
Identifier.lookup("boolean");
|
||||
public static final Identifier idByte =
|
||||
Identifier.lookup("byte");
|
||||
public static final Identifier idChar =
|
||||
Identifier.lookup("char");
|
||||
public static final Identifier idShort =
|
||||
Identifier.lookup("short");
|
||||
public static final Identifier idInt =
|
||||
Identifier.lookup("int");
|
||||
public static final Identifier idLong =
|
||||
Identifier.lookup("long");
|
||||
public static final Identifier idFloat =
|
||||
Identifier.lookup("float");
|
||||
public static final Identifier idDouble =
|
||||
Identifier.lookup("double");
|
||||
public static final Identifier idVoid =
|
||||
Identifier.lookup("void");
|
||||
|
||||
// IndentingWriter constructor args:
|
||||
|
||||
public static final int INDENT_STEP = 4;
|
||||
public static final int TAB_SIZE = Integer.MAX_VALUE; // No tabs.
|
||||
|
||||
// Type status codes:
|
||||
|
||||
public static final int STATUS_PENDING = 0;
|
||||
public static final int STATUS_VALID = 1;
|
||||
public static final int STATUS_INVALID = 2;
|
||||
|
||||
// Java Names:
|
||||
|
||||
public static final String NAME_SEPARATOR = ".";
|
||||
public static final String SERIAL_VERSION_UID = "serialVersionUID";
|
||||
|
||||
// IDL Names:
|
||||
|
||||
public static final String[] IDL_KEYWORDS = {
|
||||
"abstract",
|
||||
"any",
|
||||
"attribute",
|
||||
"boolean",
|
||||
"case",
|
||||
"char",
|
||||
"const",
|
||||
"context",
|
||||
"custom",
|
||||
"default",
|
||||
"double",
|
||||
"enum",
|
||||
"exception",
|
||||
"factory",
|
||||
"FALSE",
|
||||
"fixed",
|
||||
"float",
|
||||
"in",
|
||||
"inout",
|
||||
"interface",
|
||||
"long",
|
||||
"module",
|
||||
"native",
|
||||
"Object",
|
||||
"octet",
|
||||
"oneway",
|
||||
"out",
|
||||
"private",
|
||||
"public",
|
||||
"raises",
|
||||
"readonly",
|
||||
"sequence",
|
||||
"short",
|
||||
"string",
|
||||
"struct",
|
||||
"supports",
|
||||
"switch",
|
||||
"TRUE",
|
||||
"truncatable",
|
||||
"typedef",
|
||||
"unsigned",
|
||||
"union",
|
||||
"ValueBase",
|
||||
"valuetype",
|
||||
"void",
|
||||
"wchar",
|
||||
"wstring",
|
||||
};
|
||||
|
||||
|
||||
public static final String EXCEPTION_SUFFIX = "Exception";
|
||||
public static final String ERROR_SUFFIX = "Error";
|
||||
public static final String EX_SUFFIX = "Ex";
|
||||
|
||||
public static final String IDL_REPOSITORY_ID_PREFIX = "IDL:";
|
||||
public static final String IDL_REPOSITORY_ID_VERSION = ":1.0";
|
||||
|
||||
public static final String[] IDL_CORBA_MODULE = {"CORBA"};
|
||||
public static final String[] IDL_SEQUENCE_MODULE = {"org","omg","boxedRMI"};
|
||||
public static final String[] IDL_BOXEDIDL_MODULE = {"org","omg","boxedIDL"};
|
||||
|
||||
public static final String IDL_CLASS = "ClassDesc";
|
||||
public static final String[] IDL_CLASS_MODULE = {"javax","rmi","CORBA"};
|
||||
|
||||
public static final String IDL_IDLENTITY = "IDLEntity";
|
||||
public static final String IDL_SERIALIZABLE = "Serializable";
|
||||
public static final String IDL_EXTERNALIZABLE = "Externalizable";
|
||||
public static final String[] IDL_JAVA_IO_MODULE = {"java","io"};
|
||||
public static final String[] IDL_ORG_OMG_CORBA_MODULE = {"org","omg","CORBA"};
|
||||
public static final String[] IDL_ORG_OMG_CORBA_PORTABLE_MODULE = {"org","omg","CORBA","portable"};
|
||||
|
||||
public static final String IDL_JAVA_LANG_OBJECT = "_Object";
|
||||
public static final String[] IDL_JAVA_LANG_MODULE = {"java","lang"};
|
||||
|
||||
public static final String IDL_JAVA_RMI_REMOTE = "Remote";
|
||||
public static final String[] IDL_JAVA_RMI_MODULE = {"java","rmi"};
|
||||
|
||||
public static final String IDL_SEQUENCE = "seq";
|
||||
|
||||
public static final String IDL_CONSTRUCTOR = "create";
|
||||
|
||||
public static final String IDL_NAME_SEPARATOR = "::";
|
||||
public static final String IDL_BOOLEAN = "boolean";
|
||||
public static final String IDL_BYTE = "octet";
|
||||
public static final String IDL_CHAR = "wchar";
|
||||
public static final String IDL_SHORT = "short";
|
||||
public static final String IDL_INT = "long";
|
||||
public static final String IDL_LONG = "long long";
|
||||
public static final String IDL_FLOAT = "float";
|
||||
public static final String IDL_DOUBLE = "double";
|
||||
public static final String IDL_VOID = "void";
|
||||
|
||||
public static final String IDL_STRING = "WStringValue";
|
||||
public static final String IDL_CONSTANT_STRING = "wstring";
|
||||
public static final String IDL_CORBA_OBJECT = "Object";
|
||||
public static final String IDL_ANY = "any";
|
||||
|
||||
// File names:
|
||||
|
||||
public static final String SOURCE_FILE_EXTENSION = ".java";
|
||||
public static final String IDL_FILE_EXTENSION = ".idl";
|
||||
|
||||
// Type Codes:
|
||||
|
||||
public static final int TYPE_VOID = 0x00000001; // In PrimitiveType
|
||||
public static final int TYPE_BOOLEAN = 0x00000002; // In PrimitiveType
|
||||
public static final int TYPE_BYTE = 0x00000004; // In PrimitiveType
|
||||
public static final int TYPE_CHAR = 0x00000008; // In PrimitiveType
|
||||
public static final int TYPE_SHORT = 0x00000010; // In PrimitiveType
|
||||
public static final int TYPE_INT = 0x00000020; // In PrimitiveType
|
||||
public static final int TYPE_LONG = 0x00000040; // In PrimitiveType
|
||||
public static final int TYPE_FLOAT = 0x00000080; // In PrimitiveType
|
||||
public static final int TYPE_DOUBLE = 0x00000100; // In PrimitiveType
|
||||
|
||||
public static final int TYPE_STRING = 0x00000200; // In SpecialClassType (String)
|
||||
public static final int TYPE_ANY = 0x00000400; // In SpecialInterfaceType (Serializable,Externalizable)
|
||||
public static final int TYPE_CORBA_OBJECT = 0x00000800; // In SpecialInterfaceType (CORBA.Object,Remote)
|
||||
|
||||
public static final int TYPE_REMOTE = 0x00001000; // In RemoteType
|
||||
public static final int TYPE_ABSTRACT = 0x00002000; // In AbstractType
|
||||
public static final int TYPE_NC_INTERFACE = 0x00004000; // In NCInterfaceType
|
||||
|
||||
public static final int TYPE_VALUE = 0x00008000; // In ValueType
|
||||
public static final int TYPE_IMPLEMENTATION = 0x00010000; // In ImplementationType
|
||||
public static final int TYPE_NC_CLASS = 0x00020000; // In NCClassType
|
||||
|
||||
public static final int TYPE_ARRAY = 0x00040000; // In ArrayType
|
||||
public static final int TYPE_JAVA_RMI_REMOTE = 0x00080000; // In SpecialInterfaceType
|
||||
|
||||
// Type code masks:
|
||||
|
||||
public static final int TYPE_NONE = 0x00000000;
|
||||
public static final int TYPE_ALL = 0xFFFFFFFF;
|
||||
public static final int TYPE_MASK = 0x00FFFFFF;
|
||||
public static final int TM_MASK = 0xFF000000;
|
||||
|
||||
// Type code modifiers:
|
||||
|
||||
public static final int TM_PRIMITIVE = 0x01000000;
|
||||
public static final int TM_COMPOUND = 0x02000000;
|
||||
public static final int TM_CLASS = 0x04000000;
|
||||
public static final int TM_INTERFACE = 0x08000000;
|
||||
public static final int TM_SPECIAL_CLASS = 0x10000000;
|
||||
public static final int TM_SPECIAL_INTERFACE= 0x20000000;
|
||||
public static final int TM_NON_CONFORMING = 0x40000000;
|
||||
public static final int TM_INNER = 0x80000000;
|
||||
|
||||
// Attribute kinds...
|
||||
|
||||
public static final int ATTRIBUTE_NONE = 0; // Not an attribute.
|
||||
public static final int ATTRIBUTE_IS = 1; // read-only, had "is" prefix.
|
||||
public static final int ATTRIBUTE_GET = 2; // read-only, had "get" prefix.
|
||||
public static final int ATTRIBUTE_IS_RW = 3; // read-write, had "is" prefix.
|
||||
public static final int ATTRIBUTE_GET_RW = 4; // read-write, had "get" prefix.
|
||||
public static final int ATTRIBUTE_SET = 5; // had "set" prefix.
|
||||
|
||||
public static final String[] ATTRIBUTE_WIRE_PREFIX = {
|
||||
"",
|
||||
"_get_",
|
||||
"_get_",
|
||||
"_get_",
|
||||
"_get_",
|
||||
"_set_",
|
||||
};
|
||||
}
|
||||
41
jdkSrc/jdk8/sun/rmi/rmic/iiop/ContextElement.java
Normal file
41
jdkSrc/jdk8/sun/rmi/rmic/iiop/ContextElement.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
/**
|
||||
* ContextElement provides a common interface for elements of a ContextStack.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public interface ContextElement {
|
||||
public String getElementName();
|
||||
}
|
||||
447
jdkSrc/jdk8/sun/rmi/rmic/iiop/ContextStack.java
Normal file
447
jdkSrc/jdk8/sun/rmi/rmic/iiop/ContextStack.java
Normal file
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.CompilerError;
|
||||
|
||||
/**
|
||||
* ContextStack provides a mechanism to record parsing state.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class ContextStack {
|
||||
|
||||
// Context codes.
|
||||
|
||||
public static final int TOP = 1;
|
||||
|
||||
public static final int METHOD = 2;
|
||||
public static final int METHOD_RETURN = 3;
|
||||
public static final int METHOD_ARGUMENT = 4;
|
||||
public static final int METHOD_EXCEPTION = 5;
|
||||
|
||||
public static final int MEMBER = 6;
|
||||
public static final int MEMBER_CONSTANT = 7;
|
||||
public static final int MEMBER_STATIC = 8;
|
||||
public static final int MEMBER_TRANSIENT = 9;
|
||||
|
||||
public static final int IMPLEMENTS = 10;
|
||||
public static final int EXTENDS = 11;
|
||||
|
||||
// String versions of context codes.
|
||||
|
||||
private static final String[] CODE_NAMES = {
|
||||
"UNKNOWN ",
|
||||
"Top level type ",
|
||||
"Method ",
|
||||
"Return parameter ",
|
||||
"Parameter ",
|
||||
"Exception ",
|
||||
"Member ",
|
||||
"Constant member ",
|
||||
"Static member ",
|
||||
"Transient member ",
|
||||
"Implements ",
|
||||
"Extends ",
|
||||
};
|
||||
// Member data.
|
||||
|
||||
private int currentIndex = -1;
|
||||
private int maxIndex = 100;
|
||||
private TypeContext[] stack = new TypeContext[maxIndex];
|
||||
private int newCode = TOP;
|
||||
private BatchEnvironment env = null;
|
||||
private boolean trace = false;
|
||||
private TypeContext tempContext = new TypeContext();
|
||||
|
||||
private static final String TRACE_INDENT = " ";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ContextStack (BatchEnvironment env) {
|
||||
this.env = env;
|
||||
env.contextStack = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if env.nerrors > 0.
|
||||
*/
|
||||
public boolean anyErrors () {
|
||||
return env.nerrors > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable tracing.
|
||||
*/
|
||||
public void setTrace(boolean trace) {
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check trace flag.
|
||||
*/
|
||||
public boolean isTraceOn() {
|
||||
return trace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the environment.
|
||||
*/
|
||||
public BatchEnvironment getEnv() {
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the new context.
|
||||
*/
|
||||
public void setNewContextCode(int code) {
|
||||
newCode = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current context code.
|
||||
*/
|
||||
public int getCurrentContextCode() {
|
||||
return newCode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If tracing on, write the current call stack (not the context stack) to
|
||||
* System.out.
|
||||
*/
|
||||
final void traceCallStack () {
|
||||
if (trace) dumpCallStack();
|
||||
}
|
||||
|
||||
public final static void dumpCallStack() {
|
||||
new Error().printStackTrace(System.out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a line indented by stack depth.
|
||||
*/
|
||||
final private void tracePrint (String text, boolean line) {
|
||||
int length = text.length() + (currentIndex * TRACE_INDENT.length());
|
||||
StringBuffer buffer = new StringBuffer(length);
|
||||
for (int i = 0; i < currentIndex; i++) {
|
||||
buffer.append(TRACE_INDENT);
|
||||
}
|
||||
buffer.append(text);
|
||||
if (line) {
|
||||
buffer.append("\n");
|
||||
}
|
||||
System.out.print(buffer.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* If tracing on, print a line.
|
||||
*/
|
||||
final void trace (String text) {
|
||||
if (trace) {
|
||||
tracePrint(text,false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If tracing on, print a line followed by a '\n'.
|
||||
*/
|
||||
final void traceln (String text) {
|
||||
if (trace) {
|
||||
tracePrint(text,true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If tracing on, print a pre-mapped ContextElement.
|
||||
*/
|
||||
final void traceExistingType (Type type) {
|
||||
if (trace) {
|
||||
tempContext.set(newCode,type);
|
||||
traceln(toResultString(tempContext,true,true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a new element on the stack.
|
||||
* @return the new element.
|
||||
*/
|
||||
public TypeContext push (ContextElement element) {
|
||||
|
||||
currentIndex++;
|
||||
|
||||
// Grow array if need to...
|
||||
|
||||
if (currentIndex == maxIndex) {
|
||||
int newMax = maxIndex * 2;
|
||||
TypeContext[] newStack = new TypeContext[newMax];
|
||||
System.arraycopy(stack,0,newStack,0,maxIndex);
|
||||
maxIndex = newMax;
|
||||
stack = newStack;
|
||||
}
|
||||
|
||||
// Make sure we have a context object to use at this position...
|
||||
|
||||
TypeContext it = stack[currentIndex];
|
||||
|
||||
if (it == null) {
|
||||
it = new TypeContext();
|
||||
stack[currentIndex] = it;
|
||||
}
|
||||
|
||||
// Set the context object...
|
||||
|
||||
it.set(newCode,element);
|
||||
|
||||
// Trace...
|
||||
|
||||
traceln(toTrialString(it));
|
||||
|
||||
// Return...
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an element from the stack.
|
||||
* @return the new current element or null if top.
|
||||
*/
|
||||
public TypeContext pop (boolean wasValid) {
|
||||
|
||||
if (currentIndex < 0) {
|
||||
throw new CompilerError("Nothing on stack!");
|
||||
}
|
||||
|
||||
newCode = stack[currentIndex].getCode();
|
||||
traceln(toResultString(stack[currentIndex],wasValid,false));
|
||||
|
||||
Type last = stack[currentIndex].getCandidateType();
|
||||
if (last != null) {
|
||||
|
||||
// Set status...
|
||||
|
||||
if (wasValid) {
|
||||
last.setStatus(Constants.STATUS_VALID);
|
||||
} else {
|
||||
last.setStatus(Constants.STATUS_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
currentIndex--;
|
||||
|
||||
if (currentIndex < 0) {
|
||||
|
||||
// Done parsing, so update the invalid types
|
||||
// if this type was valid...
|
||||
|
||||
if (wasValid) {
|
||||
Type.updateAllInvalidTypes(this);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return stack[currentIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current size.
|
||||
*/
|
||||
public int size () {
|
||||
return currentIndex + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific context.
|
||||
*/
|
||||
public TypeContext getContext (int index) {
|
||||
|
||||
if (currentIndex < index) {
|
||||
throw new Error("Index out of range");
|
||||
}
|
||||
return stack[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current top context.
|
||||
*/
|
||||
public TypeContext getContext () {
|
||||
|
||||
if (currentIndex < 0) {
|
||||
throw new Error("Nothing on stack!");
|
||||
}
|
||||
return stack[currentIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Is parent context a value type?
|
||||
*/
|
||||
public boolean isParentAValue () {
|
||||
|
||||
if (currentIndex > 0) {
|
||||
return stack[currentIndex - 1].isValue();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent context. Null if none.
|
||||
*/
|
||||
public TypeContext getParentContext () {
|
||||
|
||||
if (currentIndex > 0) {
|
||||
return stack[currentIndex - 1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string for the context name...
|
||||
*/
|
||||
public String getContextCodeString () {
|
||||
|
||||
if (currentIndex >= 0) {
|
||||
return CODE_NAMES[newCode];
|
||||
} else {
|
||||
return CODE_NAMES[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string for the given context code...
|
||||
*/
|
||||
public static String getContextCodeString (int contextCode) {
|
||||
return CODE_NAMES[contextCode];
|
||||
}
|
||||
|
||||
private String toTrialString(TypeContext it) {
|
||||
int code = it.getCode();
|
||||
if (code != METHOD && code != MEMBER) {
|
||||
return it.toString() + " (trying " + it.getTypeDescription() + ")";
|
||||
} else {
|
||||
return it.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String toResultString (TypeContext it, boolean result, boolean preExisting) {
|
||||
int code = it.getCode();
|
||||
if (code != METHOD && code != MEMBER) {
|
||||
if (result) {
|
||||
String str = it.toString() + " --> " + it.getTypeDescription();
|
||||
if (preExisting) {
|
||||
return str + " [Previously mapped]";
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (result) {
|
||||
return it.toString() + " --> [Mapped]";
|
||||
}
|
||||
}
|
||||
return it.toString() + " [Did not map]";
|
||||
}
|
||||
|
||||
public void clear () {
|
||||
for (int i = 0; i < stack.length; i++) {
|
||||
if (stack[i] != null) stack[i].destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TypeContext {
|
||||
|
||||
public void set(int code, ContextElement element) {
|
||||
this.code = code;
|
||||
this.element = element;
|
||||
if (element instanceof ValueType) {
|
||||
isValue = true;
|
||||
} else {
|
||||
isValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return element.getElementName();
|
||||
}
|
||||
|
||||
public Type getCandidateType() {
|
||||
if (element instanceof Type) {
|
||||
return (Type) element;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeDescription() {
|
||||
if (element instanceof Type) {
|
||||
return ((Type) element).getTypeDescription();
|
||||
} else {
|
||||
return "[unknown type]";
|
||||
}
|
||||
}
|
||||
|
||||
public String toString () {
|
||||
if (element != null) {
|
||||
return ContextStack.getContextCodeString(code) + element.getElementName();
|
||||
} else {
|
||||
return ContextStack.getContextCodeString(code) + "null";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValue () {
|
||||
return isValue;
|
||||
}
|
||||
|
||||
public boolean isConstant () {
|
||||
return code == ContextStack.MEMBER_CONSTANT;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (element instanceof Type) {
|
||||
((Type)element).destroy();
|
||||
}
|
||||
element = null;
|
||||
}
|
||||
|
||||
private int code = 0;
|
||||
private ContextElement element = null;
|
||||
private boolean isValue = false;
|
||||
}
|
||||
160
jdkSrc/jdk8/sun/rmi/rmic/iiop/DirectoryLoader.java
Normal file
160
jdkSrc/jdk8/sun/rmi/rmic/iiop/DirectoryLoader.java
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
/**
|
||||
* DirectoryLoader is a simple ClassLoader which loads from a specified
|
||||
* file system directory.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
|
||||
public class DirectoryLoader extends ClassLoader {
|
||||
|
||||
private Hashtable cache;
|
||||
private File root;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public DirectoryLoader (File rootDir) {
|
||||
cache = new Hashtable();
|
||||
if (rootDir == null || !rootDir.isDirectory()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
root = rootDir;
|
||||
}
|
||||
|
||||
private DirectoryLoader () {}
|
||||
|
||||
/**
|
||||
* Convenience version of loadClass which sets 'resolve' == true.
|
||||
*/
|
||||
public Class loadClass(String className) throws ClassNotFoundException {
|
||||
return loadClass(className, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the required version of loadClass which is called
|
||||
* both from loadClass above and from the internal function
|
||||
* FindClassFromClass.
|
||||
*/
|
||||
public synchronized Class loadClass(String className, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
Class result;
|
||||
byte classData[];
|
||||
|
||||
// Do we already have it in the cache?
|
||||
|
||||
result = (Class) cache.get(className);
|
||||
|
||||
if (result == null) {
|
||||
|
||||
// Nope, can we get if from the system class loader?
|
||||
|
||||
try {
|
||||
|
||||
result = super.findSystemClass(className);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
// No, so try loading it...
|
||||
|
||||
classData = getClassFileData(className);
|
||||
|
||||
if (classData == null) {
|
||||
throw new ClassNotFoundException();
|
||||
}
|
||||
|
||||
// Parse the class file data...
|
||||
|
||||
result = defineClass(classData, 0, classData.length);
|
||||
|
||||
if (result == null) {
|
||||
throw new ClassFormatError();
|
||||
}
|
||||
|
||||
// Resolve it...
|
||||
|
||||
if (resolve) resolveClass(result);
|
||||
|
||||
// Add to cache...
|
||||
|
||||
cache.put(className, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reurn a byte array containing the contents of the class file. Returns null
|
||||
* if an exception occurs.
|
||||
*/
|
||||
private byte[] getClassFileData (String className) {
|
||||
|
||||
byte result[] = null;
|
||||
FileInputStream stream = null;
|
||||
|
||||
// Get the file...
|
||||
|
||||
File classFile = new File(root,className.replace('.',File.separatorChar) + ".class");
|
||||
|
||||
// Now get the bits...
|
||||
|
||||
try {
|
||||
stream = new FileInputStream(classFile);
|
||||
result = new byte[stream.available()];
|
||||
stream.read(result);
|
||||
} catch(ThreadDeath death) {
|
||||
throw death;
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch(ThreadDeath death) {
|
||||
throw death;
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
436
jdkSrc/jdk8/sun/rmi/rmic/iiop/Generator.java
Normal file
436
jdkSrc/jdk8/sun/rmi/rmic/iiop/Generator.java
Normal file
@@ -0,0 +1,436 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.IOException;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassPath;
|
||||
import sun.tools.java.ClassFile;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.tools.java.ClassDeclaration;
|
||||
import sun.rmi.rmic.IndentingWriter;
|
||||
import sun.rmi.rmic.Main;
|
||||
import sun.rmi.rmic.iiop.Util;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Generator provides a small framework from which IIOP-specific
|
||||
* generators can inherit. Common logic is implemented here which uses
|
||||
* both abstract methods as well as concrete methods which subclasses may
|
||||
* want to override. The following methods must be present in any subclass:
|
||||
* <pre>
|
||||
* Default constructor
|
||||
* CompoundType getTopType(BatchEnvironment env, ClassDefinition cdef);
|
||||
* int parseArgs(String argv[], int currentIndex);
|
||||
* boolean requireNewInstance();
|
||||
* OutputType[] getOutputTypesFor(CompoundType topType,
|
||||
* HashSet alreadyChecked);
|
||||
* String getFileNameExtensionFor(OutputType outputType);
|
||||
* void writeOutputFor ( OutputType outputType,
|
||||
* HashSet alreadyChecked,
|
||||
* IndentingWriter writer) throws IOException;
|
||||
* </pre>
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public abstract class Generator implements sun.rmi.rmic.Generator,
|
||||
sun.rmi.rmic.iiop.Constants {
|
||||
|
||||
protected boolean alwaysGenerate = false;
|
||||
protected BatchEnvironment env = null;
|
||||
protected ContextStack contextStack = null;
|
||||
private boolean trace = false;
|
||||
protected boolean idl = false;
|
||||
|
||||
/**
|
||||
* Examine and consume command line arguments.
|
||||
* @param argv The command line arguments. Ignore null
|
||||
* and unknown arguments. Set each consumed argument to null.
|
||||
* @param error Report any errors using the main.error() methods.
|
||||
* @return true if no errors, false otherwise.
|
||||
*/
|
||||
public boolean parseArgs(String argv[], Main main) {
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
if (argv[i] != null) {
|
||||
if (argv[i].equalsIgnoreCase("-always") ||
|
||||
argv[i].equalsIgnoreCase("-alwaysGenerate")) {
|
||||
alwaysGenerate = true;
|
||||
argv[i] = null;
|
||||
} else if (argv[i].equalsIgnoreCase("-xtrace")) {
|
||||
trace = true;
|
||||
argv[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if non-conforming types should be parsed.
|
||||
* @param stack The context stack.
|
||||
*/
|
||||
protected abstract boolean parseNonConforming(ContextStack stack);
|
||||
|
||||
/**
|
||||
* Create and return a top-level type.
|
||||
* @param cdef The top-level class definition.
|
||||
* @param stack The context stack.
|
||||
* @return The compound type or null if is non-conforming.
|
||||
*/
|
||||
protected abstract CompoundType getTopType(ClassDefinition cdef, ContextStack stack);
|
||||
|
||||
/**
|
||||
* Return an array containing all the file names and types that need to be
|
||||
* generated for the given top-level type. The file names must NOT have an
|
||||
* extension (e.g. ".java").
|
||||
* @param topType The type returned by getTopType().
|
||||
* @param alreadyChecked A set of Types which have already been checked.
|
||||
* Intended to be passed to Type.collectMatching(filter,alreadyChecked).
|
||||
*/
|
||||
protected abstract OutputType[] getOutputTypesFor(CompoundType topType,
|
||||
HashSet alreadyChecked);
|
||||
|
||||
/**
|
||||
* Return the file name extension for the given file name (e.g. ".java").
|
||||
* All files generated with the ".java" extension will be compiled. To
|
||||
* change this behavior for ".java" files, override the compileJavaSourceFile
|
||||
* method to return false.
|
||||
* @param outputType One of the items returned by getOutputTypesFor(...)
|
||||
*/
|
||||
protected abstract String getFileNameExtensionFor(OutputType outputType);
|
||||
|
||||
/**
|
||||
* Write the output for the given OutputFileName into the output stream.
|
||||
* @param name One of the items returned by getOutputTypesFor(...)
|
||||
* @param alreadyChecked A set of Types which have already been checked.
|
||||
* Intended to be passed to Type.collectMatching(filter,alreadyChecked).
|
||||
* @param writer The output stream.
|
||||
*/
|
||||
protected abstract void writeOutputFor(OutputType outputType,
|
||||
HashSet alreadyChecked,
|
||||
IndentingWriter writer) throws IOException;
|
||||
|
||||
/**
|
||||
* Return true if a new instance should be created for each
|
||||
* class on the command line. Subclasses which return true
|
||||
* should override newInstance() to return an appropriately
|
||||
* constructed instance.
|
||||
*/
|
||||
protected abstract boolean requireNewInstance();
|
||||
|
||||
/**
|
||||
* Return true if the specified file needs generation.
|
||||
*/
|
||||
public boolean requiresGeneration (File target, Type theType) {
|
||||
|
||||
boolean result = alwaysGenerate;
|
||||
|
||||
if (!result) {
|
||||
|
||||
// Get a ClassFile instance for base source or class
|
||||
// file. We use ClassFile so that if the base is in
|
||||
// a zip file, we can still get at it's mod time...
|
||||
|
||||
ClassFile baseFile;
|
||||
ClassPath path = env.getClassPath();
|
||||
String className = theType.getQualifiedName().replace('.',File.separatorChar);
|
||||
|
||||
// First try the source file...
|
||||
|
||||
baseFile = path.getFile(className + ".source");
|
||||
|
||||
if (baseFile == null) {
|
||||
|
||||
// Then try class file...
|
||||
|
||||
baseFile = path.getFile(className + ".class");
|
||||
}
|
||||
|
||||
// Do we have a baseFile?
|
||||
|
||||
if (baseFile != null) {
|
||||
|
||||
// Yes, grab baseFile's mod time...
|
||||
|
||||
long baseFileMod = baseFile.lastModified();
|
||||
|
||||
// Get a File instance for the target. If it is a source
|
||||
// file, create a class file instead since the source file
|
||||
// will frequently be deleted...
|
||||
|
||||
String targetName = IDLNames.replace(target.getName(),".java",".class");
|
||||
String parentPath = target.getParent();
|
||||
File targetFile = new File(parentPath,targetName);
|
||||
|
||||
// Does the target file exist?
|
||||
|
||||
if (targetFile.exists()) {
|
||||
|
||||
// Yes, so grab it's mod time...
|
||||
|
||||
long targetFileMod = targetFile.lastModified();
|
||||
|
||||
// Set result...
|
||||
|
||||
result = targetFileMod < baseFileMod;
|
||||
|
||||
} else {
|
||||
|
||||
// No, so we must generate...
|
||||
|
||||
result = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
// No, so we must generate...
|
||||
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new instance of self. Subclasses
|
||||
* which need to do something other than default construction
|
||||
* must override this method.
|
||||
*/
|
||||
protected Generator newInstance() {
|
||||
Generator result = null;
|
||||
try {
|
||||
result = (Generator) getClass().newInstance();
|
||||
}
|
||||
catch (Exception e){} // Should ALWAYS work!
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for subclasses to use.
|
||||
*/
|
||||
protected Generator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate output. Any source files created which need compilation should
|
||||
* be added to the compiler environment using the addGeneratedFile(File)
|
||||
* method.
|
||||
*
|
||||
* @param env The compiler environment
|
||||
* @param cdef The definition for the implementation class or interface from
|
||||
* which to generate output
|
||||
* @param destDir The directory for the root of the package hierarchy
|
||||
* for generated files. May be null.
|
||||
*/
|
||||
public void generate(sun.rmi.rmic.BatchEnvironment env, ClassDefinition cdef, File destDir) {
|
||||
|
||||
this.env = (BatchEnvironment) env;
|
||||
contextStack = new ContextStack(this.env);
|
||||
contextStack.setTrace(trace);
|
||||
|
||||
// Make sure the environment knows whether or not to parse
|
||||
// non-conforming types. This will clear out any previously
|
||||
// parsed types if necessary...
|
||||
|
||||
this.env.setParseNonConforming(parseNonConforming(contextStack));
|
||||
|
||||
// Get our top level type...
|
||||
|
||||
CompoundType topType = getTopType(cdef,contextStack);
|
||||
if (topType != null) {
|
||||
|
||||
Generator generator = this;
|
||||
|
||||
// Do we need to make a new instance?
|
||||
|
||||
if (requireNewInstance()) {
|
||||
|
||||
// Yes, so make one. 'this' instance is the one instantiated by Main
|
||||
// and which knows any needed command line args...
|
||||
|
||||
generator = newInstance();
|
||||
}
|
||||
|
||||
// Now generate all output files...
|
||||
|
||||
generator.generateOutputFiles(topType, this.env, destDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new instance of self. Subclasses
|
||||
* which need to do something other than default construction
|
||||
* must override this method.
|
||||
*/
|
||||
protected void generateOutputFiles (CompoundType topType,
|
||||
BatchEnvironment env,
|
||||
File destDir) {
|
||||
|
||||
// Grab the 'alreadyChecked' HashSet from the environment...
|
||||
|
||||
HashSet alreadyChecked = env.alreadyChecked;
|
||||
|
||||
// Ask subclass for a list of output types...
|
||||
|
||||
OutputType[] types = getOutputTypesFor(topType,alreadyChecked);
|
||||
|
||||
// Process each file...
|
||||
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
OutputType current = types[i];
|
||||
String className = current.getName();
|
||||
File file = getFileFor(current,destDir);
|
||||
boolean sourceFile = false;
|
||||
|
||||
// Do we need to generate this file?
|
||||
|
||||
if (requiresGeneration(file,current.getType())) {
|
||||
|
||||
// Yes. If java source file, add to environment so will be compiled...
|
||||
|
||||
if (file.getName().endsWith(".java")) {
|
||||
sourceFile = compileJavaSourceFile(current);
|
||||
|
||||
// Are we supposeded to compile this one?
|
||||
|
||||
if (sourceFile) {
|
||||
env.addGeneratedFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
// Now create an output stream and ask subclass to fill it up...
|
||||
|
||||
try {
|
||||
IndentingWriter out = new IndentingWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(file)),INDENT_STEP,TAB_SIZE);
|
||||
|
||||
long startTime = 0;
|
||||
if (env.verbose()) {
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
writeOutputFor(types[i],alreadyChecked,out);
|
||||
out.close();
|
||||
|
||||
if (env.verbose()) {
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
env.output(Main.getText("rmic.generated", file.getPath(), Long.toString(duration)));
|
||||
}
|
||||
if (sourceFile) {
|
||||
env.parseFile(new ClassFile(file));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
env.error(0, "cant.write", file.toString());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
// No, say so if we need to...
|
||||
|
||||
if (env.verbose()) {
|
||||
env.output(Main.getText("rmic.previously.generated", file.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the File object that should be used as the output file
|
||||
* for the given OutputType.
|
||||
* @param outputType The type to create a file for.
|
||||
* @param destinationDir The directory to use as the root of the
|
||||
* package heirarchy. May be null, in which case the current
|
||||
* classpath is searched to find the directory in which to create
|
||||
* the output file. If that search fails (most likely because the
|
||||
* package directory lives in a zip or jar file rather than the
|
||||
* file system), the current user directory is used.
|
||||
*/
|
||||
protected File getFileFor(OutputType outputType, File destinationDir) {
|
||||
// Calling this method does some crucial initialization
|
||||
// in a subclass implementation. Don't skip it.
|
||||
Identifier id = getOutputId(outputType);
|
||||
File packageDir = null;
|
||||
if(idl){
|
||||
packageDir = Util.getOutputDirectoryForIDL(id,destinationDir,env);
|
||||
} else {
|
||||
packageDir = Util.getOutputDirectoryForStub(id,destinationDir,env);
|
||||
}
|
||||
String classFileName = outputType.getName() + getFileNameExtensionFor(outputType);
|
||||
return new File(packageDir, classFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an identifier to use for output.
|
||||
* @param outputType the type for which output is to be generated.
|
||||
* @return the new identifier. This implementation returns the input parameter.
|
||||
*/
|
||||
protected Identifier getOutputId (OutputType outputType) {
|
||||
return outputType.getType().getIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given file should be compiled.
|
||||
* @param outputType One of the items returned by getOutputTypesFor(...) for
|
||||
* which getFileNameExtensionFor(OutputType) returned ".java".
|
||||
*/
|
||||
protected boolean compileJavaSourceFile (OutputType outputType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// OutputType is a simple wrapper for a name and a Type
|
||||
//_____________________________________________________________________
|
||||
|
||||
public class OutputType {
|
||||
private String name;
|
||||
private Type type;
|
||||
|
||||
public OutputType (String name, Type type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
2084
jdkSrc/jdk8/sun/rmi/rmic/iiop/IDLGenerator.java
Normal file
2084
jdkSrc/jdk8/sun/rmi/rmic/iiop/IDLGenerator.java
Normal file
File diff suppressed because it is too large
Load Diff
1227
jdkSrc/jdk8/sun/rmi/rmic/iiop/IDLNames.java
Normal file
1227
jdkSrc/jdk8/sun/rmi/rmic/iiop/IDLNames.java
Normal file
File diff suppressed because it is too large
Load Diff
292
jdkSrc/jdk8/sun/rmi/rmic/iiop/ImplementationType.java
Normal file
292
jdkSrc/jdk8/sun/rmi/rmic/iiop/ImplementationType.java
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.tools.java.MemberDefinition;
|
||||
|
||||
/**
|
||||
* ImplementationType represents any non-special class which implements
|
||||
* one or more interfaces which inherit from java.rmi.Remote.
|
||||
* <p>
|
||||
* The static forImplementation(...) method must be used to obtain an instance,
|
||||
* and will return null if the ClassDefinition is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class ImplementationType extends ClassType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an ImplementationType for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static ImplementationType forImplementation(ClassDefinition classDef,
|
||||
ContextStack stack,
|
||||
boolean quiet) {
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
boolean doPop = false;
|
||||
ImplementationType result = null;
|
||||
|
||||
try {
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
Type existing = getType(theType,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof ImplementationType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (ImplementationType) existing;
|
||||
|
||||
}
|
||||
|
||||
// Could this be an implementation?
|
||||
|
||||
if (couldBeImplementation(quiet,stack,classDef)) {
|
||||
|
||||
// Yes, so check it...
|
||||
|
||||
ImplementationType it = new ImplementationType(stack, classDef);
|
||||
putType(theType,it,stack);
|
||||
stack.push(it);
|
||||
doPop = true;
|
||||
|
||||
if (it.initialize(stack,quiet)) {
|
||||
stack.pop(true);
|
||||
result = it;
|
||||
} else {
|
||||
removeType(theType,stack);
|
||||
stack.pop(false);
|
||||
}
|
||||
}
|
||||
} catch (CompilerError e) {
|
||||
if (doPop) stack.pop(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Implementation";
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a ImplementationType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private ImplementationType(ContextStack stack, ClassDefinition classDef) {
|
||||
super(TYPE_IMPLEMENTATION | TM_CLASS | TM_COMPOUND,classDef,stack); // Use special constructor.
|
||||
}
|
||||
|
||||
|
||||
private static boolean couldBeImplementation(boolean quiet, ContextStack stack,
|
||||
ClassDefinition classDef) {
|
||||
boolean result = false;
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
|
||||
try {
|
||||
if (!classDef.isClass()) {
|
||||
failedConstraint(17,quiet,stack,classDef.getName());
|
||||
} else {
|
||||
result = env.defRemote.implementedBy(env, classDef.getClassDeclaration());
|
||||
if (!result) failedConstraint(8,quiet,stack,classDef.getName());
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (ContextStack stack, boolean quiet) {
|
||||
|
||||
boolean result = false;
|
||||
ClassDefinition theClass = getClassDefinition();
|
||||
|
||||
if (initParents(stack)) {
|
||||
|
||||
// Make up our collections...
|
||||
|
||||
Vector directInterfaces = new Vector();
|
||||
Vector directMethods = new Vector();
|
||||
|
||||
// Check interfaces...
|
||||
|
||||
try {
|
||||
if (addRemoteInterfaces(directInterfaces,true,stack) != null) {
|
||||
|
||||
boolean haveRemote = false;
|
||||
|
||||
// Get methods from all interfaces...
|
||||
|
||||
for (int i = 0; i < directInterfaces.size(); i++) {
|
||||
InterfaceType theInt = (InterfaceType) directInterfaces.elementAt(i);
|
||||
if (theInt.isType(TYPE_REMOTE) ||
|
||||
theInt.isType(TYPE_JAVA_RMI_REMOTE)) {
|
||||
haveRemote = true;
|
||||
}
|
||||
|
||||
copyRemoteMethods(theInt,directMethods);
|
||||
}
|
||||
|
||||
// Make sure we have at least one remote interface...
|
||||
|
||||
if (!haveRemote) {
|
||||
failedConstraint(8,quiet,stack,getQualifiedName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check the methods to ensure we have the
|
||||
// correct throws clauses...
|
||||
|
||||
if (checkMethods(theClass,directMethods,stack,quiet)) {
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
result = initialize(directInterfaces,directMethods,null,stack,quiet);
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void copyRemoteMethods(InterfaceType type, Vector list) {
|
||||
|
||||
if (type.isType(TYPE_REMOTE)) {
|
||||
|
||||
// Copy all the unique methods from type...
|
||||
|
||||
Method[] allMethods = type.getMethods();
|
||||
|
||||
for (int i = 0; i < allMethods.length; i++) {
|
||||
Method theMethod = allMethods[i];
|
||||
|
||||
if (!list.contains(theMethod)) {
|
||||
list.addElement(theMethod);
|
||||
}
|
||||
}
|
||||
|
||||
// Now recurse thru all inherited interfaces...
|
||||
|
||||
InterfaceType[] allInterfaces = type.getInterfaces();
|
||||
|
||||
for (int i = 0; i < allInterfaces.length; i++) {
|
||||
copyRemoteMethods(allInterfaces[i],list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Walk all methods of the class, and for each that is already in
|
||||
// the list, call setImplExceptions()...
|
||||
|
||||
private boolean checkMethods(ClassDefinition theClass, Vector list,
|
||||
ContextStack stack, boolean quiet) {
|
||||
|
||||
// Convert vector to array...
|
||||
|
||||
Method[] methods = new Method[list.size()];
|
||||
list.copyInto(methods);
|
||||
|
||||
for (MemberDefinition member = theClass.getFirstMember();
|
||||
member != null;
|
||||
member = member.getNextMember()) {
|
||||
|
||||
if (member.isMethod() && !member.isConstructor()
|
||||
&& !member.isInitializer()) {
|
||||
|
||||
// It's a method...
|
||||
|
||||
if (!updateExceptions(member,methods,stack,quiet)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean updateExceptions (MemberDefinition implMethod, Method[] list,
|
||||
ContextStack stack, boolean quiet) {
|
||||
int length = list.length;
|
||||
String implMethodSig = implMethod.toString();
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
Method existingMethod = list[i];
|
||||
MemberDefinition existing = existingMethod.getMemberDefinition();
|
||||
|
||||
// Do we have a matching method?
|
||||
|
||||
if (implMethodSig.equals(existing.toString())) {
|
||||
|
||||
// Yes, so create exception list...
|
||||
|
||||
try {
|
||||
ValueType[] implExcept = getMethodExceptions(implMethod,quiet,stack);
|
||||
existingMethod.setImplExceptions(implExcept);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
122
jdkSrc/jdk8/sun/rmi/rmic/iiop/InterfaceType.java
Normal file
122
jdkSrc/jdk8/sun/rmi/rmic/iiop/InterfaceType.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.io.IOException;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.rmi.rmic.IndentingWriter;
|
||||
|
||||
/**
|
||||
* InterfaceType is an abstract base representing any non-special
|
||||
* interface type.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public abstract class InterfaceType extends CompoundType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Print this type.
|
||||
* @param writer The stream to print to.
|
||||
* @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names.
|
||||
* @param useIDLNames If true, print IDL names; otherwise, print java names.
|
||||
* @param globalIDLNames If true and useIDLNames true, prepends "::".
|
||||
*/
|
||||
public void print ( IndentingWriter writer,
|
||||
boolean useQualifiedNames,
|
||||
boolean useIDLNames,
|
||||
boolean globalIDLNames) throws IOException {
|
||||
|
||||
if (isInner()) {
|
||||
writer.p("// " + getTypeDescription() + " (INNER)");
|
||||
} else {
|
||||
writer.p("// " + getTypeDescription() + "");
|
||||
}
|
||||
writer.pln(" (" + getRepositoryID() + ")\n");
|
||||
printPackageOpen(writer,useIDLNames);
|
||||
|
||||
if (!useIDLNames) {
|
||||
writer.p("public ");
|
||||
}
|
||||
|
||||
writer.p("interface " + getTypeName(false,useIDLNames,false));
|
||||
printImplements(writer,"",useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
writer.plnI(" {");
|
||||
printMembers(writer,useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
writer.pln();
|
||||
printMethods(writer,useQualifiedNames,useIDLNames,globalIDLNames);
|
||||
writer.pln();
|
||||
|
||||
if (useIDLNames) {
|
||||
writer.pOln("};");
|
||||
} else {
|
||||
writer.pOln("}");
|
||||
}
|
||||
printPackageClose(writer,useIDLNames);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a InterfaceType instance for the given class. NOTE: This constructor
|
||||
* is ONLY for SpecialInterfaceType.
|
||||
*/
|
||||
protected InterfaceType(ContextStack stack, int typeCode, ClassDefinition classDef) {
|
||||
super(stack,typeCode,classDef); // Call special parent constructor.
|
||||
|
||||
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
|
||||
throw new CompilerError("Not an interface");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a InterfaceType instance for the given class. The resulting
|
||||
* object is not yet completely initialized. Subclasses must call
|
||||
* initialize(directInterfaces,directInterfaces,directConstants);
|
||||
*/
|
||||
protected InterfaceType(ContextStack stack,
|
||||
ClassDefinition classDef,
|
||||
int typeCode) {
|
||||
super(stack,classDef,typeCode);
|
||||
|
||||
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
|
||||
throw new CompilerError("Not an interface");
|
||||
}
|
||||
}
|
||||
}
|
||||
172
jdkSrc/jdk8/sun/rmi/rmic/iiop/NCClassType.java
Normal file
172
jdkSrc/jdk8/sun/rmi/rmic/iiop/NCClassType.java
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* NCClassType represents any non-special class which does not
|
||||
* extends one or more interfaces which inherit from java.rmi.Remote.
|
||||
* <p>
|
||||
* The static forImplementation(...) method must be used to obtain an instance,
|
||||
* and will return null if the ClassDefinition is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class NCClassType extends ClassType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an NCClassType for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static NCClassType forNCClass(ClassDefinition classDef,
|
||||
ContextStack stack) {
|
||||
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
boolean doPop = false;
|
||||
try {
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
Type existing = getType(theType,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof NCClassType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (NCClassType) existing;
|
||||
|
||||
}
|
||||
|
||||
NCClassType it = new NCClassType(stack, classDef);
|
||||
putType(theType,it,stack);
|
||||
stack.push(it);
|
||||
doPop = true;
|
||||
|
||||
if (it.initialize(stack)) {
|
||||
stack.pop(true);
|
||||
return it;
|
||||
} else {
|
||||
removeType(theType,stack);
|
||||
stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
} catch (CompilerError e) {
|
||||
if (doPop) stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return addExceptionDescription("Non-conforming class");
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal/Subclass Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a NCClassType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private NCClassType(ContextStack stack, ClassDefinition classDef) {
|
||||
super(stack,classDef,TYPE_NC_CLASS | TM_CLASS | TM_COMPOUND);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (ContextStack stack) {
|
||||
if (!initParents(stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stack.getEnv().getParseNonConforming()) {
|
||||
|
||||
Vector directInterfaces = new Vector();
|
||||
Vector directMethods = new Vector();
|
||||
Vector directMembers = new Vector();
|
||||
|
||||
try {
|
||||
|
||||
// Get methods...
|
||||
|
||||
if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) {
|
||||
|
||||
// Update parent class methods...
|
||||
|
||||
if (updateParentClassMethods(getClassDefinition(),directMethods,false,stack) != null) {
|
||||
|
||||
// Get conforming constants...
|
||||
|
||||
if (addConformingConstants(directMembers,false,stack)) {
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return initialize(null,null,null,stack,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
162
jdkSrc/jdk8/sun/rmi/rmic/iiop/NCInterfaceType.java
Normal file
162
jdkSrc/jdk8/sun/rmi/rmic/iiop/NCInterfaceType.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* NCInterfaceType represents any non-special, non-conforming interface.
|
||||
* <p>
|
||||
* The static forNCInterface(...) method must be used to obtain an instance.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class NCInterfaceType extends InterfaceType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an NCInterfaceType for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static NCInterfaceType forNCInterface( ClassDefinition classDef,
|
||||
ContextStack stack) {
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
boolean doPop = false;
|
||||
try {
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
Type existing = getType(theType,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof NCInterfaceType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (NCInterfaceType) existing;
|
||||
}
|
||||
|
||||
NCInterfaceType it = new NCInterfaceType(stack, classDef);
|
||||
putType(theType,it,stack);
|
||||
stack.push(it);
|
||||
doPop = true;
|
||||
|
||||
if (it.initialize(stack)) {
|
||||
stack.pop(true);
|
||||
return it;
|
||||
} else {
|
||||
removeType(theType,stack);
|
||||
stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
} catch (CompilerError e) {
|
||||
if (doPop) stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Non-conforming interface";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal/Subclass Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a NCInterfaceType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private NCInterfaceType(ContextStack stack, ClassDefinition classDef) {
|
||||
super(stack,classDef,TYPE_NC_INTERFACE | TM_INTERFACE | TM_COMPOUND);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (ContextStack stack) {
|
||||
|
||||
if (stack.getEnv().getParseNonConforming()) {
|
||||
|
||||
Vector directInterfaces = new Vector();
|
||||
Vector directMethods = new Vector();
|
||||
Vector directMembers = new Vector();
|
||||
|
||||
try {
|
||||
|
||||
// need to include parent interfaces in IDL generation...
|
||||
addNonRemoteInterfaces( directInterfaces,stack );
|
||||
|
||||
// Get methods...
|
||||
|
||||
if (addAllMethods(getClassDefinition(),directMethods,false,false,stack) != null) {
|
||||
|
||||
// Get conforming constants...
|
||||
|
||||
if (addConformingConstants(directMembers,false,stack)) {
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
if (!initialize(directInterfaces,directMethods,directMembers,stack,false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return initialize(null,null,null,stack,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
232
jdkSrc/jdk8/sun/rmi/rmic/iiop/NameContext.java
Normal file
232
jdkSrc/jdk8/sun/rmi/rmic/iiop/NameContext.java
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* A NameContext enables detection of strings which differ only
|
||||
* in case.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
class NameContext {
|
||||
|
||||
private Hashtable table;
|
||||
private boolean allowCollisions;
|
||||
|
||||
/**
|
||||
* Get a context for the given name. Name may be null, in
|
||||
* which case this method will return the default context.
|
||||
*/
|
||||
public static synchronized NameContext forName (String name,
|
||||
boolean allowCollisions,
|
||||
BatchEnvironment env) {
|
||||
|
||||
NameContext result = null;
|
||||
|
||||
// Do we need to use the default context?
|
||||
|
||||
if (name == null) {
|
||||
|
||||
// Yes.
|
||||
|
||||
name = "null";
|
||||
}
|
||||
|
||||
// Have we initialized our hashtable?
|
||||
|
||||
if (env.nameContexts == null) {
|
||||
|
||||
// Nope, so do it...
|
||||
|
||||
env.nameContexts = new Hashtable();
|
||||
|
||||
} else {
|
||||
|
||||
// Yes, see if we already have the requested
|
||||
// context...
|
||||
|
||||
result = (NameContext) env.nameContexts.get(name);
|
||||
}
|
||||
|
||||
// Do we have the requested context?
|
||||
|
||||
if (result == null) {
|
||||
|
||||
// Nope, so create and add it...
|
||||
|
||||
result = new NameContext(allowCollisions);
|
||||
|
||||
env.nameContexts.put(name,result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a context.
|
||||
* @param allowCollisions true if case-sensitive name collisions
|
||||
* are allowed, false if not.
|
||||
*/
|
||||
public NameContext (boolean allowCollisions) {
|
||||
this.allowCollisions = allowCollisions;
|
||||
table = new Hashtable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a name to this context. If constructed with allowCollisions
|
||||
* false and a collision occurs, this method will throw an exception
|
||||
* in which the message contains the string: "name" and "collision".
|
||||
*/
|
||||
public void assertPut (String name) throws Exception {
|
||||
|
||||
String message = add(name);
|
||||
|
||||
if (message != null) {
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a name to this context..
|
||||
*/
|
||||
public void put (String name) {
|
||||
|
||||
if (allowCollisions == false) {
|
||||
throw new Error("Must use assertPut(name)");
|
||||
}
|
||||
|
||||
add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a name to this context. If constructed with allowCollisions
|
||||
* false and a collision occurs, this method will return a message
|
||||
* string, otherwise returns null.
|
||||
*/
|
||||
private String add (String name) {
|
||||
|
||||
// First, create a key by converting name to lowercase...
|
||||
|
||||
String key = name.toLowerCase();
|
||||
|
||||
// Does this key exist in the context?
|
||||
|
||||
Name value = (Name) table.get(key);
|
||||
|
||||
if (value != null) {
|
||||
|
||||
// Yes, so they match if we ignore case. Do they match if
|
||||
// we don't ignore case?
|
||||
|
||||
if (!name.equals(value.name)) {
|
||||
|
||||
// No, so this is a case-sensitive match. Are we
|
||||
// supposed to allow this?
|
||||
|
||||
if (allowCollisions) {
|
||||
|
||||
// Yes, make sure it knows that it collides...
|
||||
|
||||
value.collisions = true;
|
||||
|
||||
} else {
|
||||
|
||||
// No, so return a message string...
|
||||
|
||||
return new String("\"" + name + "\" and \"" + value.name + "\"");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// No, so add it...
|
||||
|
||||
table.put(key,new Name(name,false));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a name from the context. If it has collisions, the name
|
||||
* will be converted as specified in section 5.2.7.
|
||||
*/
|
||||
public String get (String name) {
|
||||
|
||||
Name it = (Name) table.get(name.toLowerCase());
|
||||
String result = name;
|
||||
|
||||
// Do we need to mangle it?
|
||||
|
||||
if (it.collisions) {
|
||||
|
||||
// Yep, so do it...
|
||||
|
||||
int length = name.length();
|
||||
boolean allLower = true;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
if (Character.isUpperCase(name.charAt(i))) {
|
||||
result += "_";
|
||||
result += i;
|
||||
allLower = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allLower) {
|
||||
result += "_";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all entries.
|
||||
*/
|
||||
public void clear () {
|
||||
table.clear();
|
||||
}
|
||||
|
||||
public class Name {
|
||||
public String name;
|
||||
public boolean collisions;
|
||||
|
||||
public Name (String name, boolean collisions) {
|
||||
this.name = name;
|
||||
this.collisions = collisions;
|
||||
}
|
||||
}
|
||||
}
|
||||
195
jdkSrc/jdk8/sun/rmi/rmic/iiop/PrimitiveType.java
Normal file
195
jdkSrc/jdk8/sun/rmi/rmic/iiop/PrimitiveType.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* PrimitiveType wraps primitive types and void.
|
||||
* <p>
|
||||
* The static forPrimitive(...) method must be used to obtain an instance, and
|
||||
* will return null if the type is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class PrimitiveType extends Type {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a PrimitiveType object for the given type.
|
||||
*
|
||||
* If the type is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static PrimitiveType forPrimitive(sun.tools.java.Type type,
|
||||
ContextStack stack) {
|
||||
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
Type existing = getType(type,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof PrimitiveType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (PrimitiveType) existing;
|
||||
}
|
||||
|
||||
int typeCode;
|
||||
|
||||
switch (type.getTypeCode()) {
|
||||
case TC_VOID: typeCode = TYPE_VOID; break;
|
||||
case TC_BOOLEAN: typeCode = TYPE_BOOLEAN; break;
|
||||
case TC_BYTE: typeCode = TYPE_BYTE; break;
|
||||
case TC_CHAR: typeCode = TYPE_CHAR; break;
|
||||
case TC_SHORT: typeCode = TYPE_SHORT; break;
|
||||
case TC_INT: typeCode = TYPE_INT; break;
|
||||
case TC_LONG: typeCode = TYPE_LONG; break;
|
||||
case TC_FLOAT: typeCode = TYPE_FLOAT; break;
|
||||
case TC_DOUBLE: typeCode = TYPE_DOUBLE; break;
|
||||
default: return null;
|
||||
}
|
||||
|
||||
PrimitiveType it = new PrimitiveType(stack,typeCode);
|
||||
|
||||
// Add it...
|
||||
|
||||
putType(type,it,stack);
|
||||
|
||||
// Do the stack thing in case tracing on...
|
||||
|
||||
stack.push(it);
|
||||
stack.pop(true);
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return signature for this type (e.g. com.acme.Dynamite
|
||||
* would return "com.acme.Dynamite", byte = "B")
|
||||
*/
|
||||
public String getSignature() {
|
||||
switch (getTypeCode()) {
|
||||
case TYPE_VOID: return SIG_VOID;
|
||||
case TYPE_BOOLEAN: return SIG_BOOLEAN;
|
||||
case TYPE_BYTE: return SIG_BYTE;
|
||||
case TYPE_CHAR: return SIG_CHAR;
|
||||
case TYPE_SHORT: return SIG_SHORT;
|
||||
case TYPE_INT: return SIG_INT;
|
||||
case TYPE_LONG: return SIG_LONG;
|
||||
case TYPE_FLOAT: return SIG_FLOAT;
|
||||
case TYPE_DOUBLE: return SIG_DOUBLE;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Primitive";
|
||||
}
|
||||
|
||||
/**
|
||||
* IDL_Naming
|
||||
* Return the fully qualified IDL name for this type (e.g. com.acme.Dynamite would
|
||||
* return "com::acme::Dynamite").
|
||||
* @param global If true, prepends "::".
|
||||
*/
|
||||
public String getQualifiedIDLName(boolean global) {
|
||||
return super.getQualifiedIDLName(false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/*
|
||||
* Load a Class instance. Return null if fail.
|
||||
*/
|
||||
protected Class loadClass() {
|
||||
switch (getTypeCode()) {
|
||||
case TYPE_VOID: return Null.class;
|
||||
case TYPE_BOOLEAN: return boolean.class;
|
||||
case TYPE_BYTE: return byte.class;
|
||||
case TYPE_CHAR: return char.class;
|
||||
case TYPE_SHORT: return short.class;
|
||||
case TYPE_INT: return int.class;
|
||||
case TYPE_LONG: return long.class;
|
||||
case TYPE_FLOAT: return float.class;
|
||||
case TYPE_DOUBLE: return double.class;
|
||||
default: throw new CompilerError("Not a primitive type");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IDL_Naming
|
||||
* Create an PrimitiveType instance for the given class.
|
||||
*/
|
||||
private PrimitiveType(ContextStack stack, int typeCode) {
|
||||
super(stack,typeCode | TM_PRIMITIVE);
|
||||
|
||||
// Validate type and set names...
|
||||
|
||||
String idlName = IDLNames.getTypeName(typeCode,false);
|
||||
Identifier id = null;
|
||||
|
||||
switch (typeCode) {
|
||||
case TYPE_VOID: id = idVoid; break;
|
||||
case TYPE_BOOLEAN: id = idBoolean; break;
|
||||
case TYPE_BYTE: id = idByte; break;
|
||||
case TYPE_CHAR: id = idChar; break;
|
||||
case TYPE_SHORT: id = idShort; break;
|
||||
case TYPE_INT: id = idInt; break;
|
||||
case TYPE_LONG: id = idLong; break;
|
||||
case TYPE_FLOAT: id = idFloat; break;
|
||||
case TYPE_DOUBLE: id = idDouble; break;
|
||||
default: throw new CompilerError("Not a primitive type");
|
||||
}
|
||||
|
||||
setNames(id,null,idlName);
|
||||
setRepositoryID();
|
||||
}
|
||||
}
|
||||
|
||||
class Null {}
|
||||
171
jdkSrc/jdk8/sun/rmi/rmic/iiop/PrintGenerator.java
Normal file
171
jdkSrc/jdk8/sun/rmi/rmic/iiop/PrintGenerator.java
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.rmi.rmic.IndentingWriter;
|
||||
import sun.rmi.rmic.Main;
|
||||
|
||||
/**
|
||||
* An IDL generator for rmic.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class PrintGenerator implements sun.rmi.rmic.Generator,
|
||||
sun.rmi.rmic.iiop.Constants {
|
||||
|
||||
private static final int JAVA = 0;
|
||||
private static final int IDL = 1;
|
||||
private static final int BOTH = 2;
|
||||
|
||||
private int whatToPrint; // Initialized in parseArgs.
|
||||
private boolean global = false;
|
||||
private boolean qualified = false;
|
||||
private boolean trace = false;
|
||||
private boolean valueMethods = false;
|
||||
|
||||
private IndentingWriter out;
|
||||
|
||||
/**
|
||||
* Default constructor for Main to use.
|
||||
*/
|
||||
public PrintGenerator() {
|
||||
OutputStreamWriter writer = new OutputStreamWriter(System.out);
|
||||
out = new IndentingWriter (writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Examine and consume command line arguments.
|
||||
* @param argv The command line arguments. Ignore null
|
||||
* @param error Report any errors using the main.error() methods.
|
||||
* @return true if no errors, false otherwise.
|
||||
*/
|
||||
public boolean parseArgs(String argv[], Main main) {
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
if (argv[i] != null) {
|
||||
String arg = argv[i].toLowerCase();
|
||||
if (arg.equals("-xprint")) {
|
||||
whatToPrint = JAVA;
|
||||
argv[i] = null;
|
||||
if (i+1 < argv.length) {
|
||||
if (argv[i+1].equalsIgnoreCase("idl")) {
|
||||
argv[++i] = null;
|
||||
whatToPrint = IDL;
|
||||
} else if (argv[i+1].equalsIgnoreCase("both")) {
|
||||
argv[++i] = null;
|
||||
whatToPrint = BOTH;
|
||||
}
|
||||
}
|
||||
} else if (arg.equals("-xglobal")) {
|
||||
global = true;
|
||||
argv[i] = null;
|
||||
} else if (arg.equals("-xqualified")) {
|
||||
qualified = true;
|
||||
argv[i] = null;
|
||||
} else if (arg.equals("-xtrace")) {
|
||||
trace = true;
|
||||
argv[i] = null;
|
||||
} else if (arg.equals("-xvaluemethods")) {
|
||||
valueMethods = true;
|
||||
argv[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate output. Any source files created which need compilation should
|
||||
* be added to the compiler environment using the addGeneratedFile(File)
|
||||
* method.
|
||||
*
|
||||
* @param env The compiler environment
|
||||
* @param cdef The definition for the implementation class or interface from
|
||||
* which to generate output
|
||||
* @param destDir The directory for the root of the package hierarchy
|
||||
* for generated files. May be null.
|
||||
*/
|
||||
public void generate(sun.rmi.rmic.BatchEnvironment env, ClassDefinition cdef, File destDir) {
|
||||
|
||||
BatchEnvironment ourEnv = (BatchEnvironment) env;
|
||||
ContextStack stack = new ContextStack(ourEnv);
|
||||
stack.setTrace(trace);
|
||||
|
||||
if (valueMethods) {
|
||||
ourEnv.setParseNonConforming(true);
|
||||
}
|
||||
|
||||
// Get our top level type...
|
||||
|
||||
CompoundType topType = CompoundType.forCompound(cdef,stack);
|
||||
|
||||
if (topType != null) {
|
||||
|
||||
try {
|
||||
|
||||
// Collect up all the compound types...
|
||||
|
||||
Type[] theTypes = topType.collectMatching(TM_COMPOUND);
|
||||
|
||||
for (int i = 0; i < theTypes.length; i++) {
|
||||
|
||||
out.pln("\n-----------------------------------------------------------\n");
|
||||
|
||||
Type theType = theTypes[i];
|
||||
|
||||
switch (whatToPrint) {
|
||||
case JAVA: theType.println(out,qualified,false,false);
|
||||
break;
|
||||
|
||||
case IDL: theType.println(out,qualified,true,global);
|
||||
break;
|
||||
|
||||
case BOTH: theType.println(out,qualified,false,false);
|
||||
theType.println(out,qualified,true,global);
|
||||
break;
|
||||
|
||||
default: throw new CompilerError("Unknown type!");
|
||||
}
|
||||
}
|
||||
|
||||
out.flush();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new CompilerError("PrintGenerator caught " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
251
jdkSrc/jdk8/sun/rmi/rmic/iiop/RemoteType.java
Normal file
251
jdkSrc/jdk8/sun/rmi/rmic/iiop/RemoteType.java
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
|
||||
/**
|
||||
* RemoteType represents any non-special interface which inherits
|
||||
* from java.rmi.Remote.
|
||||
* <p>
|
||||
* The static forRemote(...) method must be used to obtain an instance, and will
|
||||
* return null if the ClassDefinition is non-conforming.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class RemoteType extends InterfaceType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an RemoteType for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static RemoteType forRemote(ClassDefinition classDef,
|
||||
ContextStack stack,
|
||||
boolean quiet) {
|
||||
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
boolean doPop = false;
|
||||
RemoteType result = null;
|
||||
|
||||
try {
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
Type existing = getType(theType,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof RemoteType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (RemoteType) existing;
|
||||
}
|
||||
|
||||
// Could this be a remote type?
|
||||
|
||||
if (couldBeRemote(quiet,stack,classDef)) {
|
||||
|
||||
// Yes, so check it...
|
||||
|
||||
RemoteType it = new RemoteType(stack,classDef);
|
||||
putType(theType,it,stack);
|
||||
stack.push(it);
|
||||
doPop = true;
|
||||
|
||||
if (it.initialize(quiet,stack)) {
|
||||
stack.pop(true);
|
||||
result = it;
|
||||
} else {
|
||||
removeType(theType,stack);
|
||||
stack.pop(false);
|
||||
}
|
||||
}
|
||||
} catch (CompilerError e) {
|
||||
if (doPop) stack.pop(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Remote interface";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal/Subclass Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a RemoteType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
protected RemoteType(ContextStack stack, ClassDefinition classDef) {
|
||||
super(stack,classDef,TYPE_REMOTE | TM_INTERFACE | TM_COMPOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a RemoteType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
protected RemoteType(ContextStack stack, ClassDefinition classDef, int typeCode) {
|
||||
super(stack,classDef,typeCode);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
|
||||
private static boolean couldBeRemote (boolean quiet, ContextStack stack,
|
||||
ClassDefinition classDef) {
|
||||
|
||||
boolean result = false;
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
|
||||
try {
|
||||
if (!classDef.isInterface()) {
|
||||
failedConstraint(16,quiet,stack,classDef.getName());
|
||||
} else {
|
||||
result = env.defRemote.implementedBy(env,classDef.getClassDeclaration());
|
||||
if (!result) failedConstraint(1,quiet,stack,classDef.getName());
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (boolean quiet,ContextStack stack) {
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// Go check it out and gather up the info we need...
|
||||
|
||||
Vector directInterfaces = new Vector();
|
||||
Vector directMethods = new Vector();
|
||||
Vector directConstants = new Vector();
|
||||
|
||||
if (isConformingRemoteInterface(directInterfaces,
|
||||
directMethods,
|
||||
directConstants,
|
||||
quiet,
|
||||
stack)){
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
result = initialize(directInterfaces,directMethods,directConstants,stack,quiet);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to ensure that the interface and all it's methods and arguments
|
||||
* conforms to the RMI/IDL java subset for remote interfaces as defined
|
||||
* by the "Java to IDL Mapping" specification, section 4.
|
||||
* @param directInterfaces All directly implmented interfaces will be
|
||||
* added to this list.
|
||||
* @param directMethods All directly implemented methods (other than
|
||||
* constructors and initializers) will be added to this list.
|
||||
* @param directConstants All constants defined by theInterface will be
|
||||
* added to this list.
|
||||
* @param quiet True if should not report constraint failures.
|
||||
* @return true if constraints satisfied, false otherwise.
|
||||
*/
|
||||
private boolean isConformingRemoteInterface ( Vector directInterfaces,
|
||||
Vector directMethods,
|
||||
Vector directConstants,
|
||||
boolean quiet,
|
||||
ContextStack stack) {
|
||||
|
||||
ClassDefinition theInterface = getClassDefinition();
|
||||
|
||||
try {
|
||||
|
||||
// Get all remote interfaces...
|
||||
|
||||
if (addRemoteInterfaces(directInterfaces,false,stack) == null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure all constants are conforming...
|
||||
|
||||
if (!addAllMembers(directConstants,true,quiet,stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now, collect up all methods...
|
||||
|
||||
if (addAllMethods(theInterface,directMethods,true,quiet,stack) == null) {
|
||||
// Failed a constraint check...
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now walk 'em, ensuring each is a valid remote method...
|
||||
|
||||
boolean methodsConform = true;
|
||||
for (int i = 0; i < directMethods.size(); i++) {
|
||||
if (! isConformingRemoteMethod((Method) directMethods.elementAt(i),quiet)) {
|
||||
methodsConform = false;
|
||||
}
|
||||
}
|
||||
if (!methodsConform) {
|
||||
return false;
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
171
jdkSrc/jdk8/sun/rmi/rmic/iiop/SpecialClassType.java
Normal file
171
jdkSrc/jdk8/sun/rmi/rmic/iiop/SpecialClassType.java
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* SpecialClassType represents any one of the following types:
|
||||
* <pre>
|
||||
* java.lang.Object
|
||||
* java.lang.String
|
||||
* </pre>
|
||||
* all of which are treated as special cases.
|
||||
* <p>
|
||||
* The static forSpecial(...) method must be used to obtain an instance, and
|
||||
* will return null if the type is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class SpecialClassType extends ClassType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a SpecialClassType object for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static SpecialClassType forSpecial (ClassDefinition theClass,
|
||||
ContextStack stack) {
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
sun.tools.java.Type type = theClass.getType();
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
String typeKey = type.toString() + stack.getContextCodeString();
|
||||
|
||||
Type existing = getType(typeKey,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof SpecialClassType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (SpecialClassType) existing;
|
||||
}
|
||||
|
||||
// Is it a special type?
|
||||
|
||||
int typeCode = getTypeCode(type,theClass,stack);
|
||||
|
||||
if (typeCode != TYPE_NONE) {
|
||||
|
||||
// Yes...
|
||||
|
||||
SpecialClassType result = new SpecialClassType(stack,typeCode,theClass);
|
||||
putType(typeKey,result,stack);
|
||||
stack.push(result);
|
||||
stack.pop(true);
|
||||
return result;
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Special class";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an SpecialClassType instance for the given class.
|
||||
*/
|
||||
private SpecialClassType(ContextStack stack, int typeCode,
|
||||
ClassDefinition theClass) {
|
||||
super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
|
||||
Identifier id = theClass.getName();
|
||||
String idlName = null;
|
||||
String[] idlModuleName = null;
|
||||
boolean constant = stack.size() > 0 && stack.getContext().isConstant();
|
||||
|
||||
// Set names...
|
||||
|
||||
switch (typeCode) {
|
||||
case TYPE_STRING: {
|
||||
idlName = IDLNames.getTypeName(typeCode,constant);
|
||||
if (!constant) {
|
||||
idlModuleName = IDL_CORBA_MODULE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_ANY: {
|
||||
idlName = IDL_JAVA_LANG_OBJECT;
|
||||
idlModuleName = IDL_JAVA_LANG_MODULE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setNames(id,idlModuleName,idlName);
|
||||
|
||||
// Init parents...
|
||||
|
||||
if (!initParents(stack)) {
|
||||
|
||||
// Should not be possible!
|
||||
|
||||
throw new CompilerError("SpecialClassType found invalid parent.");
|
||||
}
|
||||
|
||||
// Initialize CompoundType...
|
||||
|
||||
initialize(null,null,null,stack,false);
|
||||
}
|
||||
|
||||
private static int getTypeCode(sun.tools.java.Type type, ClassDefinition theClass, ContextStack stack) {
|
||||
if (type.isType(TC_CLASS)) {
|
||||
Identifier id = type.getClassName();
|
||||
if (id == idJavaLangString) return TYPE_STRING;
|
||||
if (id == idJavaLangObject) return TYPE_ANY;
|
||||
}
|
||||
return TYPE_NONE;
|
||||
}
|
||||
}
|
||||
233
jdkSrc/jdk8/sun/rmi/rmic/iiop/SpecialInterfaceType.java
Normal file
233
jdkSrc/jdk8/sun/rmi/rmic/iiop/SpecialInterfaceType.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.CompilerError;
|
||||
import sun.tools.java.Identifier;
|
||||
import sun.tools.java.ClassDeclaration;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
|
||||
/**
|
||||
* SpecialInterfaceType represents any one of the following types:
|
||||
* <pre>
|
||||
* java.rmi.Remote
|
||||
* java.io.Serializable
|
||||
* java.io.Externalizable
|
||||
* org.omg.CORBA.Object
|
||||
* org.omg.CORBA.portable.IDLEntity
|
||||
* </pre>
|
||||
* all of which are treated as special cases. For all but CORBA.Object,
|
||||
* the type must match exactly. For CORBA.Object, the type must either be
|
||||
* CORBA.Object or inherit from it.
|
||||
* <p>
|
||||
* The static forSpecial(...) method must be used to obtain an instance, and
|
||||
* will return null if the type is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class SpecialInterfaceType extends InterfaceType {
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a SpecialInterfaceType object for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static SpecialInterfaceType forSpecial ( ClassDefinition theClass,
|
||||
ContextStack stack) {
|
||||
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type type = theClass.getType();
|
||||
Type existing = getType(type,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof SpecialInterfaceType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (SpecialInterfaceType) existing;
|
||||
}
|
||||
|
||||
// Is it special?
|
||||
|
||||
if (isSpecial(type,theClass,stack)) {
|
||||
|
||||
// Yes...
|
||||
|
||||
SpecialInterfaceType result = new SpecialInterfaceType(stack,0,theClass);
|
||||
putType(type,result,stack);
|
||||
stack.push(result);
|
||||
|
||||
if (result.initialize(type,stack)) {
|
||||
stack.pop(true);
|
||||
return result;
|
||||
} else {
|
||||
removeType(type,stack);
|
||||
stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
return "Special interface";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an SpecialInterfaceType instance for the given class.
|
||||
*/
|
||||
private SpecialInterfaceType(ContextStack stack, int typeCode,
|
||||
ClassDefinition theClass) {
|
||||
super(stack,typeCode | TM_SPECIAL_INTERFACE | TM_INTERFACE | TM_COMPOUND, theClass);
|
||||
setNames(theClass.getName(),null,null); // Fixed in initialize.
|
||||
}
|
||||
|
||||
private static boolean isSpecial(sun.tools.java.Type type,
|
||||
ClassDefinition theClass,
|
||||
ContextStack stack) {
|
||||
if (type.isType(TC_CLASS)) {
|
||||
Identifier id = type.getClassName();
|
||||
|
||||
if (id.equals(idRemote)) return true;
|
||||
if (id == idJavaIoSerializable) return true;
|
||||
if (id == idJavaIoExternalizable) return true;
|
||||
if (id == idCorbaObject) return true;
|
||||
if (id == idIDLEntity) return true;
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
try {
|
||||
if (env.defCorbaObject.implementedBy(env,theClass.getClassDeclaration())) return true;
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean initialize(sun.tools.java.Type type, ContextStack stack) {
|
||||
|
||||
int typeCode = TYPE_NONE;
|
||||
Identifier id = null;
|
||||
String idlName = null;
|
||||
String[] idlModuleName = null;
|
||||
boolean constant = stack.size() > 0 && stack.getContext().isConstant();
|
||||
|
||||
if (type.isType(TC_CLASS)) {
|
||||
id = type.getClassName();
|
||||
|
||||
if (id.equals(idRemote)) {
|
||||
typeCode = TYPE_JAVA_RMI_REMOTE;
|
||||
idlName = IDL_JAVA_RMI_REMOTE;
|
||||
idlModuleName = IDL_JAVA_RMI_MODULE;
|
||||
} else if (id == idJavaIoSerializable) {
|
||||
typeCode = TYPE_ANY;
|
||||
idlName = IDL_SERIALIZABLE;
|
||||
idlModuleName = IDL_JAVA_IO_MODULE;
|
||||
} else if (id == idJavaIoExternalizable) {
|
||||
typeCode = TYPE_ANY;
|
||||
idlName = IDL_EXTERNALIZABLE;
|
||||
idlModuleName = IDL_JAVA_IO_MODULE;
|
||||
} else if (id == idIDLEntity) {
|
||||
typeCode = TYPE_ANY;
|
||||
idlName = IDL_IDLENTITY;
|
||||
idlModuleName = IDL_ORG_OMG_CORBA_PORTABLE_MODULE;
|
||||
} else {
|
||||
|
||||
typeCode = TYPE_CORBA_OBJECT;
|
||||
|
||||
// Is it exactly org.omg.CORBA.Object?
|
||||
|
||||
if (id == idCorbaObject) {
|
||||
|
||||
// Yes, so special case...
|
||||
|
||||
idlName = IDLNames.getTypeName(typeCode,constant);
|
||||
idlModuleName = null;
|
||||
|
||||
} else {
|
||||
|
||||
// No, so get the correct names...
|
||||
|
||||
try {
|
||||
|
||||
// These can fail if we get case-sensitive name matches...
|
||||
|
||||
idlName = IDLNames.getClassOrInterfaceName(id,env);
|
||||
idlModuleName = IDLNames.getModuleNames(id,isBoxed(),env);
|
||||
|
||||
} catch (Exception e) {
|
||||
failedConstraint(7,false,stack,id.toString(),e.getMessage());
|
||||
throw new CompilerError("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeCode == TYPE_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset type code...
|
||||
|
||||
setTypeCode(typeCode | TM_SPECIAL_INTERFACE | TM_INTERFACE | TM_COMPOUND);
|
||||
|
||||
// Set names
|
||||
|
||||
if (idlName == null) {
|
||||
throw new CompilerError("Not a special type");
|
||||
}
|
||||
|
||||
setNames(id,idlModuleName,idlName);
|
||||
|
||||
// Initialize CompoundType...
|
||||
|
||||
return initialize(null,null,null,stack,false);
|
||||
}
|
||||
}
|
||||
372
jdkSrc/jdk8/sun/rmi/rmic/iiop/StaticStringsHash.java
Normal file
372
jdkSrc/jdk8/sun/rmi/rmic/iiop/StaticStringsHash.java
Normal file
@@ -0,0 +1,372 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
/**
|
||||
* StaticStringsHash takes an array of constant strings and
|
||||
* uses several different hash methods to try to find the
|
||||
* 'best' one for that set. The set of methods is currently
|
||||
* fixed, but with a little work could be made extensible thru
|
||||
* subclassing.
|
||||
* <p>
|
||||
* The current set of methods is:
|
||||
* <ol>
|
||||
* <li> length() - works well when all strings are different length.</li>
|
||||
* <li> charAt(n) - works well when one offset into all strings is different.</li>
|
||||
* <li> hashCode() - works well with larger arrays.</li>
|
||||
* </ol>
|
||||
* After constructing an instance over the set of strings, the
|
||||
* <code>getKey(String)</code> method can be used to use the selected hash
|
||||
* method to produce a key. The <code>method</code> string will contain
|
||||
* "length()", "charAt(n)", or "hashCode()", and is intended for use by
|
||||
* code generators.
|
||||
* <p>
|
||||
* The <code>keys</code> array will contain the full set of unique keys.
|
||||
* <p>
|
||||
* The <code>buckets</code> array will contain a set of arrays, one for
|
||||
* each key in the <code>keys</code>, where <code>buckets[x][y]</code>
|
||||
* is an index into the <code>strings</code> array.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class StaticStringsHash {
|
||||
|
||||
/** The set of strings upon which the hash info is created */
|
||||
public String[] strings = null;
|
||||
|
||||
/** Unique hash keys */
|
||||
public int[] keys = null;
|
||||
|
||||
/** Buckets for each key, where buckets[x][y] is an index
|
||||
* into the strings[] array. */
|
||||
public int[][] buckets = null;
|
||||
|
||||
/** The method to invoke on String to produce the hash key */
|
||||
public String method = null;
|
||||
|
||||
/** Get a key for the given string using the
|
||||
* selected hash method.
|
||||
* @param str the string to return a key for.
|
||||
* @return the key.
|
||||
*/
|
||||
public int getKey(String str) {
|
||||
switch (keyKind) {
|
||||
case LENGTH: return str.length();
|
||||
case CHAR_AT: return str.charAt(charAt);
|
||||
case HASH_CODE: return str.hashCode();
|
||||
}
|
||||
throw new Error("Bad keyKind");
|
||||
}
|
||||
|
||||
/** Constructor
|
||||
* @param strings the set of strings upon which to
|
||||
* find an optimal hash method. Must not contain
|
||||
* duplicates.
|
||||
*/
|
||||
public StaticStringsHash(String[] strings) {
|
||||
this.strings = strings;
|
||||
length = strings.length;
|
||||
tempKeys = new int[length];
|
||||
bucketSizes = new int[length];
|
||||
setMinStringLength();
|
||||
|
||||
// Decide on the best algorithm based on
|
||||
// which one has the smallest maximum
|
||||
// bucket depth. First, try length()...
|
||||
|
||||
int currentMaxDepth = getKeys(LENGTH);
|
||||
int useCharAt = -1;
|
||||
boolean useHashCode = false;
|
||||
|
||||
if (currentMaxDepth > 1) {
|
||||
|
||||
// At least one bucket had more than one
|
||||
// entry, so try charAt(i). If there
|
||||
// are a lot of strings in the array,
|
||||
// and minStringLength is large, limit
|
||||
// the search to a smaller number of
|
||||
// characters to avoid spending a lot
|
||||
// of time here that is most likely to
|
||||
// be pointless...
|
||||
|
||||
int minLength = minStringLength;
|
||||
if (length > CHAR_AT_MAX_LINES &&
|
||||
length * minLength > CHAR_AT_MAX_CHARS) {
|
||||
minLength = length/CHAR_AT_MAX_CHARS;
|
||||
}
|
||||
|
||||
charAt = 0;
|
||||
for (int i = 0; i < minLength; i++) {
|
||||
int charAtDepth = getKeys(CHAR_AT);
|
||||
if (charAtDepth < currentMaxDepth) {
|
||||
currentMaxDepth = charAtDepth;
|
||||
useCharAt = i;
|
||||
if (currentMaxDepth == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
charAt++;
|
||||
}
|
||||
charAt = useCharAt;
|
||||
|
||||
|
||||
if (currentMaxDepth > 1) {
|
||||
|
||||
// At least one bucket had more than one
|
||||
// entry, try hashCode().
|
||||
//
|
||||
// Since the cost of computing a full hashCode
|
||||
// (for the runtime target string) is much higher
|
||||
// than the previous methods, use it only if it is
|
||||
// substantially better. The definition of 'substantial'
|
||||
// here is not very well founded, and could be improved
|
||||
// with some further analysis ;^)
|
||||
|
||||
int hashCodeDepth = getKeys(HASH_CODE);
|
||||
if (hashCodeDepth < currentMaxDepth-3) {
|
||||
|
||||
// Using the full hashCode results in at least
|
||||
// 3 fewer entries in the worst bucket, so will
|
||||
// therefore avoid at least 3 calls to equals()
|
||||
// in the worst case.
|
||||
//
|
||||
// Note that using a number smaller than 3 could
|
||||
// result in using a hashCode when there are only
|
||||
// 2 strings in the array, and that would surely
|
||||
// be a poor performance choice.
|
||||
|
||||
useHashCode = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset keys if needed...
|
||||
|
||||
if (!useHashCode) {
|
||||
if (useCharAt >= 0) {
|
||||
|
||||
// Use the charAt(i) method...
|
||||
|
||||
getKeys(CHAR_AT);
|
||||
|
||||
} else {
|
||||
|
||||
// Use length method...
|
||||
|
||||
getKeys(LENGTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now allocate and fill our real hashKeys array...
|
||||
|
||||
keys = new int[bucketCount];
|
||||
System.arraycopy(tempKeys,0,keys,0,bucketCount);
|
||||
|
||||
// Sort keys and bucketSizes arrays...
|
||||
|
||||
boolean didSwap;
|
||||
do {
|
||||
didSwap = false;
|
||||
for (int i = 0; i < bucketCount - 1; i++) {
|
||||
if (keys[i] > keys[i+1]) {
|
||||
int temp = keys[i];
|
||||
keys[i] = keys[i+1];
|
||||
keys[i+1] = temp;
|
||||
temp = bucketSizes[i];
|
||||
bucketSizes[i] = bucketSizes[i+1];
|
||||
bucketSizes[i+1] = temp;
|
||||
didSwap = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (didSwap == true);
|
||||
|
||||
// Allocate our buckets array. Fill the string
|
||||
// index slot with an unused key so we can
|
||||
// determine which are free...
|
||||
|
||||
int unused = findUnusedKey();
|
||||
buckets = new int[bucketCount][];
|
||||
for (int i = 0; i < bucketCount; i++) {
|
||||
buckets[i] = new int[bucketSizes[i]];
|
||||
for (int j = 0; j < bucketSizes[i]; j++) {
|
||||
buckets[i][j] = unused;
|
||||
}
|
||||
}
|
||||
|
||||
// And fill it in...
|
||||
|
||||
for(int i = 0; i < strings.length; i++) {
|
||||
int key = getKey(strings[i]);
|
||||
for (int j = 0; j < bucketCount; j++) {
|
||||
if (keys[j] == key) {
|
||||
int k = 0;
|
||||
while (buckets[j][k] != unused) {
|
||||
k++;
|
||||
}
|
||||
buckets[j][k] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Print an optimized 'contains' method for the
|
||||
* argument strings
|
||||
*/
|
||||
public static void main (String[] args) {
|
||||
StaticStringsHash hash = new StaticStringsHash(args);
|
||||
System.out.println();
|
||||
System.out.println(" public boolean contains(String key) {");
|
||||
System.out.println(" switch (key."+hash.method+") {");
|
||||
for (int i = 0; i < hash.buckets.length; i++) {
|
||||
System.out.println(" case "+hash.keys[i]+": ");
|
||||
for (int j = 0; j < hash.buckets[i].length; j++) {
|
||||
if (j > 0) {
|
||||
System.out.print(" } else ");
|
||||
} else {
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println("if (key.equals(\""+ hash.strings[hash.buckets[i][j]] +"\")) {");
|
||||
System.out.println(" return true;");
|
||||
}
|
||||
System.out.println(" }");
|
||||
}
|
||||
System.out.println(" }");
|
||||
System.out.println(" return false;");
|
||||
System.out.println(" }");
|
||||
}
|
||||
|
||||
private int length;
|
||||
private int[] tempKeys;
|
||||
private int[] bucketSizes;
|
||||
private int bucketCount;
|
||||
private int maxDepth;
|
||||
private int minStringLength = Integer.MAX_VALUE;
|
||||
private int keyKind;
|
||||
private int charAt;
|
||||
|
||||
private static final int LENGTH = 0;
|
||||
private static final int CHAR_AT = 1;
|
||||
private static final int HASH_CODE = 2;
|
||||
|
||||
/* Determines the maximum number of charAt(i)
|
||||
* tests that will be done. The search is
|
||||
* limited because if the number of characters
|
||||
* is large enough, the likelyhood of finding
|
||||
* a good hash key based on this method is
|
||||
* low. The CHAR_AT_MAX_CHARS limit only
|
||||
* applies f there are more strings than
|
||||
* CHAR_AT_MAX_LINES.
|
||||
*/
|
||||
private static final int CHAR_AT_MAX_LINES = 50;
|
||||
private static final int CHAR_AT_MAX_CHARS = 1000;
|
||||
|
||||
private void resetKeys(int keyKind) {
|
||||
this.keyKind = keyKind;
|
||||
switch (keyKind) {
|
||||
case LENGTH: method = "length()"; break;
|
||||
case CHAR_AT: method = "charAt("+charAt+")"; break;
|
||||
case HASH_CODE: method = "hashCode()"; break;
|
||||
}
|
||||
maxDepth = 1;
|
||||
bucketCount = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
tempKeys[i] = 0;
|
||||
bucketSizes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void setMinStringLength() {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (strings[i].length() < minStringLength) {
|
||||
minStringLength = strings[i].length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int findUnusedKey() {
|
||||
int unused = 0;
|
||||
int keysLength = keys.length;
|
||||
|
||||
// Note that we just assume that resource
|
||||
// exhaustion will occur rather than an
|
||||
// infinite loop here if the set of keys
|
||||
// is very large.
|
||||
|
||||
while (true) {
|
||||
boolean match = false;
|
||||
for (int i = 0; i < keysLength; i++) {
|
||||
if (keys[i] == unused) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
unused--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return unused;
|
||||
}
|
||||
|
||||
private int getKeys(int methodKind) {
|
||||
resetKeys(methodKind);
|
||||
for(int i = 0; i < strings.length; i++) {
|
||||
addKey(getKey(strings[i]));
|
||||
}
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
private void addKey(int key) {
|
||||
|
||||
// Have we seen this one before?
|
||||
|
||||
boolean addIt = true;
|
||||
for (int j = 0; j < bucketCount; j++) {
|
||||
if (tempKeys[j] == key) {
|
||||
addIt = false;
|
||||
bucketSizes[j]++;
|
||||
if (bucketSizes[j] > maxDepth) {
|
||||
maxDepth = bucketSizes[j];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (addIt) {
|
||||
tempKeys[bucketCount] = key;
|
||||
bucketSizes[bucketCount] = 1;
|
||||
bucketCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
2380
jdkSrc/jdk8/sun/rmi/rmic/iiop/StubGenerator.java
Normal file
2380
jdkSrc/jdk8/sun/rmi/rmic/iiop/StubGenerator.java
Normal file
File diff suppressed because it is too large
Load Diff
1009
jdkSrc/jdk8/sun/rmi/rmic/iiop/Type.java
Normal file
1009
jdkSrc/jdk8/sun/rmi/rmic/iiop/Type.java
Normal file
File diff suppressed because it is too large
Load Diff
174
jdkSrc/jdk8/sun/rmi/rmic/iiop/Util.java
Normal file
174
jdkSrc/jdk8/sun/rmi/rmic/iiop/Util.java
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.io.File;
|
||||
import sun.tools.java.Identifier;
|
||||
|
||||
import com.sun.corba.se.impl.util.PackagePrefixChecker;
|
||||
|
||||
/**
|
||||
* Util provides static utility methods used by other rmic classes.
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
|
||||
public final class Util implements sun.rmi.rmic.Constants {
|
||||
|
||||
|
||||
public static String packagePrefix(){ return PackagePrefixChecker.packagePrefix();}
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory that should be used for output for a given
|
||||
* class.
|
||||
* @param theClass The fully qualified name of the class.
|
||||
* @param rootDir The directory to use as the root of the
|
||||
* package heirarchy. May be null, in which case the current
|
||||
* working directory is used as the root.
|
||||
*/
|
||||
private static File getOutputDirectoryFor(Identifier theClass,
|
||||
File rootDir,
|
||||
BatchEnvironment env,
|
||||
boolean idl ) {
|
||||
File outputDir = null;
|
||||
String className = theClass.getFlatName().toString().replace('.', SIGC_INNERCLASS);
|
||||
String qualifiedClassName = className;
|
||||
String packagePath = null;
|
||||
String packageName = theClass.getQualifier().toString();
|
||||
//Shift package names for stubs generated for interfaces.
|
||||
/*if(type.isInterface())*/
|
||||
packageName = correctPackageName(packageName, idl, env.getStandardPackage());
|
||||
//Done.
|
||||
if (packageName.length() > 0) {
|
||||
qualifiedClassName = packageName + "." + className;
|
||||
packagePath = packageName.replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
// Do we have a root directory?
|
||||
|
||||
if (rootDir != null) {
|
||||
|
||||
// Yes, do we have a package name?
|
||||
|
||||
if (packagePath != null) {
|
||||
|
||||
// Yes, so use it as the root. Open the directory...
|
||||
|
||||
outputDir = new File(rootDir, packagePath);
|
||||
|
||||
// Make sure the directory exists...
|
||||
|
||||
ensureDirectory(outputDir,env);
|
||||
|
||||
} else {
|
||||
|
||||
// Default package, so use root as output dir...
|
||||
|
||||
outputDir = rootDir;
|
||||
}
|
||||
} else {
|
||||
|
||||
// No root directory. Get the current working directory...
|
||||
|
||||
String workingDirPath = System.getProperty("user.dir");
|
||||
File workingDir = new File(workingDirPath);
|
||||
|
||||
// Do we have a package name?
|
||||
|
||||
if (packagePath == null) {
|
||||
|
||||
// No, so use working directory...
|
||||
|
||||
outputDir = workingDir;
|
||||
|
||||
} else {
|
||||
|
||||
// Yes, so use working directory as the root...
|
||||
|
||||
outputDir = new File(workingDir, packagePath);
|
||||
|
||||
// Make sure the directory exists...
|
||||
|
||||
ensureDirectory(outputDir,env);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, return the directory...
|
||||
|
||||
return outputDir;
|
||||
}
|
||||
|
||||
public static File getOutputDirectoryForIDL(Identifier theClass,
|
||||
File rootDir,
|
||||
BatchEnvironment env) {
|
||||
return getOutputDirectoryFor(theClass, rootDir, env, true);
|
||||
}
|
||||
|
||||
public static File getOutputDirectoryForStub(Identifier theClass,
|
||||
File rootDir,
|
||||
BatchEnvironment env) {
|
||||
return getOutputDirectoryFor(theClass, rootDir, env, false);
|
||||
}
|
||||
|
||||
private static void ensureDirectory (File dir, BatchEnvironment env) {
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
if (!dir.exists()) {
|
||||
env.error(0,"rmic.cannot.create.dir",dir.getAbsolutePath());
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String correctPackageName(
|
||||
String p, boolean idl, boolean standardPackage){
|
||||
if (idl){
|
||||
return p;
|
||||
} else {
|
||||
if (standardPackage) {
|
||||
return p;
|
||||
} else {
|
||||
return PackagePrefixChecker.correctPackageName(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOffendingPackage(String p){
|
||||
return PackagePrefixChecker.isOffendingPackage(p);
|
||||
}
|
||||
|
||||
public static boolean hasOffendingPrefix(String p){
|
||||
return PackagePrefixChecker.hasOffendingPrefix(p);
|
||||
}
|
||||
|
||||
}
|
||||
488
jdkSrc/jdk8/sun/rmi/rmic/iiop/ValueType.java
Normal file
488
jdkSrc/jdk8/sun/rmi/rmic/iiop/ValueType.java
Normal file
@@ -0,0 +1,488 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.rmi.rmic.iiop;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.tools.java.ClassNotFound;
|
||||
import sun.tools.java.ClassDeclaration;
|
||||
import sun.tools.java.ClassDefinition;
|
||||
import sun.tools.java.MemberDefinition;
|
||||
import java.util.Hashtable;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.io.ObjectStreamField;
|
||||
|
||||
|
||||
/**
|
||||
* ValueType represents any non-special class which does inherit from
|
||||
* java.io.Serializable and does not inherit from java.rmi.Remote.
|
||||
* <p>
|
||||
* The static forValue(...) method must be used to obtain an instance, and
|
||||
* will return null if the ClassDefinition is non-conforming.
|
||||
*
|
||||
* @author Bryan Atsatt
|
||||
*/
|
||||
public class ValueType extends ClassType {
|
||||
|
||||
private boolean isCustom;
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Public Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create an ValueType object for the given class.
|
||||
*
|
||||
* If the class is not a properly formed or if some other error occurs, the
|
||||
* return value will be null, and errors will have been reported to the
|
||||
* supplied BatchEnvironment.
|
||||
*/
|
||||
public static ValueType forValue(ClassDefinition classDef,
|
||||
ContextStack stack,
|
||||
boolean quiet) {
|
||||
|
||||
if (stack.anyErrors()) return null;
|
||||
|
||||
// Do we already have it?
|
||||
|
||||
sun.tools.java.Type theType = classDef.getType();
|
||||
String typeKey = theType.toString();
|
||||
Type existing = getType(typeKey,stack);
|
||||
|
||||
if (existing != null) {
|
||||
|
||||
if (!(existing instanceof ValueType)) return null; // False hit.
|
||||
|
||||
// Yep, so return it...
|
||||
|
||||
return (ValueType) existing;
|
||||
}
|
||||
|
||||
// Is this java.lang.Class?
|
||||
|
||||
boolean javaLangClass = false;
|
||||
|
||||
if (classDef.getClassDeclaration().getName() == idJavaLangClass) {
|
||||
|
||||
// Yes, so replace classDef with one for
|
||||
// javax.rmi.CORBA.ClassDesc...
|
||||
|
||||
javaLangClass = true;
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
ClassDeclaration decl = env.getClassDeclaration(idClassDesc);
|
||||
ClassDefinition def = null;
|
||||
|
||||
try {
|
||||
def = decl.getClassDefinition(env);
|
||||
} catch (ClassNotFound ex) {
|
||||
classNotFound(stack,ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
classDef = def;
|
||||
}
|
||||
|
||||
// Could this be a value?
|
||||
|
||||
if (couldBeValue(stack,classDef)) {
|
||||
|
||||
// Yes, so check it...
|
||||
|
||||
ValueType it = new ValueType(classDef,stack,javaLangClass);
|
||||
putType(typeKey,it,stack);
|
||||
stack.push(it);
|
||||
|
||||
if (it.initialize(stack,quiet)) {
|
||||
stack.pop(true);
|
||||
return it;
|
||||
} else {
|
||||
removeType(typeKey,stack);
|
||||
stack.pop(false);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a string describing this type.
|
||||
*/
|
||||
public String getTypeDescription () {
|
||||
String result = addExceptionDescription("Value");
|
||||
if (isCustom) {
|
||||
result = "Custom " + result;
|
||||
}
|
||||
if (isIDLEntity) {
|
||||
result = result + " [IDLEntity]";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this type is a "custom" type (i.e.
|
||||
* it implements java.io.Externalizable or has a
|
||||
* method with the following signature:
|
||||
*
|
||||
* private void writeObject(java.io.ObjectOutputStream out);
|
||||
*
|
||||
*/
|
||||
public boolean isCustom () {
|
||||
return isCustom;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Subclass/Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Create a ValueType instance for the given class. The resulting
|
||||
* object is not yet completely initialized.
|
||||
*/
|
||||
private ValueType(ClassDefinition classDef,
|
||||
ContextStack stack,
|
||||
boolean isMappedJavaLangClass) {
|
||||
super(stack,classDef,TYPE_VALUE | TM_CLASS | TM_COMPOUND);
|
||||
isCustom = false;
|
||||
|
||||
// If this is the mapped version of java.lang.Class,
|
||||
// set the non-IDL names back to java.lang.Class...
|
||||
|
||||
if (isMappedJavaLangClass) {
|
||||
setNames(idJavaLangClass,IDL_CLASS_MODULE,IDL_CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
// Internal Interfaces
|
||||
//_____________________________________________________________________
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
|
||||
private static boolean couldBeValue(ContextStack stack, ClassDefinition classDef) {
|
||||
|
||||
boolean result = false;
|
||||
ClassDeclaration classDecl = classDef.getClassDeclaration();
|
||||
BatchEnvironment env = stack.getEnv();
|
||||
|
||||
try {
|
||||
// Make sure it's not remote...
|
||||
|
||||
if (env.defRemote.implementedBy(env, classDecl)) {
|
||||
failedConstraint(10,false,stack,classDef.getName());
|
||||
} else {
|
||||
|
||||
// Make sure it's Serializable...
|
||||
|
||||
if (!env.defSerializable.implementedBy(env, classDecl)) {
|
||||
failedConstraint(11,false,stack,classDef.getName());
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this instance.
|
||||
*/
|
||||
private boolean initialize (ContextStack stack, boolean quiet) {
|
||||
|
||||
ClassDefinition ourDef = getClassDefinition();
|
||||
ClassDeclaration ourDecl = getClassDeclaration();
|
||||
|
||||
try {
|
||||
|
||||
// Make sure our parentage is ok...
|
||||
|
||||
if (!initParents(stack)) {
|
||||
failedConstraint(12,quiet,stack,getQualifiedName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// We're ok, so make up our collections...
|
||||
|
||||
Vector directInterfaces = new Vector();
|
||||
Vector directMethods = new Vector();
|
||||
Vector directMembers = new Vector();
|
||||
|
||||
// Get interfaces...
|
||||
|
||||
if (addNonRemoteInterfaces(directInterfaces,stack) != null) {
|
||||
|
||||
// Get methods...
|
||||
|
||||
if (addAllMethods(ourDef,directMethods,false,false,stack) != null) {
|
||||
|
||||
// Update parent class methods
|
||||
if (updateParentClassMethods(ourDef,directMethods,false,stack) != null) {
|
||||
|
||||
// Get constants and members...
|
||||
|
||||
if (addAllMembers(directMembers,false,false,stack)) {
|
||||
|
||||
// We're ok, so pass 'em up...
|
||||
|
||||
if (!initialize(directInterfaces,directMethods,directMembers,stack,quiet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is this class Externalizable?
|
||||
|
||||
boolean externalizable = false;
|
||||
if (!env.defExternalizable.implementedBy(env, ourDecl)) {
|
||||
|
||||
// No, so check to see if we have a serialPersistentField
|
||||
// that will modify the members.
|
||||
|
||||
if (!checkPersistentFields(getClassInstance(),quiet)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Yes.
|
||||
|
||||
externalizable = true;
|
||||
}
|
||||
|
||||
// Should this class be considered "custom"? It is if
|
||||
// it is Externalizable OR if it has a method with the
|
||||
// following signature:
|
||||
//
|
||||
// private void writeObject(java.io.ObjectOutputStream out);
|
||||
//
|
||||
|
||||
if (externalizable) {
|
||||
isCustom = true;
|
||||
} else {
|
||||
for (MemberDefinition member = ourDef.getFirstMember();
|
||||
member != null;
|
||||
member = member.getNextMember()) {
|
||||
|
||||
if (member.isMethod() &&
|
||||
!member.isInitializer() &&
|
||||
member.isPrivate() &&
|
||||
member.getName().toString().equals("writeObject")) {
|
||||
|
||||
// Check return type, arguments and exceptions...
|
||||
|
||||
sun.tools.java.Type methodType = member.getType();
|
||||
sun.tools.java.Type rtnType = methodType.getReturnType();
|
||||
|
||||
if (rtnType == sun.tools.java.Type.tVoid) {
|
||||
|
||||
// Return type is correct. How about arguments?
|
||||
|
||||
sun.tools.java.Type[] args = methodType.getArgumentTypes();
|
||||
if (args.length == 1 &&
|
||||
args[0].getTypeSignature().equals("Ljava/io/ObjectOutputStream;")) {
|
||||
|
||||
// Arguments are correct, so it is a custom
|
||||
// value type...
|
||||
|
||||
isCustom = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFound e) {
|
||||
classNotFound(stack,e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkPersistentFields (Class clz, boolean quiet) {
|
||||
|
||||
// Do we have a writeObject method?
|
||||
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].getName().equals("writeObject") &&
|
||||
methods[i].getArguments().length == 1) {
|
||||
|
||||
Type returnType = methods[i].getReturnType();
|
||||
Type arg = methods[i].getArguments()[0];
|
||||
String id = arg.getQualifiedName();
|
||||
|
||||
if (returnType.isType(TYPE_VOID) &&
|
||||
id.equals("java.io.ObjectOutputStream")) {
|
||||
|
||||
// Got one, so there's nothing to do...
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do we have a valid serialPersistentField array?
|
||||
|
||||
MemberDefinition spfDef = null;
|
||||
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals("serialPersistentFields")) {
|
||||
|
||||
Member member = members[i];
|
||||
Type type = member.getType();
|
||||
Type elementType = type.getElementType();
|
||||
|
||||
// We have a member with the correct name. Make sure
|
||||
// we have the correct signature...
|
||||
|
||||
if (elementType != null &&
|
||||
elementType.getQualifiedName().equals(
|
||||
"java.io.ObjectStreamField")
|
||||
) {
|
||||
|
||||
if (member.isStatic() &&
|
||||
member.isFinal() &&
|
||||
member.isPrivate()) {
|
||||
|
||||
// We have the correct signature
|
||||
|
||||
spfDef = member.getMemberDefinition();
|
||||
|
||||
} else {
|
||||
|
||||
// Bad signature...
|
||||
|
||||
failedConstraint(4,quiet,stack,getQualifiedName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we do not have a serialPersistentField,
|
||||
// there's nothing to do, so return with no error...
|
||||
|
||||
if (spfDef == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ok, now we must examine the contents of the array -
|
||||
// then validate them...
|
||||
|
||||
Hashtable fields = getPersistentFields(clz);
|
||||
boolean result = true;
|
||||
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
String fieldName = members[i].getName();
|
||||
String fieldType = members[i].getType().getSignature();
|
||||
|
||||
// Is this field present in the array?
|
||||
|
||||
String type = (String) fields.get(fieldName);
|
||||
|
||||
if (type == null) {
|
||||
|
||||
// No, so mark it transient...
|
||||
|
||||
members[i].setTransient();
|
||||
|
||||
} else {
|
||||
|
||||
// Yes, does the type match?
|
||||
|
||||
if (type.equals(fieldType)) {
|
||||
|
||||
// Yes, so remove it from the fields table...
|
||||
|
||||
fields.remove(fieldName);
|
||||
|
||||
} else {
|
||||
|
||||
// No, so error...
|
||||
|
||||
result = false;
|
||||
failedConstraint(2,quiet,stack,fieldName,getQualifiedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ok, we've checked all of our fields. Are there any left in the "array"?
|
||||
// If so, it's an error...
|
||||
|
||||
if (result && fields.size() > 0) {
|
||||
|
||||
result = false;
|
||||
failedConstraint(9,quiet,stack,getQualifiedName());
|
||||
}
|
||||
|
||||
// Return result...
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names and types of all the persistent fields of a Class.
|
||||
*/
|
||||
private Hashtable getPersistentFields (Class clz) {
|
||||
Hashtable result = new Hashtable();
|
||||
ObjectStreamClass osc = ObjectStreamClass.lookup(clz);
|
||||
if (osc != null) {
|
||||
ObjectStreamField[] fields = osc.getFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
String typeSig;
|
||||
String typePrefix = String.valueOf(fields[i].getTypeCode());
|
||||
if (fields[i].isPrimitive()) {
|
||||
typeSig = typePrefix;
|
||||
} else {
|
||||
if (fields[i].getTypeCode() == '[') {
|
||||
typePrefix = "";
|
||||
}
|
||||
typeSig = typePrefix + fields[i].getType().getName().replace('.','/');
|
||||
if (typeSig.endsWith(";")) {
|
||||
typeSig = typeSig.substring(0,typeSig.length()-1);
|
||||
}
|
||||
}
|
||||
result.put(fields[i].getName(),typeSig);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user