Code cleanup: remove some unnescessary casts

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@707937 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2008-10-26 04:31:28 +00:00
parent f01e6bd0d4
commit e1bd3c4dcb
73 changed files with 468 additions and 441 deletions

View File

@ -178,14 +178,14 @@ public class MappingToolTask
if (MappingTool.ACTION_IMPORT.equals(flags.action)) if (MappingTool.ACTION_IMPORT.equals(flags.action))
assertFiles(files); assertFiles(files);
ClassLoader toolLoader = (ClassLoader) AccessController ClassLoader toolLoader = AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.getClassLoaderAction(MappingTool.class)); .getClassLoaderAction(MappingTool.class));
ClassLoader loader = toolLoader; ClassLoader loader = toolLoader;
MultiLoaderClassResolver resolver = new MultiLoaderClassResolver(); MultiLoaderClassResolver resolver = new MultiLoaderClassResolver();
if (tmpClassLoader) { if (tmpClassLoader) {
loader = (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper loader = AccessController.doPrivileged(J2DoPrivHelper
.newTemporaryClassLoaderAction(getClassLoader())); .newTemporaryClassLoaderAction(getClassLoader()));
resolver.addClassLoader(loader); resolver.addClassLoader(loader);
} }

View File

@ -262,11 +262,11 @@ public class ReverseMappingToolTask
// load customizer properties // load customizer properties
Properties customProps = new Properties(); Properties customProps = new Properties();
File propsFile = Files.getFile(customizerProperties, loader); File propsFile = Files.getFile(customizerProperties, loader);
if (propsFile != null && ((Boolean) AccessController.doPrivileged( if (propsFile != null && (AccessController.doPrivileged(
J2DoPrivHelper.existsAction(propsFile))).booleanValue()) { J2DoPrivHelper.existsAction(propsFile))).booleanValue()) {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
fis = (FileInputStream) AccessController.doPrivileged( fis = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(propsFile)); J2DoPrivHelper.newFileInputStreamAction(propsFile));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (FileNotFoundException) pae.getException(); throw (FileNotFoundException) pae.getException();
@ -278,7 +278,7 @@ public class ReverseMappingToolTask
JDBCConfiguration conf = (JDBCConfiguration) getConfiguration(); JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
flags.customizer = (ReverseCustomizer) Configurations. flags.customizer = (ReverseCustomizer) Configurations.
newInstance(customizerClass, conf, null, newInstance(customizerClass, conf, null,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
ReverseCustomizer.class))); ReverseCustomizer.class)));
if (flags.customizer != null) if (flags.customizer != null)

View File

@ -48,7 +48,7 @@ public class MappingRepositoryValue
// we need to manually perform the instantiation // we need to manually perform the instantiation
try { try {
Class cls = Strings.toClass(clsName, Class cls = Strings.toClass(clsName,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(type))); J2DoPrivHelper.getClassLoaderAction(type)));
return cls.getConstructor(new Class[]{ JDBCConfiguration.class }). return cls.getConstructor(new Class[]{ JDBCConfiguration.class }).
newInstance(new Object[]{ conf }); newInstance(new Object[]{ conf });

View File

@ -467,7 +467,7 @@ public class MappingRepository
try { try {
if (strat == null) if (strat == null)
strat = JavaTypes.classForName(name, cls, strat = JavaTypes.classForName(name, cls,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
ClassStrategy.class))); ClassStrategy.class)));
ClassStrategy strategy = ClassStrategy strategy =
@ -501,7 +501,7 @@ public class MappingRepository
name = Configurations.getClassName(name); name = Configurations.getClassName(name);
try { try {
Class c = JavaTypes.classForName(name, field, Class c = JavaTypes.classForName(name, field,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class))); J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)));
if (FieldStrategy.class.isAssignableFrom(c)) { if (FieldStrategy.class.isAssignableFrom(c)) {
FieldStrategy strat = (FieldStrategy) FieldStrategy strat = (FieldStrategy)
@ -574,7 +574,7 @@ public class MappingRepository
if (strat == null) if (strat == null)
strat = JavaTypes.classForName(name, strat = JavaTypes.classForName(name,
discrim.getClassMapping(), discrim.getClassMapping(),
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
DiscriminatorStrategy.class))); DiscriminatorStrategy.class)));
DiscriminatorStrategy strategy = (DiscriminatorStrategy) DiscriminatorStrategy strategy = (DiscriminatorStrategy)
@ -640,7 +640,7 @@ public class MappingRepository
if (strat == null) if (strat == null)
strat = JavaTypes.classForName(name, strat = JavaTypes.classForName(name,
version.getClassMapping(), version.getClassMapping(),
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
VersionStrategy.class))); VersionStrategy.class)));
} catch (Exception e) { } catch (Exception e) {
@ -982,7 +982,7 @@ public class MappingRepository
name = Configurations.getClassName(name); name = Configurations.getClassName(name);
try { try {
Class c = JavaTypes.classForName(name, val, Class c = JavaTypes.classForName(name, val,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class))); J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)));
Object o = AccessController.doPrivileged( Object o = AccessController.doPrivileged(
J2DoPrivHelper.newInstanceAction(c)); J2DoPrivHelper.newInstanceAction(c));
@ -1009,7 +1009,7 @@ public class MappingRepository
name = Configurations.getClassName(name); name = Configurations.getClassName(name);
try { try {
Class c = JavaTypes.classForName(name, val, Class c = JavaTypes.classForName(name, val,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(ValueHandler.class))); J2DoPrivHelper.getClassLoaderAction(ValueHandler.class)));
if (ValueHandler.class.isAssignableFrom(c)) { if (ValueHandler.class.isAssignableFrom(c)) {
ValueHandler vh = (ValueHandler) AccessController.doPrivileged( ValueHandler vh = (ValueHandler) AccessController.doPrivileged(

View File

@ -179,7 +179,7 @@ public class ReverseMappingTool
private final Log _log; private final Log _log;
private final Map _tables = new HashMap(); private final Map _tables = new HashMap();
private final Project _project = new Project(); private final Project _project = new Project();
private final BCClassLoader _loader = (BCClassLoader) AccessController private final BCClassLoader _loader = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project)); .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project));
private StrategyInstaller _strat = null; private StrategyInstaller _strat = null;
private String _package = null; private String _package = null;
@ -1899,11 +1899,11 @@ public class ReverseMappingTool
File customFile = Files.getFile File customFile = Files.getFile
(opts.removeProperty("customizerProperties", "cp", null), null); (opts.removeProperty("customizerProperties", "cp", null), null);
Properties customProps = new Properties(); Properties customProps = new Properties();
if (customFile != null && ((Boolean) AccessController.doPrivileged( if (customFile != null && (AccessController.doPrivileged(
J2DoPrivHelper.existsAction(customFile))).booleanValue()) { J2DoPrivHelper.existsAction(customFile))).booleanValue()) {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
fis = (FileInputStream) AccessController.doPrivileged( fis = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(customFile)); J2DoPrivHelper.newFileInputStreamAction(customFile));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (FileNotFoundException) pae.getException(); throw (FileNotFoundException) pae.getException();

View File

@ -114,7 +114,7 @@ public class DataSourceFactory {
// see if their driver name is actually a data source // see if their driver name is actually a data source
if (DataSource.class.isAssignableFrom(driverClass)) { if (DataSource.class.isAssignableFrom(driverClass)) {
return (DataSource) Configurations.newInstance(driver, return (DataSource) Configurations.newInstance(driver,
conf, props, (ClassLoader) AccessController.doPrivileged( conf, props, AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
DataSource.class))); DataSource.class)));
} }

View File

@ -79,7 +79,7 @@ public class FileSchemaFactory
} }
public SchemaGroup readSchema() { public SchemaGroup readSchema() {
URL url = (URL) AccessController.doPrivileged( URL url = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(_loader, _fileName)); J2DoPrivHelper.getResourceAction(_loader, _fileName));
if (url == null) if (url == null)
return new SchemaGroup(); return new SchemaGroup();

View File

@ -117,7 +117,7 @@ public class DBDictionaryFactory {
DBDictionary dict = null; DBDictionary dict = null;
try { try {
Class c = Class.forName(dclass, true, Class c = Class.forName(dclass, true,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
DBDictionary.class))); DBDictionary.class)));
dict = (DBDictionary) AccessController.doPrivileged( dict = (DBDictionary) AccessController.doPrivileged(

View File

@ -133,10 +133,10 @@ public class AbstractStoreBrokerFactory
private static AbstractStoreManager createStoreManager(String cls, private static AbstractStoreManager createStoreManager(String cls,
String props) { String props) {
AbstractStoreManager store = (AbstractStoreManager) Configurations. AbstractStoreManager store =
newInstance(cls, (ClassLoader) AccessController.doPrivileged( (AbstractStoreManager) Configurations.newInstance(cls,
J2DoPrivHelper.getClassLoaderAction( AccessController.doPrivileged(J2DoPrivHelper
AbstractStoreManager.class))); .getClassLoaderAction(AbstractStoreManager.class)));
Configurations.configureInstance(store, null, props, Configurations.configureInstance(store, null, props,
PROP_ABSTRACT_STORE); PROP_ABSTRACT_STORE);
if (store == null) if (store == null)

View File

@ -111,10 +111,9 @@ public class OpenJPAVersion {
appendProperty("java.vendor", buf).append("\n\n"); appendProperty("java.vendor", buf).append("\n\n");
buf.append("java.class.path:\n"); buf.append("java.class.path:\n");
StringTokenizer tok = new StringTokenizer StringTokenizer tok =
((String) AccessController.doPrivileged( new StringTokenizer(AccessController.doPrivileged(J2DoPrivHelper
J2DoPrivHelper.getPropertyAction("java.class.path")), .getPropertyAction("java.class.path")), File.pathSeparator);
File.pathSeparator);
while (tok.hasMoreTokens()) { while (tok.hasMoreTokens()) {
buf.append("\t").append(tok.nextToken()); buf.append("\t").append(tok.nextToken());
buf.append("\n"); buf.append("\n");
@ -136,8 +135,8 @@ public class OpenJPAVersion {
} }
private StringBuffer appendProperty(String prop, StringBuffer buf) { private StringBuffer appendProperty(String prop, StringBuffer buf) {
return buf.append(prop).append(": ") return buf.append(prop).append(": ").append(
.append((String) AccessController.doPrivileged( AccessController.doPrivileged(J2DoPrivHelper
J2DoPrivHelper.getPropertyAction(prop))); .getPropertyAction(prop)));
} }
} }

View File

@ -78,10 +78,11 @@ public abstract class AbstractQueryCache
entityTimestampMap = new ConcurrentHashMap<String,Long>(); entityTimestampMap = new ConcurrentHashMap<String,Long>();
// Get all persistence types to pre-load the entityTimestamp Map // Get all persistence types to pre-load the entityTimestamp Map
Collection perTypes = conf.getMetaDataRepositoryInstance(). Collection perTypes =
getPersistentTypeNames(false, conf.getMetaDataRepositoryInstance().getPersistentTypeNames(
(ClassLoader) AccessController.doPrivileged( false,
J2DoPrivHelper.getContextClassLoaderAction())); AccessController.doPrivileged(J2DoPrivHelper
.getContextClassLoaderAction()));
// Pre-load all the entity types into the HashMap to handle // Pre-load all the entity types into the HashMap to handle
// synchronization on the map efficiently // synchronization on the map efficiently

View File

@ -99,9 +99,10 @@ public class DataCacheScheduler
_caches.put(cache, schedule); _caches.put(cache, schedule);
_stop = false; _stop = false;
if (_thread == null) { if (_thread == null) {
_thread = (Thread) AccessController.doPrivileged(J2DoPrivHelper _thread =
.newDaemonThreadAction(this, _loc.get("scheduler-name") AccessController.doPrivileged(J2DoPrivHelper
.getMessage())); .newDaemonThreadAction(this, _loc.get("scheduler-name")
.getMessage()));
_thread.start(); _thread.start();
if (_log.isTraceEnabled()) if (_log.isTraceEnabled())
_log.trace(_loc.get("scheduler-start", _thread.getName())); _log.trace(_loc.get("scheduler-start", _thread.getName()));

View File

@ -1370,7 +1370,7 @@ public class ApplicationIdTool {
ApplicationIdTool tool; ApplicationIdTool tool;
Class cls; Class cls;
ClassMetaData meta; ClassMetaData meta;
BCClassLoader bc = (BCClassLoader) AccessController BCClassLoader bc = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(new Project())); .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(new Project()));
for (Iterator itr = classes.iterator(); itr.hasNext();) { for (Iterator itr = classes.iterator(); itr.hasNext();) {
cls = (Class) itr.next(); cls = (Class) itr.next();
@ -1424,10 +1424,10 @@ public class ApplicationIdTool {
name = Strings.getPackageName(context) + "." + name; name = Strings.getPackageName(context) + "." + name;
// first try with regular class loader // first try with regular class loader
ClassLoader loader = (ClassLoader) AccessController.doPrivileged( ClassLoader loader = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(context)); J2DoPrivHelper.getClassLoaderAction(context));
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
try { try {
return Class.forName(name, false, loader); return Class.forName(name, false, loader);

View File

@ -96,9 +96,9 @@ public class DynamicStorageGenerator {
// the project/classloader for the classes. // the project/classloader for the classes.
private final Project _project = new Project(); private final Project _project = new Project();
private final BCClassLoader _loader = (BCClassLoader) AccessController private final BCClassLoader _loader =
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project, AccessController.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(
(ClassLoader) AccessController.doPrivileged(J2DoPrivHelper _project, AccessController.doPrivileged(J2DoPrivHelper
.getClassLoaderAction(DynamicStorage.class)))); .getClassLoaderAction(DynamicStorage.class))));
/** /**

View File

@ -144,7 +144,7 @@ public class PCEnhancer {
static { static {
Class[] classes = Services.getImplementorClasses( Class[] classes = Services.getImplementorClasses(
AuxiliaryEnhancer.class, AuxiliaryEnhancer.class,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(AuxiliaryEnhancer.class))); J2DoPrivHelper.getClassLoaderAction(AuxiliaryEnhancer.class)));
List auxEnhancers = new ArrayList(classes.length); List auxEnhancers = new ArrayList(classes.length);
for (int i = 0; i < classes.length; i++) { for (int i = 0; i < classes.length; i++) {
@ -185,7 +185,7 @@ public class PCEnhancer {
* repository. * repository.
*/ */
public PCEnhancer(OpenJPAConfiguration conf, Class type) { public PCEnhancer(OpenJPAConfiguration conf, Class type) {
this(conf, (BCClass) AccessController.doPrivileged(J2DoPrivHelper this(conf, AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(new Project(), type)), .loadProjectClassAction(new Project(), type)),
(MetaDataRepository) null); (MetaDataRepository) null);
} }
@ -196,7 +196,7 @@ public class PCEnhancer {
* and then loading from <code>conf</code>'s repository. * and then loading from <code>conf</code>'s repository.
*/ */
public PCEnhancer(OpenJPAConfiguration conf, ClassMetaData meta) { public PCEnhancer(OpenJPAConfiguration conf, ClassMetaData meta) {
this(conf, (BCClass) AccessController.doPrivileged(J2DoPrivHelper this(conf, AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(new Project(), meta.getDescribedType())), .loadProjectClassAction(new Project(), meta.getDescribedType())),
meta.getRepository()); meta.getRepository());
} }
@ -730,7 +730,7 @@ public class PCEnhancer {
* Package-protected and static for testing. * Package-protected and static for testing.
*/ */
static BCField getReturnedField(BCMethod meth) { static BCField getReturnedField(BCMethod meth) {
return findField(meth, ((Code) AccessController.doPrivileged( return findField(meth, (AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction())).xreturn() J2DoPrivHelper.newCodeAction())).xreturn()
.setType(meth.getReturnType()), false); .setType(meth.getReturnType()), false);
} }
@ -740,7 +740,7 @@ public class PCEnhancer {
* Package-protected and static for testing. * Package-protected and static for testing.
*/ */
static BCField getAssignedField(BCMethod meth) { static BCField getAssignedField(BCMethod meth) {
return findField(meth, ((Code) AccessController.doPrivileged( return findField(meth, (AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction())).putfield(), true); J2DoPrivHelper.newCodeAction())).putfield(), true);
} }
@ -791,7 +791,7 @@ public class PCEnhancer {
// field that's being accessed // field that's being accessed
if (!findAccessed && prevIns instanceof GetFieldInstruction) { if (!findAccessed && prevIns instanceof GetFieldInstruction) {
final FieldInstruction fPrevIns = (FieldInstruction) prevIns; final FieldInstruction fPrevIns = (FieldInstruction) prevIns;
cur = (BCField) AccessController.doPrivileged( cur = AccessController.doPrivileged(
J2DoPrivHelper.getFieldInstructionFieldAction(fPrevIns)); J2DoPrivHelper.getFieldInstructionFieldAction(fPrevIns));
// if the middle instruction was an xload_1, then the // if the middle instruction was an xload_1, then the
// matched instruction is the field that's being set. // matched instruction is the field that's being set.
@ -799,7 +799,7 @@ public class PCEnhancer {
&& ((LoadInstruction) prevIns).getParam() == 0) { && ((LoadInstruction) prevIns).getParam() == 0) {
final FieldInstruction fTemplateIns = final FieldInstruction fTemplateIns =
(FieldInstruction) templateIns; (FieldInstruction) templateIns;
cur = (BCField) AccessController.doPrivileged(J2DoPrivHelper cur = AccessController.doPrivileged(J2DoPrivHelper
.getFieldInstructionFieldAction(fTemplateIns)); .getFieldInstructionFieldAction(fTemplateIns));
} else } else
return null; return null;
@ -856,7 +856,7 @@ public class PCEnhancer {
*/ */
private void replaceAndValidateFieldAccess() throws NoSuchMethodException { private void replaceAndValidateFieldAccess() throws NoSuchMethodException {
// create template putfield/getfield instructions to search for // create template putfield/getfield instructions to search for
Code template = (Code) AccessController.doPrivileged( Code template = AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction()); J2DoPrivHelper.newCodeAction());
Instruction put = template.putfield(); Instruction put = template.putfield();
Instruction get = template.getfield(); Instruction get = template.getfield();
@ -958,7 +958,7 @@ public class PCEnhancer {
loadManagedInstance(code, false); loadManagedInstance(code, false);
final FieldInstruction fFi = fi; final FieldInstruction fFi = fi;
code.getfield().setField( code.getfield().setField(
(BCField) AccessController.doPrivileged(J2DoPrivHelper AccessController.doPrivileged(J2DoPrivHelper
.getFieldInstructionFieldAction(fFi))); .getFieldInstructionFieldAction(fFi)));
int val = code.getNextLocalsIndex(); int val = code.getNextLocalsIndex();
code.xstore().setLocal(val).setType(fi.getFieldType()); code.xstore().setLocal(val).setType(fi.getFieldType());
@ -1569,55 +1569,55 @@ public class PCEnhancer {
try { try {
// pcGetGenericContext // pcGetGenericContext
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "get" + CONTEXTNAME, (Class[]) null)), false); SMTYPE, "get" + CONTEXTNAME, (Class[]) null)), false);
// pcFetchObjectId // pcFetchObjectId
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "fetchObjectId", (Class[]) null)), false); SMTYPE, "fetchObjectId", (Class[]) null)), false);
// pcIsDeleted // pcIsDeleted
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "isDeleted", (Class[]) null)), false); SMTYPE, "isDeleted", (Class[]) null)), false);
// pcIsDirty // pcIsDirty
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "isDirty", (Class[]) null)), true); SMTYPE, "isDirty", (Class[]) null)), true);
// pcIsNew // pcIsNew
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "isNew", (Class[]) null)), false); SMTYPE, "isNew", (Class[]) null)), false);
// pcIsPersistent // pcIsPersistent
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "isPersistent", (Class[]) null)), false); SMTYPE, "isPersistent", (Class[]) null)), false);
// pcIsTransactional // pcIsTransactional
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "isTransactional", (Class[]) null)), false); SMTYPE, "isTransactional", (Class[]) null)), false);
// pcSerializing // pcSerializing
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "serializing", (Class[]) null)), false); SMTYPE, "serializing", (Class[]) null)), false);
// pcDirty // pcDirty
translateFromStateManagerMethod( translateFromStateManagerMethod(
(Method) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
SMTYPE, "dirty", new Class[]{ String.class })), false); SMTYPE, "dirty", new Class[]{ String.class })), false);
@ -2595,7 +2595,7 @@ public class PCEnhancer {
Class[] params = (Class[]) plist.toArray(new Class[plist.size()]); Class[] params = (Class[]) plist.toArray(new Class[plist.size()]);
try { try {
return (Method) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction(owner, name, params)); J2DoPrivHelper.getDeclaredMethodAction(owner, name, params));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (NoSuchMethodException) pae.getException(); throw (NoSuchMethodException) pae.getException();
@ -2956,7 +2956,7 @@ public class PCEnhancer {
code.vreturn(); code.vreturn();
} }
Instruction tmplate = ((Code) AccessController.doPrivileged( Instruction tmplate = (AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction())).vreturn(); J2DoPrivHelper.newCodeAction())).vreturn();
JumpInstruction toret; JumpInstruction toret;
Instruction ret; Instruction ret;
@ -3267,7 +3267,7 @@ public class PCEnhancer {
if (clinit != null) { if (clinit != null) {
code = clinit.getCode(true); code = clinit.getCode(true);
if (replaceLast) { if (replaceLast) {
Code template = (Code) AccessController.doPrivileged( Code template = AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction()); J2DoPrivHelper.newCodeAction());
code.searchForward(template.vreturn()); code.searchForward(template.vreturn());
code.previous(); code.previous();
@ -3346,7 +3346,7 @@ public class PCEnhancer {
} }
// create template super.clone () instruction to match against // create template super.clone () instruction to match against
Instruction template = ((Code) AccessController.doPrivileged( Instruction template = (AccessController.doPrivileged(
J2DoPrivHelper.newCodeAction())).invokespecial() J2DoPrivHelper.newCodeAction())).invokespecial()
.setMethod(superName, "clone", Object.class.getName(), null); .setMethod(superName, "clone", Object.class.getName(), null);
@ -3720,7 +3720,7 @@ public class PCEnhancer {
// next, find the field in the managed type hierarchy // next, find the field in the managed type hierarchy
BCField field = null; BCField field = null;
outer: for (BCClass bc = _pc; bc != null; bc = bc.getSuperclassBC()) { outer: for (BCClass bc = _pc; bc != null; bc = bc.getSuperclassBC()) {
BCField[] fields = (BCField[]) AccessController BCField[] fields = AccessController
.doPrivileged(J2DoPrivHelper.getBCClassFieldsAction(bc, .doPrivileged(J2DoPrivHelper.getBCClassFieldsAction(bc,
fieldName)); fieldName));
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
@ -4451,7 +4451,7 @@ public class PCEnhancer {
loader = conf.getClassResolverInstance(). loader = conf.getClassResolverInstance().
getClassLoader(PCEnhancer.class, null); getClassLoader(PCEnhancer.class, null);
if (flags.tmpClassLoader) if (flags.tmpClassLoader)
loader = (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper loader = AccessController.doPrivileged(J2DoPrivHelper
.newTemporaryClassLoaderAction(loader)); .newTemporaryClassLoaderAction(loader));
if (repos == null) { if (repos == null) {

View File

@ -106,9 +106,9 @@ public class PCEnhancerAgent {
conf.setConnectionDriverName(null); conf.setConnectionDriverName(null);
conf.setConnectionFactoryName(null); conf.setConnectionFactoryName(null);
// set single class resolver // set single class resolver
final ClassLoader tmpLoader = (ClassLoader) AccessController final ClassLoader tmpLoader = AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.newTemporaryClassLoaderAction((ClassLoader) AccessController .newTemporaryClassLoaderAction(AccessController
.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()) .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
)); ));
conf.setClassResolver(new ClassResolver() { conf.setClassResolver(new ClassResolver() {

View File

@ -198,7 +198,7 @@ public class Reflection {
* @since 0.9.8 * @since 0.9.8
*/ */
private static Field getDeclaredField(Class cls, String name) { private static Field getDeclaredField(Class cls, String name) {
Field[] fields = (Field[]) AccessController.doPrivileged( Field[] fields = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredFieldsAction(cls)); J2DoPrivHelper.getDeclaredFieldsAction(cls));
for (int i = 0 ; i < fields.length; i++) { for (int i = 0 ; i < fields.length; i++) {
if (name.equals(fields[i].getName())) if (name.equals(fields[i].getName()))

View File

@ -238,7 +238,7 @@ public class TCPRemoteCommitProvider
hostname = host; hostname = host;
tmpPort = DEFAULT_PORT; tmpPort = DEFAULT_PORT;
} }
InetAddress tmpAddress = (InetAddress) AccessController InetAddress tmpAddress = AccessController
.doPrivileged(J2DoPrivHelper.getByNameAction(hostname)); .doPrivileged(J2DoPrivHelper.getByNameAction(hostname));
// bleair: For each address we would rather make use of // bleair: For each address we would rather make use of
@ -505,7 +505,7 @@ public class TCPRemoteCommitProvider
_port = port; _port = port;
_log = log; _log = log;
try { try {
_receiveSocket = (ServerSocket) AccessController _receiveSocket = AccessController
.doPrivileged(J2DoPrivHelper.newServerSocketAction(_port)); .doPrivileged(J2DoPrivHelper.newServerSocketAction(_port));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (IOException) pae.getException(); throw (IOException) pae.getException();
@ -576,7 +576,7 @@ public class TCPRemoteCommitProvider
try { try {
s = null; s = null;
// Block, waiting to accept new connection from a peer // Block, waiting to accept new connection from a peer
s = (Socket) AccessController.doPrivileged(J2DoPrivHelper s = AccessController.doPrivileged(J2DoPrivHelper
.acceptAction(_receiveSocket)); .acceptAction(_receiveSocket));
if (_log.isTraceEnabled()) { if (_log.isTraceEnabled()) {
_log.trace(s_loc.get("tcp-received-connection", _log.trace(s_loc.get("tcp-received-connection",
@ -770,12 +770,12 @@ public class TCPRemoteCommitProvider
int colon = host.indexOf(':'); int colon = host.indexOf(':');
try { try {
if (colon != -1) { if (colon != -1) {
_address = (InetAddress) AccessController _address = AccessController
.doPrivileged(J2DoPrivHelper.getByNameAction(host .doPrivileged(J2DoPrivHelper.getByNameAction(host
.substring(0, colon))); .substring(0, colon)));
_port = Integer.parseInt(host.substring(colon + 1)); _port = Integer.parseInt(host.substring(colon + 1));
} else { } else {
_address = (InetAddress) AccessController _address = AccessController
.doPrivileged(J2DoPrivHelper.getByNameAction(host)); .doPrivileged(J2DoPrivHelper.getByNameAction(host));
_port = DEFAULT_PORT; _port = DEFAULT_PORT;
} }
@ -905,7 +905,7 @@ public class TCPRemoteCommitProvider
public Object makeObject() public Object makeObject()
throws IOException { throws IOException {
try { try {
Socket s = (Socket) AccessController Socket s = AccessController
.doPrivileged(J2DoPrivHelper.newSocketAction(_address, .doPrivileged(J2DoPrivHelper.newSocketAction(_address,
_port)); _port));
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {

View File

@ -116,7 +116,7 @@ public class Bootstrap {
// handle cases where there is a mismatch between loaders by falling // handle cases where there is a mismatch between loaders by falling
// back to the configuration's class loader for broker resolution // back to the configuration's class loader for broker resolution
cls = getFactoryClass(conf, cls = getFactoryClass(conf,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(conf.getClass()))); J2DoPrivHelper.getClassLoaderAction(conf.getClass())));
meth = cls.getMethod(methodName, FACTORY_ARGS); meth = cls.getMethod(methodName, FACTORY_ARGS);
} }
@ -139,7 +139,7 @@ public class Bootstrap {
private static Class getFactoryClass(ConfigurationProvider conf, private static Class getFactoryClass(ConfigurationProvider conf,
ClassLoader loader) { ClassLoader loader) {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
Object cls = BrokerFactoryValue.get(conf); Object cls = BrokerFactoryValue.get(conf);

View File

@ -269,7 +269,7 @@ public class BrokerImpl
DelegatingStoreManager sm, boolean managed, int connMode, DelegatingStoreManager sm, boolean managed, int connMode,
boolean fromDeserialization) { boolean fromDeserialization) {
_initializeWasInvoked = true; _initializeWasInvoked = true;
_loader = (ClassLoader) AccessController.doPrivileged( _loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if (!fromDeserialization) if (!fromDeserialization)
_conf = factory.getConfiguration(); _conf = factory.getConfiguration();
@ -4183,7 +4183,7 @@ public class BrokerImpl
if (!PCRegistry.isRegistered(cls)) { if (!PCRegistry.isRegistered(cls)) {
try { try {
Class.forName(cls.getName(), true, Class.forName(cls.getName(), true,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(cls))); J2DoPrivHelper.getClassLoaderAction(cls)));
} catch (Throwable t) { } catch (Throwable t) {
} }
@ -4341,10 +4341,10 @@ public class BrokerImpl
if (intfs[i].getName().equals(PersistenceCapable.class.getName())) { if (intfs[i].getName().equals(PersistenceCapable.class.getName())) {
throw new UserException(_loc.get("pc-loader-different", throw new UserException(_loc.get("pc-loader-different",
Exceptions.toString(obj), Exceptions.toString(obj),
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction( J2DoPrivHelper.getClassLoaderAction(
PersistenceCapable.class)), PersistenceCapable.class)),
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(intfs[i])))) J2DoPrivHelper.getClassLoaderAction(intfs[i]))))
.setFailedObject(obj); .setFailedObject(obj);
} }

View File

@ -1569,7 +1569,7 @@ public class QueryImpl
// first check the aliases map in the MetaDataRepository // first check the aliases map in the MetaDataRepository
ClassLoader loader = (_class == null) ? _loader ClassLoader loader = (_class == null) ? _loader
: (ClassLoader) AccessController.doPrivileged( : AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(_class)); J2DoPrivHelper.getClassLoaderAction(_class));
ClassMetaData meta = _broker.getConfiguration(). ClassMetaData meta = _broker.getConfiguration().
getMetaDataRepositoryInstance().getMetaData(name, loader, false); getMetaDataRepositoryInstance().getMetaData(name, loader, false);

View File

@ -41,7 +41,7 @@ public class QueryLanguages {
// Load and cache all the query languages available in the system. // Load and cache all the query languages available in the system.
Class[] classes = Services.getImplementorClasses( Class[] classes = Services.getImplementorClasses(
ExpressionParser.class, ExpressionParser.class,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(ExpressionParser.class))); J2DoPrivHelper.getClassLoaderAction(ExpressionParser.class)));
for (int i = 0; i < classes.length; i++) { for (int i = 0; i < classes.length; i++) {
ExpressionParser ep; ExpressionParser ep;

View File

@ -98,7 +98,7 @@ public abstract class AbstractCFMetaDataFactory
File file; File file;
for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
file = new File(strs[i]); file = new File(strs[i]);
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) J2DoPrivHelper.existsAction(file))).booleanValue())
this.files.add(file); this.files.add(file);
} }
@ -364,7 +364,7 @@ public abstract class AbstractCFMetaDataFactory
for (int i = 0; i < metas.length; i++) { for (int i = 0; i < metas.length; i++) {
if (getSourceFile(metas[i]) == null) if (getSourceFile(metas[i]) == null)
setSourceFile(metas[i], defaultSourceFile(metas[i])); setSourceFile(metas[i], defaultSourceFile(metas[i]));
if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper if ((AccessController.doPrivileged(J2DoPrivHelper
.existsAction(getSourceFile(metas[i])))).booleanValue()) { .existsAction(getSourceFile(metas[i])))).booleanValue()) {
if (files == null) if (files == null)
files = new HashSet(); files = new HashSet();
@ -379,7 +379,7 @@ public abstract class AbstractCFMetaDataFactory
queries[i].setSource(defaultSourceFile(queries[i], queries[i].setSource(defaultSourceFile(queries[i],
clsNames), queries[i].getSourceScope(), clsNames), queries[i].getSourceScope(),
queries[i].getSourceType()); queries[i].getSourceType());
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(queries[i].getSourceFile()))) J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
.booleanValue()) { .booleanValue()) {
if (files == null) if (files == null)
@ -392,7 +392,7 @@ public abstract class AbstractCFMetaDataFactory
if (getSourceFile(seqs[i]) == null) if (getSourceFile(seqs[i]) == null)
setSourceFile(seqs[i], defaultSourceFile(seqs[i], setSourceFile(seqs[i], defaultSourceFile(seqs[i],
clsNames)); clsNames));
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(getSourceFile(seqs[i])))) J2DoPrivHelper.existsAction(getSourceFile(seqs[i]))))
.booleanValue()) { .booleanValue()) {
if (files == null) if (files == null)
@ -420,7 +420,7 @@ public abstract class AbstractCFMetaDataFactory
if (queries[i].getSourceFile() == null) if (queries[i].getSourceFile() == null)
queries[i].setSource(defaultSourceFile(queries[i], clsNames), queries[i].setSource(defaultSourceFile(queries[i], clsNames),
queries[i].getSourceScope(), queries[i].getSourceType()); queries[i].getSourceScope(), queries[i].getSourceType());
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(queries[i].getSourceFile()))) J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
.booleanValue()) { .booleanValue()) {
if (files == null) if (files == null)
@ -631,7 +631,7 @@ public abstract class AbstractCFMetaDataFactory
File file; File file;
for (Iterator itr = files.iterator(); itr.hasNext();) { for (Iterator itr = files.iterator(); itr.hasNext();) {
file = (File) itr.next(); file = (File) itr.next();
if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper if ((AccessController.doPrivileged(J2DoPrivHelper
.isDirectoryAction(file))).booleanValue()) { .isDirectoryAction(file))).booleanValue()) {
if (log.isTraceEnabled()) if (log.isTraceEnabled())
log.trace(_loc.get("scanning-directory", file)); log.trace(_loc.get("scanning-directory", file));
@ -641,7 +641,7 @@ public abstract class AbstractCFMetaDataFactory
if (log.isTraceEnabled()) if (log.isTraceEnabled())
log.trace(_loc.get("scanning-jar", file)); log.trace(_loc.get("scanning-jar", file));
try { try {
ZipFile zFile = (ZipFile) AccessController ZipFile zFile = AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.newZipFileAction(file)); .newZipFileAction(file));
scan(new ZipFileMetaDataIterator(zFile, scan(new ZipFileMetaDataIterator(zFile,
@ -657,7 +657,7 @@ public abstract class AbstractCFMetaDataFactory
if (log.isTraceEnabled()) if (log.isTraceEnabled())
log.trace(_loc.get("scan-found-names", clss, file)); log.trace(_loc.get("scan-found-names", clss, file));
names.addAll(Arrays.asList(clss)); names.addAll(Arrays.asList(clss));
File f = (File) AccessController File f = AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.getAbsoluteFileAction(file)); .getAbsoluteFileAction(file));
try { try {
@ -674,12 +674,12 @@ public abstract class AbstractCFMetaDataFactory
for (Iterator itr = urls.iterator(); itr.hasNext();) { for (Iterator itr = urls.iterator(); itr.hasNext();) {
url = (URL) itr.next(); url = (URL) itr.next();
if ("file".equals(url.getProtocol())) { if ("file".equals(url.getProtocol())) {
File file = (File) AccessController File file = AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.getAbsoluteFileAction(new File(url.getFile()))); .getAbsoluteFileAction(new File(url.getFile())));
if (files != null && files.contains(file)) { if (files != null && files.contains(file)) {
continue; continue;
} else if (((Boolean) AccessController } else if ((AccessController
.doPrivileged(J2DoPrivHelper.isDirectoryAction(file))) .doPrivileged(J2DoPrivHelper.isDirectoryAction(file)))
.booleanValue()) { .booleanValue()) {
if (log.isTraceEnabled()) if (log.isTraceEnabled())
@ -726,7 +726,7 @@ public abstract class AbstractCFMetaDataFactory
for (Iterator itr = rsrcs.iterator(); itr.hasNext();) { for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
rsrc = (String) itr.next(); rsrc = (String) itr.next();
if (rsrc.endsWith(".jar")) { if (rsrc.endsWith(".jar")) {
url = (URL) AccessController.doPrivileged( url = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(loader, rsrc)); J2DoPrivHelper.getResourceAction(loader, rsrc));
if (url != null) { if (url != null) {
if (log.isTraceEnabled()) if (log.isTraceEnabled())

View File

@ -198,7 +198,7 @@ public abstract class AbstractMetaDataDefaults
FieldMetaData fmd; FieldMetaData fmd;
for (int i = 0; i < fieldNames.length; i ++) { for (int i = 0; i < fieldNames.length; i ++) {
if (meta.getAccessType() == ClassMetaData.ACCESS_FIELD) if (meta.getAccessType() == ClassMetaData.ACCESS_FIELD)
member = (Field) AccessController.doPrivileged( member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredFieldAction( J2DoPrivHelper.getDeclaredFieldAction(
cls,fieldNames[i])); cls,fieldNames[i]));
else else
@ -362,7 +362,7 @@ public abstract class AbstractMetaDataDefaults
//### where the superclass uses a different access type //### where the superclass uses a different access type
if (fmd.getDefiningMetaData().getAccessType() == if (fmd.getDefiningMetaData().getAccessType() ==
ClassMetaData.ACCESS_FIELD) ClassMetaData.ACCESS_FIELD)
return (Field) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredFieldAction( J2DoPrivHelper.getDeclaredFieldAction(
fmd.getDeclaringType(), fmd.getName())); fmd.getDeclaringType(), fmd.getName()));
return Reflection.findGetter(fmd.getDeclaringType(), fmd.getName(), return Reflection.findGetter(fmd.getDeclaringType(), fmd.getName(),

View File

@ -2087,12 +2087,12 @@ public class FieldMetaData
String memberName = (String) in.readObject(); String memberName = (String) in.readObject();
try { try {
if (isField) if (isField)
_member = (Field) AccessController.doPrivileged( _member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredFieldAction( J2DoPrivHelper.getDeclaredFieldAction(
cls, memberName)); cls, memberName));
else { else {
Class[] parameterTypes = (Class[]) in.readObject(); Class[] parameterTypes = (Class[]) in.readObject();
_member = (Method) AccessController.doPrivileged( _member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
cls, memberName, parameterTypes)); cls, memberName, parameterTypes));
} }

View File

@ -77,12 +77,12 @@ class InterfaceImplGenerator {
if (impl != null) if (impl != null)
return impl; return impl;
ClassLoader parentLoader = (ClassLoader) AccessController.doPrivileged( ClassLoader parentLoader = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(iface)); J2DoPrivHelper.getClassLoaderAction(iface));
BCClassLoader loader = (BCClassLoader) AccessController BCClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project, .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project,
parentLoader)); parentLoader));
BCClassLoader enhLoader = (BCClassLoader) AccessController BCClassLoader enhLoader = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_enhProject, .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_enhProject,
parentLoader)); parentLoader));
BCClass bc = _project.loadClass(getClassName(meta)); BCClass bc = _project.loadClass(getClassName(meta));
@ -90,9 +90,9 @@ class InterfaceImplGenerator {
ClassMetaData sup = meta.getPCSuperclassMetaData(); ClassMetaData sup = meta.getPCSuperclassMetaData();
if (sup != null) { if (sup != null) {
bc.setSuperclass(sup.getInterfaceImpl()); bc.setSuperclass(sup.getInterfaceImpl());
enhLoader = (BCClassLoader) AccessController enhLoader = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction( .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(
_enhProject, (ClassLoader) AccessController _enhProject, AccessController
.doPrivileged(J2DoPrivHelper.getClassLoaderAction(sup .doPrivileged(J2DoPrivHelper.getClassLoaderAction(sup
.getInterfaceImpl())))); .getInterfaceImpl()))));
} }
@ -209,7 +209,7 @@ class InterfaceImplGenerator {
*/ */
private static Method getMethodSafe(Class iface, String name, Class arg) { private static Method getMethodSafe(Class iface, String name, Class arg) {
try { try {
return (Method) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
iface, name, arg == null ? null : new Class[]{arg})); iface, name, arg == null ? null : new Class[]{arg}));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
@ -221,7 +221,7 @@ class InterfaceImplGenerator {
if (fmd.getType() != boolean.class && fmd.getType() != Boolean.class) if (fmd.getType() != boolean.class && fmd.getType() != Boolean.class)
return true; return true;
try { try {
Method meth = (Method) AccessController.doPrivileged( Method meth = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction(iface, "is" + J2DoPrivHelper.getDeclaredMethodAction(iface, "is" +
StringUtils.capitalize(fmd.getName()), (Class[]) null)); StringUtils.capitalize(fmd.getName()), (Class[]) null));
return meth == null; return meth == null;

View File

@ -454,7 +454,7 @@ public class MetaDataRepository
if ((_validate & VALIDATE_RUNTIME) != 0) { if ((_validate & VALIDATE_RUNTIME) != 0) {
try { try {
Class.forName(cls.getName(), true, Class.forName(cls.getName(), true,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(cls))); J2DoPrivHelper.getClassLoaderAction(cls)));
} catch (Throwable t) { } catch (Throwable t) {
} }
@ -1038,7 +1038,7 @@ public class MetaDataRepository
if (_log.isTraceEnabled()) if (_log.isTraceEnabled())
_log.trace(_loc.get("resolve-identity", oidClass)); _log.trace(_loc.get("resolve-identity", oidClass));
ClassLoader cl = (ClassLoader) AccessController.doPrivileged( ClassLoader cl = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(oidClass)); J2DoPrivHelper.getClassLoaderAction(oidClass));
String className; String className;
while (oidClass != null && oidClass != Object.class) { while (oidClass != null && oidClass != Object.class) {

View File

@ -255,7 +255,7 @@ public class SequenceMetaData
String clsName = plugin.getClassName(); String clsName = plugin.getClassName();
Class cls = Class.forName(clsName, true, Class cls = Class.forName(clsName, true,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(Seq.class))); J2DoPrivHelper.getClassLoaderAction(Seq.class)));
StringBuffer props = new StringBuffer(); StringBuffer props = new StringBuffer();
if (plugin.getProperties() != null) if (plugin.getProperties() != null)

View File

@ -40,15 +40,15 @@ public class ClassResolverImpl
// class (the bootstrap loader is the parent of the system loader) // class (the bootstrap loader is the parent of the system loader)
ClassLoader contextLoader = null; ClassLoader contextLoader = null;
if (contextClass != null) { if (contextClass != null) {
contextLoader = (ClassLoader) AccessController.doPrivileged( contextLoader = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(contextClass)); J2DoPrivHelper.getClassLoaderAction(contextClass));
if (contextLoader == null) if (contextLoader == null)
contextLoader = (ClassLoader) AccessController.doPrivileged( contextLoader = AccessController.doPrivileged(
J2DoPrivHelper.getSystemClassLoaderAction()); J2DoPrivHelper.getSystemClassLoaderAction());
} }
// if there is only one unique loader, just return it // if there is only one unique loader, just return it
ClassLoader threadLoader = (ClassLoader) AccessController.doPrivileged( ClassLoader threadLoader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if ((contextLoader == null || contextLoader == threadLoader) if ((contextLoader == null || contextLoader == threadLoader)
&& (envLoader == null || envLoader == threadLoader)) && (envLoader == null || envLoader == threadLoader))
@ -56,7 +56,7 @@ public class ClassResolverImpl
// construct a multi class loader that will delegate in the order // construct a multi class loader that will delegate in the order
// described in section 12.5 of the spec // described in section 12.5 of the spec
MultiClassLoader loader = (MultiClassLoader) AccessController MultiClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
if (contextLoader != null) if (contextLoader != null)
loader.addClassLoader(contextLoader); loader.addClassLoader(contextLoader);

View File

@ -39,9 +39,9 @@ public class GeneratedClasses {
* classes. * classes.
*/ */
public static ClassLoader getMostDerivedLoader(Class c1, Class c2) { public static ClassLoader getMostDerivedLoader(Class c1, Class c2) {
ClassLoader l1 = (ClassLoader) AccessController.doPrivileged( ClassLoader l1 = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(c1)); J2DoPrivHelper.getClassLoaderAction(c1));
ClassLoader l2 = (ClassLoader) AccessController.doPrivileged( ClassLoader l2 = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(c2)); J2DoPrivHelper.getClassLoaderAction(c2));
if (l1 == l2) if (l1 == l2)
return l1; return l1;
@ -60,7 +60,7 @@ public class GeneratedClasses {
* Load the class represented by the given bytecode. * Load the class represented by the given bytecode.
*/ */
public static Class loadBCClass(BCClass bc, ClassLoader loader) { public static Class loadBCClass(BCClass bc, ClassLoader loader) {
BCClassLoader bcloader = (BCClassLoader) AccessController BCClassLoader bcloader = AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(bc .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(bc
.getProject(), loader)); .getProject(), loader));
try { try {

View File

@ -78,7 +78,7 @@ public final class Id
*/ */
public Id(String str, ClassLoader loader) { public Id(String str, ClassLoader loader) {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if (str == null) if (str == null)

View File

@ -31,7 +31,7 @@ import org.apache.openjpa.lib.util.MultiClassLoader;
*/ */
public class MultiLoaderClassResolver implements ClassResolver { public class MultiLoaderClassResolver implements ClassResolver {
final private MultiClassLoader _loader = (MultiClassLoader) AccessController final private MultiClassLoader _loader = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
public MultiLoaderClassResolver() { public MultiLoaderClassResolver() {

View File

@ -48,10 +48,10 @@ public class Proxies {
public static void assertAllowedType(Object value, Class allowed) { public static void assertAllowedType(Object value, Class allowed) {
if (value != null && allowed != null && !allowed.isInstance(value)) { if (value != null && allowed != null && !allowed.isInstance(value)) {
throw new UserException(_loc.get("bad-elem-type", new Object[]{ throw new UserException(_loc.get("bad-elem-type", new Object[]{
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(allowed)), J2DoPrivHelper.getClassLoaderAction(allowed)),
allowed, allowed,
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(value.getClass())), J2DoPrivHelper.getClassLoaderAction(value.getClass())),
value.getClass() value.getClass()
})); }));

View File

@ -440,9 +440,10 @@ public class ProxyManagerImpl
ProxyBean.class); ProxyBean.class);
Class pcls = loadBuildTimeProxy(type, l); Class pcls = loadBuildTimeProxy(type, l);
if (pcls == null) { if (pcls == null) {
BCClass bc = (BCClass) AccessController // TODO Move this to J2DOPrivHelper?
.doPrivileged(new PrivilegedAction() { BCClass bc = AccessController
public Object run() { .doPrivileged(new PrivilegedAction<BCClass>() {
public BCClass run() {
return generateProxyBeanBytecode(type, true); return generateProxyBeanBytecode(type, true);
} }
}); });
@ -513,7 +514,7 @@ public class ProxyManagerImpl
boolean runtime) { boolean runtime) {
assertNotFinal(type); assertNotFinal(type);
Project project = new Project(); Project project = new Project();
BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper BCClass bc = AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(project, getProxyClassName(type, runtime))); .loadProjectClassAction(project, getProxyClassName(type, runtime)));
bc.setSuperclass(type); bc.setSuperclass(type);
bc.declareInterface(ProxyCollection.class); bc.declareInterface(ProxyCollection.class);
@ -551,7 +552,7 @@ public class ProxyManagerImpl
protected BCClass generateProxyMapBytecode(Class type, boolean runtime) { protected BCClass generateProxyMapBytecode(Class type, boolean runtime) {
assertNotFinal(type); assertNotFinal(type);
Project project = new Project(); Project project = new Project();
BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper BCClass bc = AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(project, getProxyClassName(type, runtime))); .loadProjectClassAction(project, getProxyClassName(type, runtime)));
bc.setSuperclass(type); bc.setSuperclass(type);
bc.declareInterface(ProxyMap.class); bc.declareInterface(ProxyMap.class);
@ -571,7 +572,7 @@ public class ProxyManagerImpl
protected BCClass generateProxyDateBytecode(Class type, boolean runtime) { protected BCClass generateProxyDateBytecode(Class type, boolean runtime) {
assertNotFinal(type); assertNotFinal(type);
Project project = new Project(); Project project = new Project();
BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper BCClass bc = AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(project, getProxyClassName(type, runtime))); .loadProjectClassAction(project, getProxyClassName(type, runtime)));
bc.setSuperclass(type); bc.setSuperclass(type);
bc.declareInterface(ProxyDate.class); bc.declareInterface(ProxyDate.class);
@ -591,7 +592,7 @@ public class ProxyManagerImpl
boolean runtime) { boolean runtime) {
assertNotFinal(type); assertNotFinal(type);
Project project = new Project(); Project project = new Project();
BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper BCClass bc = AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(project, getProxyClassName(type, runtime))); .loadProjectClassAction(project, getProxyClassName(type, runtime)));
bc.setSuperclass(type); bc.setSuperclass(type);
bc.declareInterface(ProxyCalendar.class); bc.declareInterface(ProxyCalendar.class);
@ -626,7 +627,7 @@ public class ProxyManagerImpl
} }
Project project = new Project(); Project project = new Project();
BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper BCClass bc = AccessController.doPrivileged(J2DoPrivHelper
.loadProjectClassAction(project, getProxyClassName(type, runtime))); .loadProjectClassAction(project, getProxyClassName(type, runtime)));
bc.setSuperclass(type); bc.setSuperclass(type);
bc.declareInterface(ProxyBean.class); bc.declareInterface(ProxyBean.class);
@ -1585,7 +1586,7 @@ public class ProxyManagerImpl
public static void main(String[] args) public static void main(String[] args)
throws ClassNotFoundException, IOException { throws ClassNotFoundException, IOException {
File dir = Files.getClassFile(ProxyManagerImpl.class); File dir = Files.getClassFile(ProxyManagerImpl.class);
dir = (dir == null) ? new File((String) AccessController.doPrivileged( dir = (dir == null) ? new File(AccessController.doPrivileged(
J2DoPrivHelper.getPropertyAction("user.dir"))) J2DoPrivHelper.getPropertyAction("user.dir")))
: dir.getParentFile(); : dir.getParentFile();
@ -1647,9 +1648,10 @@ public class ProxyManagerImpl
bc = mgr.generateProxyCalendarBytecode(cls, false); bc = mgr.generateProxyCalendarBytecode(cls, false);
else { else {
final Class fCls = cls; final Class fCls = cls;
bc = (BCClass) AccessController // TODO Move this to J2DOPrivHelper
.doPrivileged(new PrivilegedAction() { bc = AccessController
public Object run() { .doPrivileged(new PrivilegedAction<BCClass>() {
public BCClass run() {
return mgr.generateProxyBeanBytecode(fCls, false); return mgr.generateProxyBeanBytecode(fCls, false);
} }
}); });

View File

@ -129,7 +129,7 @@ public class Serialization {
protected Class resolveClass(ObjectStreamClass desc) protected Class resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException { throws IOException, ClassNotFoundException {
MultiClassLoader loader = (MultiClassLoader) AccessController MultiClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
addContextClassLoaders(loader); addContextClassLoaders(loader);
loader.addClassLoader(getClass().getClassLoader()); loader.addClassLoader(getClass().getClassLoader());
@ -138,7 +138,7 @@ public class Serialization {
} }
protected void addContextClassLoaders(MultiClassLoader loader) { protected void addContextClassLoaders(MultiClassLoader loader) {
loader.addClassLoader((ClassLoader) AccessController.doPrivileged( loader.addClassLoader(AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction())); J2DoPrivHelper.getContextClassLoaderAction()));
} }
} }

View File

@ -57,7 +57,7 @@ public abstract class AbstractTask extends MatchingTask {
private static final Localizer _loc = Localizer.forPackage private static final Localizer _loc = Localizer.forPackage
(AbstractTask.class); (AbstractTask.class);
protected final List fileSets = new ArrayList(); protected final List<FileSet> fileSets = new ArrayList<FileSet>();
protected boolean haltOnError = true; protected boolean haltOnError = true;
protected Path classpath = null; protected Path classpath = null;
protected boolean useParent = false; protected boolean useParent = false;
@ -117,10 +117,10 @@ public abstract class AbstractTask extends MatchingTask {
return _cl; return _cl;
if (classpath != null) if (classpath != null)
_cl = new AntClassLoader(project, classpath, useParent); _cl = new AntClassLoader(getProject(), classpath, useParent);
else else
_cl = new AntClassLoader(project.getCoreLoader(), project, _cl = new AntClassLoader(getProject().getCoreLoader(), getProject(),
new Path(project), useParent); new Path(getProject()), useParent);
_cl.setIsolated(isolate); _cl.setIsolated(isolate);
return _cl; return _cl;
@ -143,7 +143,7 @@ public abstract class AbstractTask extends MatchingTask {
public Path createClasspath() { public Path createClasspath() {
if (classpath == null) if (classpath == null)
classpath = new Path(project); classpath = new Path(getProject());
return classpath.createPath(); return classpath.createPath();
} }
@ -161,7 +161,7 @@ public abstract class AbstractTask extends MatchingTask {
_conf = newConfiguration(); _conf = newConfiguration();
if (_conf.getPropertiesResource() == null) { if (_conf.getPropertiesResource() == null) {
ConfigurationProvider cp = ProductDerivations.loadDefaults ConfigurationProvider cp = ProductDerivations.loadDefaults
((ClassLoader) AccessController.doPrivileged( (AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(_conf.getClass()))); J2DoPrivHelper.getClassLoaderAction(_conf.getClass())));
if (cp != null) if (cp != null)
cp.setInto(_conf); cp.setInto(_conf);
@ -181,18 +181,17 @@ public abstract class AbstractTask extends MatchingTask {
} }
private String[] getFiles() { private String[] getFiles() {
List files = new ArrayList(); List<String> files = new ArrayList<String>();
for (Iterator i = fileSets.iterator(); i.hasNext();) { for(FileSet fs : fileSets) {
FileSet fs = (FileSet) i.next(); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
DirectoryScanner ds = fs.getDirectoryScanner(project);
String[] dsFiles = ds.getIncludedFiles(); String[] dsFiles = ds.getIncludedFiles();
for (int j = 0; j < dsFiles.length; j++) { for (int j = 0; j < dsFiles.length; j++) {
File f = new File(dsFiles[j]); File f = new File(dsFiles[j]);
if (!((Boolean) AccessController.doPrivileged(J2DoPrivHelper if (!( AccessController.doPrivileged(J2DoPrivHelper
.isFileAction(f))).booleanValue()) .isFileAction(f))).booleanValue())
f = new File(ds.getBasedir(), dsFiles[j]); f = new File(ds.getBasedir(), dsFiles[j]);
files.add((String) AccessController.doPrivileged( files.add(AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(f))); J2DoPrivHelper.getAbsolutePathAction(f)));
} }
} }

View File

@ -165,9 +165,9 @@ public class ConfigurationImpl
* {@link ProductDerivation}s, and from System properties. * {@link ProductDerivation}s, and from System properties.
*/ */
public boolean loadGlobals() { public boolean loadGlobals() {
MultiClassLoader loader = (MultiClassLoader) AccessController MultiClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
loader.addClassLoader((ClassLoader) AccessController.doPrivileged( loader.addClassLoader(AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction())); J2DoPrivHelper.getContextClassLoaderAction()));
loader.addClassLoader(getClass().getClassLoader()); loader.addClassLoader(getClass().getClassLoader());
ConfigurationProvider provider = ProductDerivations.loadGlobals(loader); ConfigurationProvider provider = ProductDerivations.loadGlobals(loader);
@ -177,7 +177,7 @@ public class ConfigurationImpl
// let system properties override other globals // let system properties override other globals
try { try {
fromProperties(new HashMap( fromProperties(new HashMap(
(Properties) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getPropertiesAction()))); J2DoPrivHelper.getPropertiesAction())));
} catch (SecurityException se) { } catch (SecurityException se) {
// security manager might disallow // security manager might disallow

View File

@ -245,19 +245,19 @@ public class Configurations {
// we always prefer the thread loader, because it's the only thing we // we always prefer the thread loader, because it's the only thing we
// can access that isn't bound to the OpenJPA classloader, unless // can access that isn't bound to the OpenJPA classloader, unless
// the conf object is of a custom class // the conf object is of a custom class
ClassLoader ctxLoader = (ClassLoader) AccessController.doPrivileged( ClassLoader ctxLoader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if (loader == null) { if (loader == null) {
if (ctxLoader != null) if (ctxLoader != null)
return ctxLoader; return ctxLoader;
if (conf != null) if (conf != null)
return (ClassLoader) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(conf.getClass())); J2DoPrivHelper.getClassLoaderAction(conf.getClass()));
return Configurations.class.getClassLoader(); return Configurations.class.getClassLoader();
} }
for (ClassLoader parent = ctxLoader; parent != null; for (ClassLoader parent = ctxLoader; parent != null;
parent = (ClassLoader) AccessController.doPrivileged( parent = AccessController.doPrivileged(
J2DoPrivHelper.getParentAction(parent))) { J2DoPrivHelper.getParentAction(parent))) {
if (parent == loader) if (parent == loader)
return ctxLoader; return ctxLoader;
@ -267,10 +267,10 @@ public class Configurations {
AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(conf.getClass())); J2DoPrivHelper.getClassLoaderAction(conf.getClass()));
parent != null; parent != null;
parent = (ClassLoader) AccessController.doPrivileged( parent = AccessController.doPrivileged(
J2DoPrivHelper.getParentAction(parent))) { J2DoPrivHelper.getParentAction(parent))) {
if (parent == loader) if (parent == loader)
return (ClassLoader) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(conf.getClass())); J2DoPrivHelper.getClassLoaderAction(conf.getClass()));
} }
} }
@ -332,12 +332,12 @@ public class Configurations {
} }
File file = new File(path); File file = new File(path);
if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper if ((AccessController.doPrivileged(J2DoPrivHelper
.isFileAction(file))).booleanValue()) .isFileAction(file))).booleanValue())
provider = ProductDerivations.load(file, anchor, null); provider = ProductDerivations.load(file, anchor, null);
else { else {
file = new File("META-INF" + File.separatorChar + path); file = new File("META-INF" + File.separatorChar + path);
if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper if ((AccessController.doPrivileged(J2DoPrivHelper
.isFileAction(file))).booleanValue()) .isFileAction(file))).booleanValue())
provider = ProductDerivations.load(file, anchor, null); provider = ProductDerivations.load(file, anchor, null);
else else

View File

@ -60,7 +60,7 @@ public class FileValue extends Value {
} }
protected String getInternalString() { protected String getInternalString() {
return (value == null) ? null : (String) AccessController.doPrivileged( return (value == null) ? null : AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(value)); J2DoPrivHelper.getAbsolutePathAction(value));
} }

View File

@ -98,10 +98,10 @@ public class ObjectValue extends Value {
boolean fatal) { boolean fatal) {
ClassLoader cl = (ClassLoader) _classloaderCache.get(type); ClassLoader cl = (ClassLoader) _classloaderCache.get(type);
if (cl == null) { if (cl == null) {
cl = (ClassLoader) AccessController.doPrivileged( cl = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(type)); J2DoPrivHelper.getClassLoaderAction(type));
if (cl == null) { // System classloader is returned as null if (cl == null) { // System classloader is returned as null
cl = (ClassLoader) AccessController.doPrivileged( cl = AccessController.doPrivileged(
J2DoPrivHelper.getSystemClassLoaderAction()); J2DoPrivHelper.getSystemClassLoaderAction());
} }
_classloaderCache.put(type, cl); _classloaderCache.put(type, cl);

View File

@ -52,7 +52,7 @@ public class ProductDerivations {
private static final Throwable[] _derivationErrors; private static final Throwable[] _derivationErrors;
private static String[] _prefixes; private static String[] _prefixes;
static { static {
ClassLoader l = (ClassLoader) AccessController.doPrivileged( ClassLoader l = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(ProductDerivation.class)); J2DoPrivHelper.getClassLoaderAction(ProductDerivation.class));
_derivationNames = Services.getImplementors(ProductDerivation.class, l); _derivationNames = Services.getImplementors(ProductDerivation.class, l);
_derivationErrors = new Throwable[_derivationNames.length]; _derivationErrors = new Throwable[_derivationNames.length];
@ -250,7 +250,7 @@ public class ProductDerivations {
if (StringUtils.isEmpty(resource)) if (StringUtils.isEmpty(resource))
return null; return null;
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
ConfigurationProvider provider = null; ConfigurationProvider provider = null;
StringBuffer errs = null; StringBuffer errs = null;
@ -285,7 +285,7 @@ public class ProductDerivations {
if (file == null) if (file == null)
return null; return null;
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
ConfigurationProvider provider = null; ConfigurationProvider provider = null;
StringBuffer errs = null; StringBuffer errs = null;
@ -302,7 +302,7 @@ public class ProductDerivations {
errs.append(_derivations[i].getClass().getName() + ":" + t); errs.append(_derivations[i].getClass().getName() + ":" + t);
} }
} }
String aPath = (String) AccessController.doPrivileged( String aPath = AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(file)); J2DoPrivHelper.getAbsolutePathAction(file));
reportErrors(errs, aPath, err); reportErrors(errs, aPath, err);
String rsrc = aPath + "#" + anchor; String rsrc = aPath + "#" + anchor;
@ -331,7 +331,7 @@ public class ProductDerivations {
private static ConfigurationProvider load(ClassLoader loader, private static ConfigurationProvider load(ClassLoader loader,
boolean globals) { boolean globals) {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
ConfigurationProvider provider = null; ConfigurationProvider provider = null;

View File

@ -188,7 +188,7 @@ public class LogFactoryImpl
_out = new PrintStream((FileOutputStream) _out = new PrintStream((FileOutputStream)
AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.newFileOutputStreamAction( J2DoPrivHelper.newFileOutputStreamAction(
(String) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getCanonicalPathAction(f)), J2DoPrivHelper.getCanonicalPathAction(f)),
true))); true)));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {

View File

@ -298,7 +298,7 @@ public class CFMetaDataParser extends XMLMetaDataParser {
return null; return null;
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
boolean fullName = name.indexOf('.') != -1; boolean fullName = name.indexOf('.') != -1;
boolean noPackage = StringUtils.isEmpty(pkg); boolean noPackage = StringUtils.isEmpty(pkg);

View File

@ -214,7 +214,7 @@ public class ClassArgParser {
return new String[]{ getFromClassFile(file) }; return new String[]{ getFromClassFile(file) };
if (arg.endsWith(".java")) if (arg.endsWith(".java"))
return new String[]{ getFromJavaFile(file) }; return new String[]{ getFromJavaFile(file) };
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) { J2DoPrivHelper.existsAction(file))).booleanValue()) {
Collection col = getFromMetaDataFile(file); Collection col = getFromMetaDataFile(file);
return (String[]) col.toArray(new String[col.size()]); return (String[]) col.toArray(new String[col.size()]);
@ -300,7 +300,7 @@ public class ClassArgParser {
private String getFromClassFile(File file) throws IOException { private String getFromClassFile(File file) throws IOException {
FileInputStream fin = null; FileInputStream fin = null;
try { try {
fin = (FileInputStream) AccessController.doPrivileged( fin = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(file)); J2DoPrivHelper.newFileInputStreamAction(file));
return getFromClass(fin); return getFromClass(fin);
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {

View File

@ -75,7 +75,7 @@ public class ClassMetaDataIterator implements MetaDataIterator {
} }
if (loader == null) { if (loader == null) {
MultiClassLoader multi = (MultiClassLoader) AccessController MultiClassLoader multi = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
multi.addClassLoader(multi.SYSTEM_LOADER); multi.addClassLoader(multi.SYSTEM_LOADER);
multi.addClassLoader(multi.THREAD_LOADER); multi.addClassLoader(multi.THREAD_LOADER);
@ -156,7 +156,7 @@ public class ClassMetaDataIterator implements MetaDataIterator {
_url = -1; _url = -1;
_urls.clear(); _urls.clear();
try { try {
e = (Enumeration) AccessController.doPrivileged( e = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction( J2DoPrivHelper.getResourcesAction(
_loader, (String) _locs.get(_loc))); _loader, (String) _locs.get(_loc)));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
@ -178,7 +178,7 @@ public class ClassMetaDataIterator implements MetaDataIterator {
if (_url == -1 || _url >= _urls.size()) if (_url == -1 || _url >= _urls.size())
throw new IllegalStateException(); throw new IllegalStateException();
try { try {
return (InputStream) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.openStreamAction((URL) _urls.get(_url))); J2DoPrivHelper.openStreamAction((URL) _urls.get(_url)));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (IOException) pae.getException(); throw (IOException) pae.getException();
@ -190,7 +190,7 @@ public class ClassMetaDataIterator implements MetaDataIterator {
throw new IllegalStateException(); throw new IllegalStateException();
File file = new File(URLDecoder.decode(((URL) _urls.get(_url)). File file = new File(URLDecoder.decode(((URL) _urls.get(_url)).
getFile())); getFile()));
return (((Boolean) AccessController.doPrivileged( return ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) ? file:null; J2DoPrivHelper.existsAction(file))).booleanValue()) ? file:null;
} }

View File

@ -51,7 +51,7 @@ public class ClasspathMetaDataIterator extends MetaDataIteratorChain {
*/ */
public ClasspathMetaDataIterator(String[] dirs, MetaDataFilter filter) public ClasspathMetaDataIterator(String[] dirs, MetaDataFilter filter)
throws IOException { throws IOException {
Properties props = (Properties) AccessController.doPrivileged( Properties props = AccessController.doPrivileged(
J2DoPrivHelper.getPropertiesAction()); J2DoPrivHelper.getPropertiesAction());
String path = props.getProperty("java.class.path"); String path = props.getProperty("java.class.path");
String[] tokens = Strings.split(path, String[] tokens = Strings.split(path,
@ -62,15 +62,15 @@ public class ClasspathMetaDataIterator extends MetaDataIteratorChain {
continue; continue;
File file = new File(tokens[i]); File file = new File(tokens[i]);
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) J2DoPrivHelper.existsAction(file))).booleanValue())
continue; continue;
if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper if ((AccessController.doPrivileged(J2DoPrivHelper
.isDirectoryAction(file))).booleanValue()) .isDirectoryAction(file))).booleanValue())
addIterator(new FileMetaDataIterator(file, filter)); addIterator(new FileMetaDataIterator(file, filter));
else if (tokens[i].endsWith(".jar")) { else if (tokens[i].endsWith(".jar")) {
try { try {
ZipFile zFile = (ZipFile) AccessController ZipFile zFile = AccessController
.doPrivileged(J2DoPrivHelper.newZipFileAction(file)); .doPrivileged(J2DoPrivHelper.newZipFileAction(file));
addIterator(new ZipFileMetaDataIterator(zFile, filter)); addIterator(new ZipFileMetaDataIterator(zFile, filter));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {

View File

@ -113,7 +113,7 @@ public class FileMetaDataIterator implements MetaDataIterator {
_file = (File) _itr.next(); _file = (File) _itr.next();
try { try {
File f = (File) AccessController.doPrivileged(J2DoPrivHelper File f = AccessController.doPrivileged(J2DoPrivHelper
.getAbsoluteFileAction(_file)); .getAbsoluteFileAction(_file));
return AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.toURLAction(f)); J2DoPrivHelper.toURLAction(f));
@ -127,7 +127,7 @@ public class FileMetaDataIterator implements MetaDataIterator {
throw new IllegalStateException(); throw new IllegalStateException();
FileInputStream fis = null; FileInputStream fis = null;
try { try {
fis = (FileInputStream) AccessController.doPrivileged( fis = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(_file)); J2DoPrivHelper.newFileInputStreamAction(_file));
return fis; return fis;
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
@ -157,11 +157,11 @@ public class FileMetaDataIterator implements MetaDataIterator {
} }
public byte[] getContent() throws IOException { public byte[] getContent() throws IOException {
long len = ((Long) AccessController.doPrivileged( long len = (AccessController.doPrivileged(
J2DoPrivHelper.lengthAction(_file))).longValue(); J2DoPrivHelper.lengthAction(_file))).longValue();
FileInputStream fin = null; FileInputStream fin = null;
try { try {
fin = (FileInputStream) AccessController.doPrivileged( fin = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(_file)); J2DoPrivHelper.newFileInputStreamAction(_file));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (FileNotFoundException) pae.getException(); throw (FileNotFoundException) pae.getException();

View File

@ -57,7 +57,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator {
public ResourceMetaDataIterator(String rsrc, ClassLoader loader) public ResourceMetaDataIterator(String rsrc, ClassLoader loader)
throws IOException { throws IOException {
if (loader == null) { if (loader == null) {
MultiClassLoader multi = (MultiClassLoader) AccessController MultiClassLoader multi = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
multi.addClassLoader(multi.SYSTEM_LOADER); multi.addClassLoader(multi.SYSTEM_LOADER);
multi.addClassLoader(multi.THREAD_LOADER); multi.addClassLoader(multi.THREAD_LOADER);
@ -66,7 +66,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator {
} }
try { try {
Enumeration e = (Enumeration) AccessController.doPrivileged( Enumeration e = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction(loader, rsrc)); J2DoPrivHelper.getResourcesAction(loader, rsrc));
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
if (_urls == null) if (_urls == null)
@ -92,7 +92,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator {
if (_url == -1 || _url >= _urls.size()) if (_url == -1 || _url >= _urls.size())
throw new IllegalStateException(); throw new IllegalStateException();
try { try {
return (InputStream) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.openStreamAction((URL) _urls.get(_url))); J2DoPrivHelper.openStreamAction((URL) _urls.get(_url)));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (IOException) pae.getException(); throw (IOException) pae.getException();
@ -104,7 +104,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator {
throw new IllegalStateException(); throw new IllegalStateException();
File file = new File(URLDecoder.decode(((URL) _urls.get(_url)). File file = new File(URLDecoder.decode(((URL) _urls.get(_url)).
getFile())); getFile()));
return (((Boolean) AccessController.doPrivileged( return ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) ? file :null; J2DoPrivHelper.existsAction(file))).booleanValue()) ? file :null;
} }

View File

@ -49,7 +49,7 @@ public class SourceTrackers {
for (int i = 0; i < trackers.length; i++) { for (int i = 0; i < trackers.length; i++) {
sourceFilePath = (trackers[i].getSourceFile() == null ? sourceFilePath = (trackers[i].getSourceFile() == null ?
_loc.get("source-tracker-file-unknown").getMessage() : _loc.get("source-tracker-file-unknown").getMessage() :
(String) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction( J2DoPrivHelper.getAbsolutePathAction(
trackers[i].getSourceFile()))); trackers[i].getSourceFile())));
buf.append(" ").append(_loc.get( buf.append(" ").append(_loc.get(

View File

@ -64,7 +64,7 @@ public class URLMetaDataIterator implements MetaDataIterator {
if (_url == null) if (_url == null)
return null; return null;
try { try {
return (InputStream) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.openStreamAction(_url)); J2DoPrivHelper.openStreamAction(_url));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (IOException) pae.getException(); throw (IOException) pae.getException();
@ -77,7 +77,7 @@ public class URLMetaDataIterator implements MetaDataIterator {
if (_url == null) if (_url == null)
return null; return null;
File file = new File(URLDecoder.decode(_url.getPath())); File file = new File(URLDecoder.decode(_url.getPath()));
return (((Boolean) AccessController.doPrivileged( return ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) ? file:null; J2DoPrivHelper.existsAction(file))).booleanValue()) ? file:null;
} }

View File

@ -271,7 +271,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler
public void parse(File file) throws IOException { public void parse(File file) throws IOException {
if (file == null) if (file == null)
return; return;
if (!((Boolean) AccessController.doPrivileged(J2DoPrivHelper if (!(AccessController.doPrivileged(J2DoPrivHelper
.isDirectoryAction(file))).booleanValue()) .isDirectoryAction(file))).booleanValue())
parse(new FileMetaDataIterator(file)); parse(new FileMetaDataIterator(file));
else { else {
@ -632,7 +632,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler
if (_loader != null) if (_loader != null)
return _loader; return _loader;
if (_curLoader == null) if (_curLoader == null)
_curLoader = (ClassLoader) AccessController.doPrivileged( _curLoader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
return _curLoader; return _curLoader;
} }

View File

@ -138,7 +138,7 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer {
File backup = Files.backup(file, false); File backup = Files.backup(file, false);
if (backup == null) { if (backup == null) {
File parent = file.getParentFile(); File parent = file.getParentFile();
if (parent != null && !((Boolean) AccessController.doPrivileged( if (parent != null && !(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(parent))).booleanValue()) J2DoPrivHelper.existsAction(parent))).booleanValue())
AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.mkdirsAction(parent)); J2DoPrivHelper.mkdirsAction(parent));
@ -198,7 +198,7 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer {
_backup = prepareWrite(file); _backup = prepareWrite(file);
try { try {
FileWriter out = new FileWriter( FileWriter out = new FileWriter(
(String) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getCanonicalPathAction(file)), J2DoPrivHelper.getCanonicalPathAction(file)),
(flags & APPEND) > 0); (flags & APPEND) > 0);
serialize(out, flags); serialize(out, flags);

View File

@ -51,16 +51,16 @@ public class Files {
* the file does not exist or a backup could not be created, returns null. * the file does not exist or a backup could not be created, returns null.
*/ */
public static File backup(File file, boolean copy) { public static File backup(File file, boolean copy) {
if (file == null || !((Boolean) AccessController.doPrivileged( if (file == null || !(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) J2DoPrivHelper.existsAction(file))).booleanValue())
return null; return null;
// create new file object copy so we don't modify the original // create new file object copy so we don't modify the original
String aPath = (String) AccessController.doPrivileged( String aPath = AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(file)); J2DoPrivHelper.getAbsolutePathAction(file));
File clone = new File(aPath); File clone = new File(aPath);
File bk = new File(aPath + "~"); File bk = new File(aPath + "~");
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.renameToAction(clone, bk))).booleanValue()) J2DoPrivHelper.renameToAction(clone, bk))).booleanValue())
return null; return null;
if (copy) { if (copy) {
@ -83,16 +83,16 @@ public class Files {
return null; return null;
if (!backup.getName().endsWith("~")) if (!backup.getName().endsWith("~"))
backup = new File(backup.getPath() + "~"); backup = new File(backup.getPath() + "~");
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(backup))).booleanValue()) J2DoPrivHelper.existsAction(backup))).booleanValue())
return null; return null;
// create new file object copy so we don't modify the original // create new file object copy so we don't modify the original
String path = (String) AccessController.doPrivileged( String path = AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(backup)); J2DoPrivHelper.getAbsolutePathAction(backup));
File clone = new File(path); File clone = new File(path);
File orig = new File(path.substring(0, path.length() - 1)); File orig = new File(path.substring(0, path.length() - 1));
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.renameToAction(clone, orig))).booleanValue()) J2DoPrivHelper.renameToAction(clone, orig))).booleanValue())
return null; return null;
if (copy) { if (copy) {
@ -132,7 +132,7 @@ public class Files {
if (innerIdx != -1) if (innerIdx != -1)
name = name.substring(0, innerIdx); name = name.substring(0, innerIdx);
URL rsrc = (URL) AccessController.doPrivileged( URL rsrc = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(cls, name + ext)); J2DoPrivHelper.getResourceAction(cls, name + ext));
if (rsrc != null && rsrc.getProtocol().equals("file")) if (rsrc != null && rsrc.getProtocol().equals("file"))
return new File(URLDecoder.decode(rsrc.getFile())); return new File(URLDecoder.decode(rsrc.getFile()));
@ -148,10 +148,10 @@ public class Files {
*/ */
public static File getPackageFile(File base, String pkg, boolean mkdirs) { public static File getPackageFile(File base, String pkg, boolean mkdirs) {
if (base == null) if (base == null)
base = new File((String) AccessController.doPrivileged( base = new File(AccessController.doPrivileged(
J2DoPrivHelper.getPropertyAction("user.dir"))); J2DoPrivHelper.getPropertyAction("user.dir")));
if (StringUtils.isEmpty(pkg)) { if (StringUtils.isEmpty(pkg)) {
if (mkdirs && !((Boolean) AccessController.doPrivileged( if (mkdirs && !(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(base))).booleanValue()) J2DoPrivHelper.existsAction(base))).booleanValue())
AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.mkdirsAction(base)); J2DoPrivHelper.mkdirsAction(base));
@ -161,7 +161,7 @@ public class Files {
pkg = pkg.replace('.', File.separatorChar); pkg = pkg.replace('.', File.separatorChar);
File file = null; File file = null;
try { try {
if (((String) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.getCanonicalPathAction(base))).endsWith(pkg)) J2DoPrivHelper.getCanonicalPathAction(base))).endsWith(pkg))
file = base; file = base;
else else
@ -173,7 +173,7 @@ public class Files {
throw new NestableRuntimeException(ioe); throw new NestableRuntimeException(ioe);
} }
if (mkdirs && !((Boolean) AccessController.doPrivileged( if (mkdirs && !(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) J2DoPrivHelper.existsAction(file))).booleanValue())
AccessController.doPrivileged(J2DoPrivHelper.mkdirsAction(file)); AccessController.doPrivileged(J2DoPrivHelper.mkdirsAction(file));
return file; return file;
@ -195,20 +195,20 @@ public class Files {
return null; return null;
File file = new File(name); File file = new File(name);
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(file))).booleanValue()) J2DoPrivHelper.existsAction(file))).booleanValue())
return file; return file;
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
URL url = (URL) AccessController.doPrivileged( URL url = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(loader, name)); J2DoPrivHelper.getResourceAction(loader, name));
if (url != null) { if (url != null) {
String urlFile = url.getFile(); String urlFile = url.getFile();
if (urlFile != null) { if (urlFile != null) {
File rsrc = new File(URLDecoder.decode(urlFile)); File rsrc = new File(URLDecoder.decode(urlFile));
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPrivHelper.existsAction(rsrc))).booleanValue()) J2DoPrivHelper.existsAction(rsrc))).booleanValue())
return rsrc; return rsrc;
} }
@ -254,7 +254,7 @@ public class Files {
if ("stderr".equals(file)) if ("stderr".equals(file))
return System.err; return System.err;
try { try {
return (FileOutputStream) AccessController.doPrivileged( return AccessController.doPrivileged(
J2DoPrivHelper.newFileOutputStreamAction( J2DoPrivHelper.newFileOutputStreamAction(
getFile(file, loader))); getFile(file, loader)));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
@ -269,17 +269,17 @@ public class Files {
*/ */
public static boolean copy(File from, File to) throws IOException { public static boolean copy(File from, File to) throws IOException {
if (from == null || to == null || if (from == null || to == null ||
!((Boolean) AccessController.doPrivileged( !(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(from))).booleanValue()) J2DoPrivHelper.existsAction(from))).booleanValue())
return false; return false;
FileInputStream in = null; FileInputStream in = null;
FileOutputStream out = null; FileOutputStream out = null;
try { try {
in = (FileInputStream) AccessController.doPrivileged( in = AccessController.doPrivileged(
J2DoPrivHelper.newFileInputStreamAction(from)); J2DoPrivHelper.newFileInputStreamAction(from));
BufferedInputStream inbuf = new BufferedInputStream(in); BufferedInputStream inbuf = new BufferedInputStream(in);
out = (FileOutputStream) AccessController.doPrivileged( out = AccessController.doPrivileged(
J2DoPrivHelper.newFileOutputStreamAction(to)); J2DoPrivHelper.newFileOutputStreamAction(to));
BufferedOutputStream outbuf = new BufferedOutputStream(out); BufferedOutputStream outbuf = new BufferedOutputStream(out);
for (int b; (b = inbuf.read()) != -1; outbuf.write(b)) ; for (int b; (b = inbuf.read()) != -1; outbuf.write(b)) ;

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.openjpa.lib.util; package org.apache.openjpa.lib.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
@ -44,10 +45,10 @@ public abstract class J2DoPriv5Helper extends J2DoPrivHelper {
* *
* @return Annotation[] * @return Annotation[]
*/ */
public static final PrivilegedAction getAnnotationsAction( public static final PrivilegedAction<Annotation []> getAnnotationsAction(
final AnnotatedElement element) { final AnnotatedElement element) {
return new PrivilegedAction() { return new PrivilegedAction<Annotation []>() {
public Object run() { public Annotation [] run() {
return element.getAnnotations(); return element.getAnnotations();
} }
}; };
@ -62,10 +63,11 @@ public abstract class J2DoPriv5Helper extends J2DoPrivHelper {
* *
* @return Annotation[] * @return Annotation[]
*/ */
public static final PrivilegedAction getDeclaredAnnotationsAction( public static final PrivilegedAction<Annotation []>
getDeclaredAnnotationsAction(
final AnnotatedElement element) { final AnnotatedElement element) {
return new PrivilegedAction() { return new PrivilegedAction<Annotation[]>() {
public Object run() { public Annotation [] run() {
return element.getDeclaredAnnotations(); return element.getDeclaredAnnotations();
} }
}; };
@ -80,10 +82,11 @@ public abstract class J2DoPriv5Helper extends J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction isAnnotationPresentAction( public static final PrivilegedAction<Boolean> isAnnotationPresentAction(
final AnnotatedElement element, final Class annotationClazz) { final AnnotatedElement element,
return new PrivilegedAction() { final Class<? extends Annotation> annotationClazz) {
public Object run() { return new PrivilegedAction<Boolean>() {
public Boolean run() {
return element.isAnnotationPresent(annotationClazz) return element.isAnnotationPresent(annotationClazz)
? Boolean.TRUE : Boolean.FALSE; ? Boolean.TRUE : Boolean.FALSE;
} }

View File

@ -23,7 +23,10 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.AccessibleObject; import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.ServerSocket; import java.net.ServerSocket;
@ -34,10 +37,13 @@ import java.net.UnknownHostException;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Enumeration;
import java.util.Properties;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import serp.bytecode.BCClass; import serp.bytecode.BCClass;
import serp.bytecode.BCClassLoader; import serp.bytecode.BCClassLoader;
import serp.bytecode.BCField;
import serp.bytecode.Code; import serp.bytecode.Code;
import serp.bytecode.FieldInstruction; import serp.bytecode.FieldInstruction;
import serp.bytecode.Project; import serp.bytecode.Project;
@ -104,7 +110,7 @@ import serp.bytecode.Project;
* 2) Methods with no exception thrown. PrivilegedAction is returned from * 2) Methods with no exception thrown. PrivilegedAction is returned from
* J2DoPrivHelper.*Action(). E.g. * J2DoPrivHelper.*Action(). E.g.
* *
* ClassLoader loader = (ClassLoader) AccessController.doPrivileged( * ClassLoader loader = AccessController.doPrivileged(
* J2DoPrivHelper.getClassLoaderAction(clazz)); * J2DoPrivHelper.getClassLoaderAction(clazz));
* *
* ClassLoader loader = (ClassLoader) (System.getSecurityManager() == null) * ClassLoader loader = (ClassLoader) (System.getSecurityManager() == null)
@ -115,7 +121,7 @@ import serp.bytecode.Project;
* from J2DoPrivHelper.*Action(). E.g. * from J2DoPrivHelper.*Action(). E.g.
* *
* try { * try {
* method = (Method) AccessController.doPrivileged( * method = AccessController.doPrivileged(
* J2DoPrivHelper.getDeclaredMethodAction(clazz, name, parameterType)); * J2DoPrivHelper.getDeclaredMethodAction(clazz, name, parameterType));
* } catch (PrivilegedActionException pae) { * } catch (PrivilegedActionException pae) {
* throw (NoSuchMethodException) pae.getException(); * throw (NoSuchMethodException) pae.getException();
@ -124,7 +130,7 @@ import serp.bytecode.Project;
* try { * try {
* method = (System.getSecurityManager() == null) * method = (System.getSecurityManager() == null)
* ? clazz.getDeclaredMethod(name,parameterType) * ? clazz.getDeclaredMethod(name,parameterType)
* : (Method) AccessController.doPrivileged( * : AccessController.doPrivileged(
* J2DoPrivHelper.getDeclaredMethodAction( * J2DoPrivHelper.getDeclaredMethodAction(
* clazz, name, parameterType)); * clazz, name, parameterType));
* } catch (PrivilegedActionException pae) { * } catch (PrivilegedActionException pae) {
@ -146,12 +152,12 @@ public abstract class J2DoPrivHelper {
*/ */
public static final String getLineSeparator() { public static final String getLineSeparator() {
if (lineSeparator == null) { if (lineSeparator == null) {
lineSeparator = (String) AccessController lineSeparator =
.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<String>() {
public Object run() { public String run() {
return System.getProperty("line.separator"); return System.getProperty("line.separator");
} }
}); });
} }
return lineSeparator; return lineSeparator;
} }
@ -164,12 +170,12 @@ public abstract class J2DoPrivHelper {
*/ */
public static final String getPathSeparator() { public static final String getPathSeparator() {
if (pathSeparator == null) { if (pathSeparator == null) {
pathSeparator = (String) AccessController pathSeparator =
.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<String>() {
public Object run() { public String run() {
return System.getProperty("path.separator"); return System.getProperty("path.separator");
} }
}); });
} }
return pathSeparator; return pathSeparator;
} }
@ -180,9 +186,9 @@ public abstract class J2DoPrivHelper {
* Requires security policy: 'permission java.lang.reflect.ReflectPermission * Requires security policy: 'permission java.lang.reflect.ReflectPermission
* "suppressAccessChecks";' * "suppressAccessChecks";'
*/ */
public static final PrivilegedAction setAccessibleAction( public static final PrivilegedAction<Object> setAccessibleAction(
final AccessibleObject aObj, final boolean flag) { final AccessibleObject aObj, final boolean flag) {
return new PrivilegedAction() { return new PrivilegedAction<Object>() {
public Object run() { public Object run() {
aObj.setAccessible(flag); aObj.setAccessible(flag);
return (Object) null; return (Object) null;
@ -229,7 +235,7 @@ public abstract class J2DoPrivHelper {
* @return Classloader * @return Classloader
*/ */
public static final PrivilegedAction<ClassLoader> getClassLoaderAction( public static final PrivilegedAction<ClassLoader> getClassLoaderAction(
final Class clazz) { final Class<?> clazz) {
return new PrivilegedAction<ClassLoader>() { return new PrivilegedAction<ClassLoader>() {
public ClassLoader run() { public ClassLoader run() {
return clazz.getClassLoader(); return clazz.getClassLoader();
@ -246,10 +252,10 @@ public abstract class J2DoPrivHelper {
* @return Field * @return Field
* @exception NoSuchFieldException * @exception NoSuchFieldException
*/ */
public static final PrivilegedExceptionAction getDeclaredFieldAction( public static final PrivilegedExceptionAction<Field> getDeclaredFieldAction(
final Class clazz, final String name) { final Class<?> clazz, final String name) {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Field>() {
public Object run() throws NoSuchFieldException { public Field run() throws NoSuchFieldException {
return clazz.getDeclaredField(name); return clazz.getDeclaredField(name);
} }
}; };
@ -263,10 +269,10 @@ public abstract class J2DoPrivHelper {
* *
* @return Field[] * @return Field[]
*/ */
public static final PrivilegedAction getDeclaredFieldsAction( public static final PrivilegedAction<Field []> getDeclaredFieldsAction(
final Class clazz) { final Class<?> clazz) {
return new PrivilegedAction() { return new PrivilegedAction<Field []>() {
public Object run() { public Field[] run() {
return clazz.getDeclaredFields(); return clazz.getDeclaredFields();
} }
}; };
@ -281,10 +287,12 @@ public abstract class J2DoPrivHelper {
* @return Method * @return Method
* @exception NoSuchMethodException * @exception NoSuchMethodException
*/ */
public static final PrivilegedExceptionAction getDeclaredMethodAction( public static final PrivilegedExceptionAction<Method>
final Class clazz, final String name, final Class[] parameterTypes) { getDeclaredMethodAction(
return new PrivilegedExceptionAction() { final Class<?> clazz, final String name,
public Object run() throws NoSuchMethodException { final Class<?>[] parameterTypes) {
return new PrivilegedExceptionAction<Method>() {
public Method run() throws NoSuchMethodException {
return clazz.getDeclaredMethod(name, parameterTypes); return clazz.getDeclaredMethod(name, parameterTypes);
} }
}; };
@ -298,10 +306,10 @@ public abstract class J2DoPrivHelper {
* *
* @return Method[] * @return Method[]
*/ */
public static final PrivilegedAction getDeclaredMethodsAction( public static final PrivilegedAction<Method []> getDeclaredMethodsAction(
final Class clazz) { final Class<?> clazz) {
return new PrivilegedAction() { return new PrivilegedAction<Method []>() {
public Object run() { public Method[] run() {
return clazz.getDeclaredMethods(); return clazz.getDeclaredMethods();
} }
}; };
@ -315,10 +323,10 @@ public abstract class J2DoPrivHelper {
* *
* @return URL * @return URL
*/ */
public static final PrivilegedAction getResourceAction( public static final PrivilegedAction<URL> getResourceAction(
final Class clazz, final String resource) { final Class<?> clazz, final String resource) {
return new PrivilegedAction() { return new PrivilegedAction<URL>() {
public Object run() { public URL run() {
return clazz.getResource(resource); return clazz.getResource(resource);
} }
}; };
@ -353,10 +361,10 @@ public abstract class J2DoPrivHelper {
* *
* @return ClassLoader * @return ClassLoader
*/ */
public static final PrivilegedAction getParentAction( public static final PrivilegedAction<ClassLoader> getParentAction(
final ClassLoader loader) { final ClassLoader loader) {
return new PrivilegedAction() { return new PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return loader.getParent(); return loader.getParent();
} }
}; };
@ -370,10 +378,10 @@ public abstract class J2DoPrivHelper {
* *
* @return URL * @return URL
*/ */
public static final PrivilegedAction getResourceAction( public static final PrivilegedAction<URL> getResourceAction(
final ClassLoader loader, final String resource) { final ClassLoader loader, final String resource) {
return new PrivilegedAction() { return new PrivilegedAction<URL>() {
public Object run() { public URL run() {
return loader.getResource(resource); return loader.getResource(resource);
} }
}; };
@ -388,10 +396,11 @@ public abstract class J2DoPrivHelper {
* @return Enumeration * @return Enumeration
* @exception IOException * @exception IOException
*/ */
public static final PrivilegedExceptionAction getResourcesAction( public static final PrivilegedExceptionAction<Enumeration<URL>>
getResourcesAction(
final ClassLoader loader, final String resource) throws IOException { final ClassLoader loader, final String resource) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Enumeration<URL>>() {
public Object run() throws IOException { public Enumeration<URL> run() throws IOException {
return loader.getResources(resource); return loader.getResources(resource);
} }
}; };
@ -405,9 +414,10 @@ public abstract class J2DoPrivHelper {
* *
* @return ClassLoader * @return ClassLoader
*/ */
public static final PrivilegedAction getSystemClassLoaderAction() { public static final PrivilegedAction<ClassLoader>
return new PrivilegedAction() { getSystemClassLoaderAction() {
public Object run() { return new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return ClassLoader.getSystemClassLoader(); return ClassLoader.getSystemClassLoader();
} }
}; };
@ -421,9 +431,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction deleteAction(final File f) { public static final PrivilegedAction<Boolean> deleteAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return f.delete() ? Boolean.TRUE : Boolean.FALSE; return f.delete() ? Boolean.TRUE : Boolean.FALSE;
} }
}; };
@ -437,9 +447,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction existsAction(final File f) { public static final PrivilegedAction<Boolean> existsAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
try { try {
return f.exists() ? Boolean.TRUE : Boolean.FALSE; return f.exists() ? Boolean.TRUE : Boolean.FALSE;
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
@ -457,9 +467,9 @@ public abstract class J2DoPrivHelper {
* *
* @return File * @return File
*/ */
public static final PrivilegedAction getAbsoluteFileAction(final File f) { public static final PrivilegedAction<File> getAbsoluteFileAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<File>() {
public Object run() { public File run() {
return f.getAbsoluteFile(); return f.getAbsoluteFile();
} }
}; };
@ -473,9 +483,10 @@ public abstract class J2DoPrivHelper {
* *
* @return String * @return String
*/ */
public static final PrivilegedAction getAbsolutePathAction(final File f) { public static final PrivilegedAction<String>
return new PrivilegedAction() { getAbsolutePathAction(final File f) {
public Object run() { return new PrivilegedAction<String>() {
public String run() {
return f.getAbsolutePath(); return f.getAbsolutePath();
} }
}; };
@ -490,10 +501,11 @@ public abstract class J2DoPrivHelper {
* @return String * @return String
* @exception IOException * @exception IOException
*/ */
public static final PrivilegedExceptionAction getCanonicalPathAction( public static final PrivilegedExceptionAction<String>
getCanonicalPathAction(
final File f) throws IOException { final File f) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<String>() {
public Object run() throws IOException { public String run() throws IOException {
return f.getCanonicalPath(); return f.getCanonicalPath();
} }
}; };
@ -507,9 +519,10 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction isDirectoryAction(final File f) { public static final PrivilegedAction<Boolean>
return new PrivilegedAction() { isDirectoryAction(final File f) {
public Object run() { return new PrivilegedAction<Boolean>() {
public Boolean run() {
return f.isDirectory() ? Boolean.TRUE : Boolean.FALSE; return f.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
} }
}; };
@ -523,9 +536,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction isFileAction(final File f) { public static final PrivilegedAction<Boolean> isFileAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return f.isFile() ? Boolean.TRUE : Boolean.FALSE; return f.isFile() ? Boolean.TRUE : Boolean.FALSE;
} }
}; };
@ -539,9 +552,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Long * @return Long
*/ */
public static final PrivilegedAction lengthAction(final File f) { public static final PrivilegedAction<Long> lengthAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<Long>() {
public Object run() { public Long run() {
return new Long(f.length()); return new Long(f.length());
} }
}; };
@ -555,9 +568,10 @@ public abstract class J2DoPrivHelper {
* *
* @return File[] * @return File[]
*/ */
public static final PrivilegedAction listFilesAction(final File f) { public static final PrivilegedAction<File []>
return new PrivilegedAction() { listFilesAction(final File f) {
public Object run() { return new PrivilegedAction<File []>() {
public File [] run() {
return f.listFiles(); return f.listFiles();
} }
}; };
@ -571,9 +585,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction mkdirsAction(final File f) { public static final PrivilegedAction<Boolean> mkdirsAction(final File f) {
return new PrivilegedAction() { return new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return f.mkdirs() ? Boolean.TRUE : Boolean.FALSE; return f.mkdirs() ? Boolean.TRUE : Boolean.FALSE;
} }
}; };
@ -587,10 +601,10 @@ public abstract class J2DoPrivHelper {
* *
* @return Boolean * @return Boolean
*/ */
public static final PrivilegedAction renameToAction(final File from, public static final PrivilegedAction<Boolean> renameToAction(
final File to) { final File from, final File to) {
return new PrivilegedAction() { return new PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return from.renameTo(to) ? Boolean.TRUE : Boolean.FALSE; return from.renameTo(to) ? Boolean.TRUE : Boolean.FALSE;
} }
}; };
@ -602,13 +616,14 @@ public abstract class J2DoPrivHelper {
* Requires security policy: * Requires security policy:
* 'permission java.io.FilePermission "read";' * 'permission java.io.FilePermission "read";'
* *
* @return Boolean * @return URL
* @throws MalformedURLException * @throws MalformedURLException
*/ */
public static final PrivilegedExceptionAction toURLAction(final File file) public static final PrivilegedExceptionAction<URL> toURLAction(
final File file)
throws MalformedURLException { throws MalformedURLException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<URL>() {
public Object run() throws MalformedURLException { public URL run() throws MalformedURLException {
return file.toURL(); return file.toURL();
} }
}; };
@ -623,10 +638,11 @@ public abstract class J2DoPrivHelper {
* @return FileInputStream * @return FileInputStream
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
public static final PrivilegedExceptionAction newFileInputStreamAction( public static final PrivilegedExceptionAction<FileInputStream>
newFileInputStreamAction(
final File f) throws FileNotFoundException { final File f) throws FileNotFoundException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<FileInputStream>() {
public Object run() throws FileNotFoundException { public FileInputStream run() throws FileNotFoundException {
return new FileInputStream(f); return new FileInputStream(f);
} }
}; };
@ -641,10 +657,11 @@ public abstract class J2DoPrivHelper {
* @return FileOutputStream * @return FileOutputStream
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
public static final PrivilegedExceptionAction newFileOutputStreamAction( public static final PrivilegedExceptionAction<FileOutputStream>
newFileOutputStreamAction(
final File f) throws FileNotFoundException { final File f) throws FileNotFoundException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<FileOutputStream>() {
public Object run() throws FileNotFoundException { public FileOutputStream run() throws FileNotFoundException {
return new FileOutputStream(f); return new FileOutputStream(f);
} }
}; };
@ -659,10 +676,11 @@ public abstract class J2DoPrivHelper {
* @return FileOutputStream * @return FileOutputStream
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
public static final PrivilegedExceptionAction newFileOutputStreamAction( public static final PrivilegedExceptionAction<FileOutputStream>
newFileOutputStreamAction(
final String f, final boolean append) throws FileNotFoundException { final String f, final boolean append) throws FileNotFoundException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<FileOutputStream>() {
public Object run() throws FileNotFoundException { public FileOutputStream run() throws FileNotFoundException {
return new FileOutputStream(f, append); return new FileOutputStream(f, append);
} }
}; };
@ -677,10 +695,10 @@ public abstract class J2DoPrivHelper {
* @return InetAddress * @return InetAddress
* @throws UnknownHostException * @throws UnknownHostException
*/ */
public static final PrivilegedExceptionAction getByNameAction( public static final PrivilegedExceptionAction<InetAddress> getByNameAction(
final String hostname) throws UnknownHostException { final String hostname) throws UnknownHostException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<InetAddress>() {
public Object run() throws UnknownHostException { public InetAddress run() throws UnknownHostException {
return InetAddress.getByName(hostname); return InetAddress.getByName(hostname);
} }
}; };
@ -695,10 +713,10 @@ public abstract class J2DoPrivHelper {
* @return Socket * @return Socket
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction newSocketAction( public static final PrivilegedExceptionAction<Socket> newSocketAction(
final InetAddress host, final int port) throws IOException { final InetAddress host, final int port) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Socket>() {
public Object run() throws IOException { public Socket run() throws IOException {
return new Socket(host, port); return new Socket(host, port);
} }
}; };
@ -713,10 +731,10 @@ public abstract class J2DoPrivHelper {
* @return ServerSocket * @return ServerSocket
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction newServerSocketAction( public static final PrivilegedExceptionAction<ServerSocket> newServerSocketAction(
final int port) throws IOException { final int port) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<ServerSocket>() {
public Object run() throws IOException { public ServerSocket run() throws IOException {
return new ServerSocket(port); return new ServerSocket(port);
} }
}; };
@ -731,10 +749,10 @@ public abstract class J2DoPrivHelper {
* @return Socket * @return Socket
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction acceptAction( public static final PrivilegedExceptionAction<Socket> acceptAction(
final ServerSocket ss) throws IOException { final ServerSocket ss) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Socket>() {
public Object run() throws IOException { public Socket run() throws IOException {
return ss.accept(); return ss.accept();
} }
}; };
@ -748,9 +766,9 @@ public abstract class J2DoPrivHelper {
* *
* @return Properties * @return Properties
*/ */
public static final PrivilegedAction getPropertiesAction() { public static final PrivilegedAction<Properties> getPropertiesAction() {
return new PrivilegedAction() { return new PrivilegedAction<Properties>() {
public Object run() { public Properties run() {
return System.getProperties(); return System.getProperties();
} }
}; };
@ -764,9 +782,10 @@ public abstract class J2DoPrivHelper {
* *
* @return String * @return String
*/ */
public static final PrivilegedAction getPropertyAction(final String name) { public static final PrivilegedAction<String> getPropertyAction(
return new PrivilegedAction() { final String name) {
public Object run() { return new PrivilegedAction<String>() {
public String run() {
return System.getProperty(name); return System.getProperty(name);
} }
}; };
@ -799,10 +818,10 @@ public abstract class J2DoPrivHelper {
* *
* @return Thread * @return Thread
*/ */
public static final PrivilegedAction newDaemonThreadAction( public static final PrivilegedAction<Thread> newDaemonThreadAction(
final Runnable target, final String name) { final Runnable target, final String name) {
return new PrivilegedAction() { return new PrivilegedAction<Thread>() {
public Object run() { public Thread run() {
Thread thread = new Thread(target, name); Thread thread = new Thread(target, name);
thread.setDaemon(true); thread.setDaemon(true);
return thread; return thread;
@ -819,10 +838,10 @@ public abstract class J2DoPrivHelper {
* @return InputStream * @return InputStream
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction openStreamAction( public static final PrivilegedExceptionAction<InputStream> openStreamAction(
final URL url) throws IOException { final URL url) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<InputStream>() {
public Object run() throws IOException { public InputStream run() throws IOException {
return url.openStream(); return url.openStream();
} }
}; };
@ -837,9 +856,9 @@ public abstract class J2DoPrivHelper {
* @return Object * @return Object
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction getContentAction( public static final PrivilegedExceptionAction<Object> getContentAction(
final URLConnection con) throws IOException { final URLConnection con) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Object>() {
public Object run() throws IOException { public Object run() throws IOException {
return con.getContent(); return con.getContent();
} }
@ -855,10 +874,11 @@ public abstract class J2DoPrivHelper {
* @return ZipFile * @return ZipFile
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction newZipFileAction(final File f) public static final PrivilegedExceptionAction<ZipFile> newZipFileAction(
final File f)
throws IOException { throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<ZipFile>() {
public Object run() throws IOException { public ZipFile run() throws IOException {
return new ZipFile(f); return new ZipFile(f);
} }
}; };
@ -872,9 +892,9 @@ public abstract class J2DoPrivHelper {
* *
* @return serp.bytecode.Code * @return serp.bytecode.Code
*/ */
public static final PrivilegedAction newCodeAction() { public static final PrivilegedAction<Code> newCodeAction() {
return new PrivilegedAction() { return new PrivilegedAction<Code>() {
public Object run() { public Code run() {
return new Code(); return new Code();
} }
}; };
@ -888,10 +908,11 @@ public abstract class J2DoPrivHelper {
* *
* @return TemporaryClassLoader * @return TemporaryClassLoader
*/ */
public static final PrivilegedAction newTemporaryClassLoaderAction( public static final PrivilegedAction<TemporaryClassLoader>
newTemporaryClassLoaderAction(
final ClassLoader parent) { final ClassLoader parent) {
return new PrivilegedAction() { return new PrivilegedAction<TemporaryClassLoader>() {
public Object run() { public TemporaryClassLoader run() {
return new TemporaryClassLoader(parent); return new TemporaryClassLoader(parent);
} }
}; };
@ -905,9 +926,10 @@ public abstract class J2DoPrivHelper {
* *
* @return MultiClassLoader * @return MultiClassLoader
*/ */
public static final PrivilegedAction newMultiClassLoaderAction() { public static final PrivilegedAction<MultiClassLoader>
return new PrivilegedAction() { newMultiClassLoaderAction() {
public Object run() { return new PrivilegedAction<MultiClassLoader>() {
public MultiClassLoader run() {
return new MultiClassLoader(); return new MultiClassLoader();
} }
}; };
@ -921,19 +943,19 @@ public abstract class J2DoPrivHelper {
* *
* @return BCClassLoader * @return BCClassLoader
*/ */
public static final PrivilegedAction newBCClassLoaderAction( public static final PrivilegedAction<BCClassLoader> newBCClassLoaderAction(
final Project project, final ClassLoader parent) { final Project project, final ClassLoader parent) {
return new PrivilegedAction() { return new PrivilegedAction<BCClassLoader>() {
public Object run() { public BCClassLoader run() {
return new BCClassLoader(project, parent); return new BCClassLoader(project, parent);
} }
}; };
} }
public static final PrivilegedAction newBCClassLoaderAction( public static final PrivilegedAction<BCClassLoader> newBCClassLoaderAction(
final Project project) { final Project project) {
return new PrivilegedAction() { return new PrivilegedAction<BCClassLoader>() {
public Object run() { public BCClassLoader run() {
return new BCClassLoader(project); return new BCClassLoader(project);
} }
}; };
@ -945,12 +967,12 @@ public abstract class J2DoPrivHelper {
* Requires security policy: * Requires security policy:
* 'permission java.io.FilePermission "write";' * 'permission java.io.FilePermission "write";'
* *
* @return File * @return null
* @throws IOException * @throws IOException
*/ */
public static final PrivilegedExceptionAction bCClassWrite( public static final PrivilegedExceptionAction<Object> bCClassWrite(
final BCClass bc, final File f) throws IOException { final BCClass bc, final File f) throws IOException {
return new PrivilegedExceptionAction() { return new PrivilegedExceptionAction<Object>() {
public Object run() throws IOException { public Object run() throws IOException {
bc.write(f); bc.write(f);
return null; return null;
@ -966,10 +988,10 @@ public abstract class J2DoPrivHelper {
* *
* @return BCField * @return BCField
*/ */
public static final PrivilegedAction getBCClassFieldsAction( public static final PrivilegedAction<BCField []> getBCClassFieldsAction(
final BCClass bcClass, final String fieldName) { final BCClass bcClass, final String fieldName) {
return new PrivilegedAction() { return new PrivilegedAction<BCField []>() {
public Object run() { public BCField [] run() {
return bcClass.getFields(fieldName); return bcClass.getFields(fieldName);
} }
}; };
@ -983,10 +1005,10 @@ public abstract class J2DoPrivHelper {
* *
* @return BCField * @return BCField
*/ */
public static final PrivilegedAction getFieldInstructionFieldAction( public static final PrivilegedAction<BCField> getFieldInstructionFieldAction(
final FieldInstruction instruction) { final FieldInstruction instruction) {
return new PrivilegedAction() { return new PrivilegedAction<BCField>() {
public Object run() { public BCField run() {
return instruction.getField(); return instruction.getField();
} }
}; };
@ -1000,10 +1022,10 @@ public abstract class J2DoPrivHelper {
* *
* @return BCClass * @return BCClass
*/ */
public static final PrivilegedAction loadProjectClassAction( public static final PrivilegedAction<BCClass> loadProjectClassAction(
final Project project, final Class clazz) { final Project project, final Class<?> clazz) {
return new PrivilegedAction() { return new PrivilegedAction<BCClass>() {
public Object run() { public BCClass run() {
return project.loadClass(clazz); return project.loadClass(clazz);
} }
}; };
@ -1017,10 +1039,10 @@ public abstract class J2DoPrivHelper {
* *
* @return BCClass * @return BCClass
*/ */
public static final PrivilegedAction loadProjectClassAction( public static final PrivilegedAction<BCClass> loadProjectClassAction(
final Project project, final String clazzName) { final Project project, final String clazzName) {
return new PrivilegedAction() { return new PrivilegedAction<BCClass>() {
public Object run() { public BCClass run() {
return project.loadClass(clazzName); return project.loadClass(clazzName);
} }
}; };

View File

@ -46,7 +46,7 @@ public class JavaVersions {
private static Method INIT_CAUSE = null; private static Method INIT_CAUSE = null;
static { static {
String specVersion = (String) AccessController.doPrivileged( String specVersion = AccessController.doPrivileged(
J2DoPrivHelper.getPropertyAction("java.specification.version")); J2DoPrivHelper.getPropertyAction("java.specification.version"));
if ("1.2".equals(specVersion)) if ("1.2".equals(specVersion))
VERSION = 2; VERSION = 2;

View File

@ -100,7 +100,7 @@ public class Localizer {
return loc; return loc;
else { else {
loc = new Localizer(pkg, file, locale, loc = new Localizer(pkg, file, locale,
cls == null ? null:(ClassLoader) AccessController.doPrivileged( cls == null ? null:AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(cls))); J2DoPrivHelper.getClassLoaderAction(cls)));
_localizers.put(key, loc); _localizers.put(key, loc);
return loc; return loc;

View File

@ -48,7 +48,7 @@ public class MultiClassLoader extends ClassLoader {
* The standard system class loader. * The standard system class loader.
*/ */
public static final ClassLoader SYSTEM_LOADER = public static final ClassLoader SYSTEM_LOADER =
(ClassLoader) AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.getSystemClassLoaderAction()); J2DoPrivHelper.getSystemClassLoaderAction());
private List _loaders = new ArrayList(5); private List _loaders = new ArrayList(5);
@ -85,7 +85,7 @@ public class MultiClassLoader extends ClassLoader {
for (int i = 0; i < loaders.length; i++) { for (int i = 0; i < loaders.length; i++) {
loader = (ClassLoader) itr.next(); loader = (ClassLoader) itr.next();
if (loader == THREAD_LOADER) if (loader == THREAD_LOADER)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
loaders[i] = loader; loaders[i] = loader;
} }
@ -98,7 +98,7 @@ public class MultiClassLoader extends ClassLoader {
public ClassLoader getClassLoader(int index) { public ClassLoader getClassLoader(int index) {
ClassLoader loader = (ClassLoader) _loaders.get(index); ClassLoader loader = (ClassLoader) _loaders.get(index);
if (loader == THREAD_LOADER) if (loader == THREAD_LOADER)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
return loader; return loader;
} }
@ -206,7 +206,7 @@ public class MultiClassLoader extends ClassLoader {
for (Iterator itr = _loaders.iterator(); itr.hasNext();) { for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
loader = (ClassLoader) itr.next(); loader = (ClassLoader) itr.next();
if (loader == THREAD_LOADER) if (loader == THREAD_LOADER)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
try { try {
return Class.forName(name, false, loader); return Class.forName(name, false, loader);
@ -222,13 +222,13 @@ public class MultiClassLoader extends ClassLoader {
for (Iterator itr = _loaders.iterator(); itr.hasNext();) { for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
loader = (ClassLoader) itr.next(); loader = (ClassLoader) itr.next();
if (loader == THREAD_LOADER) if (loader == THREAD_LOADER)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if (loader == null) // skip if (loader == null) // skip
continue; continue;
rsrc = (URL) AccessController.doPrivileged( rsrc = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(loader, name)); J2DoPrivHelper.getResourceAction(loader, name));
if (rsrc != null) if (rsrc != null)
return rsrc; return rsrc;
@ -244,14 +244,14 @@ public class MultiClassLoader extends ClassLoader {
for (Iterator itr = _loaders.iterator(); itr.hasNext();) { for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
loader = (ClassLoader) itr.next(); loader = (ClassLoader) itr.next();
if (loader == THREAD_LOADER) if (loader == THREAD_LOADER)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
if (loader == null) // skip if (loader == null) // skip
continue; continue;
try { try {
rsrcs = (Enumeration) AccessController.doPrivileged( rsrcs = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction(loader, name)); J2DoPrivHelper.getResourcesAction(loader, name));
while (rsrcs.hasMoreElements()) { while (rsrcs.hasMoreElements()) {
rsrc = rsrcs.nextElement(); rsrc = rsrcs.nextElement();

View File

@ -211,7 +211,7 @@ public class ParameterTemplate {
if (_params.containsKey(param.toString())) if (_params.containsKey(param.toString()))
copy.append(_params.get(param.toString())); copy.append(_params.get(param.toString()));
else else
copy.append((String) AccessController.doPrivileged( copy.append(AccessController.doPrivileged(
J2DoPrivHelper.getPropertyAction(param.toString()))); J2DoPrivHelper.getPropertyAction(param.toString())));
param = null; param = null;
} else if (param != null) } else if (param != null)

View File

@ -88,12 +88,12 @@ public class Services {
public static String[] getImplementors(String serviceName, public static String[] getImplementors(String serviceName,
ClassLoader loader) { ClassLoader loader) {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
try { try {
Set resourceList = new TreeSet(); Set resourceList = new TreeSet();
Enumeration resources = (Enumeration) AccessController.doPrivileged( Enumeration resources = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction(loader, PREFIX + serviceName)); J2DoPrivHelper.getResourcesAction(loader, PREFIX + serviceName));
while (resources.hasMoreElements()) while (resources.hasMoreElements())
addResources((URL) resources.nextElement(), resourceList); addResources((URL) resources.nextElement(), resourceList);
@ -205,7 +205,7 @@ public class Services {
public static Class[] getImplementorClasses(String serviceName, public static Class[] getImplementorClasses(String serviceName,
ClassLoader loader, boolean skipMissing) throws ClassNotFoundException { ClassLoader loader, boolean skipMissing) throws ClassNotFoundException {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
String[] names = getImplementors(serviceName, loader); String[] names = getImplementors(serviceName, loader);

View File

@ -38,7 +38,7 @@ class StreamResourceBundleProvider implements ResourceBundleProvider {
ClassLoader loader) { ClassLoader loader) {
String rsrc = name.replace('.', '/') + ".properties"; String rsrc = name.replace('.', '/') + ".properties";
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
InputStream in = loader.getResourceAsStream(rsrc); InputStream in = loader.getResourceAsStream(rsrc);

View File

@ -40,7 +40,7 @@ class ZipResourceBundleProvider implements ResourceBundleProvider {
ClassLoader loader) { ClassLoader loader) {
String rsrc = name.replace('.', '/') + ".properties"; String rsrc = name.replace('.', '/') + ".properties";
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
InputStream in = loader.getResourceAsStream(rsrc); InputStream in = loader.getResourceAsStream(rsrc);

View File

@ -1308,7 +1308,7 @@ public class AnnotationPersistenceMappingParser
if (xmlTypeClass != null if (xmlTypeClass != null
&& StringUtils.isEmpty(pcols[i].columnDefinition()) && StringUtils.isEmpty(pcols[i].columnDefinition())
&& ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper && (AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(fm.getDeclaredType(), .isAnnotationPresentAction(fm.getDeclaredType(),
xmlTypeClass))).booleanValue()) { xmlTypeClass))).booleanValue()) {
DBDictionary dict = ((MappingRepository) getRepository()) DBDictionary dict = ((MappingRepository) getRepository())

View File

@ -43,7 +43,7 @@ public class TestEnhancementWithMultiplePUs
OpenJPAConfiguration conf = new OpenJPAConfigurationImpl(); OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
Configurations.populateConfiguration(conf, new Options()); Configurations.populateConfiguration(conf, new Options());
MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
ClassLoader loader = (ClassLoader) AccessController ClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction( .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
getClass().getClassLoader())); getClass().getClassLoader()));
Project project = new Project(); Project project = new Project();
@ -76,7 +76,7 @@ public class TestEnhancementWithMultiplePUs
"META-INF/persistence.xml#second-persistence-unit"); "META-INF/persistence.xml#second-persistence-unit");
Configurations.populateConfiguration(conf, opts); Configurations.populateConfiguration(conf, opts);
MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
ClassLoader loader = (ClassLoader) AccessController ClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction( .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
getClass().getClassLoader())); getClass().getClassLoader()));
Project project = new Project(); Project project = new Project();
@ -115,7 +115,7 @@ public class TestEnhancementWithMultiplePUs
opts.setProperty("p", "META-INF/persistence.xml"); opts.setProperty("p", "META-INF/persistence.xml");
Configurations.populateConfiguration(conf, opts); Configurations.populateConfiguration(conf, opts);
MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
ClassLoader loader = (ClassLoader) AccessController ClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction( .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
getClass().getClassLoader())); getClass().getClassLoader()));
Project project = new Project(); Project project = new Project();

View File

@ -467,12 +467,12 @@ public class AnnotationPersistenceMetaDataParser
// check immediately whether the user is using any annotations, // check immediately whether the user is using any annotations,
// regardless of mode. this prevents adding non-entity classes to // regardless of mode. this prevents adding non-entity classes to
// repository if we're ignoring these annotations in mapping mode // repository if we're ignoring these annotations in mapping mode
if (!((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if (!(AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(_cls, Entity.class))).booleanValue() .isAnnotationPresentAction(_cls, Entity.class))).booleanValue()
&& !((Boolean) AccessController.doPrivileged(J2DoPriv5Helper && !(AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(_cls, Embeddable.class))) .isAnnotationPresentAction(_cls, Embeddable.class)))
.booleanValue() .booleanValue()
&& !((Boolean) AccessController.doPrivileged(J2DoPriv5Helper && !(AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(_cls, MappedSuperclass.class))) .isAnnotationPresentAction(_cls, MappedSuperclass.class)))
.booleanValue()) .booleanValue())
return null; return null;
@ -678,17 +678,17 @@ public class AnnotationPersistenceMetaDataParser
cls = cls.getEnclosingClass(); cls = cls.getEnclosingClass();
String rsrc = StringUtils.replace(cls.getName(), ".", "/"); String rsrc = StringUtils.replace(cls.getName(), ".", "/");
ClassLoader loader = (ClassLoader) AccessController.doPrivileged( ClassLoader loader = AccessController.doPrivileged(
J2DoPriv5Helper.getClassLoaderAction(cls)); J2DoPriv5Helper.getClassLoaderAction(cls));
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPriv5Helper.getSystemClassLoaderAction()); J2DoPriv5Helper.getSystemClassLoaderAction());
if (loader == null) if (loader == null)
return null; return null;
URL url = (URL) AccessController.doPrivileged( URL url = AccessController.doPrivileged(
J2DoPriv5Helper.getResourceAction(loader, rsrc + ".java")); J2DoPriv5Helper.getResourceAction(loader, rsrc + ".java"));
if (url == null) { if (url == null) {
url = (URL) AccessController.doPrivileged( url = AccessController.doPrivileged(
J2DoPriv5Helper.getResourceAction(loader, rsrc + ".class")); J2DoPriv5Helper.getResourceAction(loader, rsrc + ".class"));
if (url == null) if (url == null)
return null; return null;
@ -782,7 +782,7 @@ public class AnnotationPersistenceMetaDataParser
J2DoPriv5Helper.getDeclaredFieldsAction( J2DoPriv5Helper.getDeclaredFieldsAction(
meta.getDescribedType())); meta.getDescribedType()));
for (int i = 0; i < fields.length; i++) for (int i = 0; i < fields.length; i++)
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(fields[i], DetachedState.class))) .isAnnotationPresentAction(fields[i], DetachedState.class)))
.booleanValue()) .booleanValue())
meta.setDetachedState(fields[i].getName()); meta.setDetachedState(fields[i].getName());
@ -984,7 +984,7 @@ public class AnnotationPersistenceMetaDataParser
fmd.setExplicit(true); fmd.setExplicit(true);
AnnotatedElement el = (AnnotatedElement) member; AnnotatedElement el = (AnnotatedElement) member;
boolean lob = ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper boolean lob = (AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(el, Lob.class))).booleanValue(); .isAnnotationPresentAction(el, Lob.class))).booleanValue();
if (isMetaDataMode()) { if (isMetaDataMode()) {
switch (pstrat) { switch (pstrat) {

View File

@ -1198,7 +1198,7 @@ public class AnnotationPersistenceMetaDataSerializer
public void serialize(File file, int flags) throws IOException { public void serialize(File file, int flags) throws IOException {
try { try {
FileWriter out = new FileWriter((String) AccessController FileWriter out = new FileWriter(AccessController
.doPrivileged(J2DoPrivHelper.getCanonicalPathAction(file)), .doPrivileged(J2DoPrivHelper.getCanonicalPathAction(file)),
(flags & APPEND) > 0); (flags & APPEND) > 0);
serialize(out, flags); serialize(out, flags);

View File

@ -173,9 +173,9 @@ public class AnnotationPersistenceXMLMetaDataParser {
private XMLMetaData parseXMLClassAnnotations() { private XMLMetaData parseXMLClassAnnotations() {
// check immediately whether the class has JAXB XML annotations // check immediately whether the class has JAXB XML annotations
if (_cls == null || xmlTypeClass == null if (_cls == null || xmlTypeClass == null
|| !(((Boolean) AccessController.doPrivileged(J2DoPriv5Helper || !((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(_cls, xmlTypeClass))).booleanValue() .isAnnotationPresentAction(_cls, xmlTypeClass))).booleanValue()
&& ((Boolean) AccessController && (AccessController
.doPrivileged(J2DoPriv5Helper.isAnnotationPresentAction(_cls, .doPrivileged(J2DoPriv5Helper.isAnnotationPresentAction(_cls,
xmlRootElementClass))).booleanValue())) xmlRootElementClass))).booleanValue()))
return null; return null;
@ -225,7 +225,7 @@ public class AnnotationPersistenceXMLMetaDataParser {
Class superclass = cls.getSuperclass(); Class superclass = cls.getSuperclass();
// handle inheritance at sub-element level // handle inheritance at sub-element level
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(superclass, xmlTypeClass))) .isAnnotationPresentAction(superclass, xmlTypeClass)))
.booleanValue()) .booleanValue())
populateFromReflection(superclass, meta); populateFromReflection(superclass, meta);
@ -247,7 +247,7 @@ public class AnnotationPersistenceXMLMetaDataParser {
// avoid JAXB XML bind default name // avoid JAXB XML bind default name
if (StringUtils.equals(XMLMetaData.defaultName, xmlname)) if (StringUtils.equals(XMLMetaData.defaultName, xmlname))
xmlname = member.getName(); xmlname = member.getName();
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(((Field) member).getType(), .isAnnotationPresentAction(((Field) member).getType(),
xmlTypeClass))).booleanValue()) { xmlTypeClass))).booleanValue()) {
field = _repos.addXMLMetaData(((Field) member).getType() field = _repos.addXMLMetaData(((Field) member).getType()

View File

@ -118,7 +118,7 @@ public class PersistenceMetaDataDefaults
if (member == null) if (member == null)
return null; return null;
AnnotatedElement el = (AnnotatedElement) member; AnnotatedElement el = (AnnotatedElement) member;
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(el, Transient.class))).booleanValue()) .isAnnotationPresentAction(el, Transient.class))).booleanValue())
return TRANSIENT; return TRANSIENT;
if (fmd != null if (fmd != null
@ -185,7 +185,7 @@ public class PersistenceMetaDataDefaults
} }
//### EJB3: what if defined in XML? //### EJB3: what if defined in XML?
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(type, Embeddable.class))).booleanValue()) .isAnnotationPresentAction(type, Embeddable.class))).booleanValue())
return EMBEDDED; return EMBEDDED;
if (Serializable.class.isAssignableFrom(type)) if (Serializable.class.isAssignableFrom(type))
@ -312,7 +312,7 @@ public class PersistenceMetaDataDefaults
if (member instanceof Method) { if (member instanceof Method) {
try { try {
// check for setters for methods // check for setters for methods
Method setter = (Method) AccessController.doPrivileged( Method setter = AccessController.doPrivileged(
J2DoPriv5Helper.getDeclaredMethodAction( J2DoPriv5Helper.getDeclaredMethodAction(
meta.getDescribedType(), "set" + meta.getDescribedType(), "set" +
StringUtils.capitalize(name), new Class[] { StringUtils.capitalize(name), new Class[] {
@ -337,7 +337,7 @@ public class PersistenceMetaDataDefaults
private boolean isAnnotatedTransient(Member member) { private boolean isAnnotatedTransient(Member member) {
return member instanceof AnnotatedElement return member instanceof AnnotatedElement
&& ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper && (AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(((AnnotatedElement) member), .isAnnotationPresentAction(((AnnotatedElement) member),
Transient.class))).booleanValue(); Transient.class))).booleanValue();
} }

View File

@ -293,24 +293,24 @@ public class PersistenceMetaDataFactory
return null; return null;
Collection classes = repos.loadPersistentTypes(false, loader); Collection classes = repos.loadPersistentTypes(false, loader);
for (Class cls : (Collection<Class>) classes) { for (Class cls : (Collection<Class>) classes) {
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, NamedQuery.class))) .isAnnotationPresentAction(cls, NamedQuery.class)))
.booleanValue() && hasNamedQuery .booleanValue() && hasNamedQuery
(queryName, (NamedQuery) cls.getAnnotation(NamedQuery.class))) (queryName, (NamedQuery) cls.getAnnotation(NamedQuery.class)))
return cls; return cls;
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, NamedQueries.class))) .isAnnotationPresentAction(cls, NamedQueries.class)))
.booleanValue() && .booleanValue() &&
hasNamedQuery(queryName, ((NamedQueries) cls. hasNamedQuery(queryName, ((NamedQueries) cls.
getAnnotation(NamedQueries.class)).value())) getAnnotation(NamedQueries.class)).value()))
return cls; return cls;
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, NamedNativeQuery.class))) .isAnnotationPresentAction(cls, NamedNativeQuery.class)))
.booleanValue() && .booleanValue() &&
hasNamedNativeQuery(queryName, (NamedNativeQuery) cls. hasNamedNativeQuery(queryName, (NamedNativeQuery) cls.
getAnnotation(NamedNativeQuery.class))) getAnnotation(NamedNativeQuery.class)))
return cls; return cls;
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, NamedNativeQueries.class))) .isAnnotationPresentAction(cls, NamedNativeQueries.class)))
.booleanValue() && .booleanValue() &&
hasNamedNativeQuery(queryName, ((NamedNativeQueries) cls. hasNamedNativeQuery(queryName, ((NamedNativeQueries) cls.
@ -329,14 +329,14 @@ public class PersistenceMetaDataFactory
Collection classes = repos.loadPersistentTypes(false, loader); Collection classes = repos.loadPersistentTypes(false, loader);
for (Class cls : (Collection<Class>) classes) { for (Class cls : (Collection<Class>) classes) {
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .isAnnotationPresentAction(cls, SqlResultSetMapping.class)))
.booleanValue() && .booleanValue() &&
hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. hasRSMapping(rsMappingName, (SqlResultSetMapping) cls.
getAnnotation(SqlResultSetMapping.class))) getAnnotation(SqlResultSetMapping.class)))
return cls; return cls;
if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper if ((AccessController.doPrivileged(J2DoPriv5Helper
.isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .isAnnotationPresentAction(cls, SqlResultSetMappings.class)))
.booleanValue() && .booleanValue() &&
hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls.
@ -457,11 +457,11 @@ public class PersistenceMetaDataFactory
private File defaultXMLFile() { private File defaultXMLFile() {
ClassLoader loader = repos.getConfiguration(). ClassLoader loader = repos.getConfiguration().
getClassResolverInstance().getClassLoader(getClass(), null); getClassResolverInstance().getClassLoader(getClass(), null);
URL rsrc = (URL) AccessController.doPrivileged( URL rsrc = AccessController.doPrivileged(
J2DoPriv5Helper.getResourceAction(loader, "META-INF/orm.xml")); J2DoPriv5Helper.getResourceAction(loader, "META-INF/orm.xml"));
if (rsrc != null) { if (rsrc != null) {
File file = new File(rsrc.getFile()); File file = new File(rsrc.getFile());
if (((Boolean) AccessController.doPrivileged( if ((AccessController.doPrivileged(
J2DoPriv5Helper.existsAction(file))).booleanValue()) J2DoPriv5Helper.existsAction(file))).booleanValue())
return file; return file;
} }

View File

@ -228,7 +228,7 @@ public class PersistenceProductDerivation
public List getAnchorsInResource(String resource) throws Exception { public List getAnchorsInResource(String resource) throws Exception {
ConfigurationParser parser = new ConfigurationParser(null); ConfigurationParser parser = new ConfigurationParser(null);
try { try {
ClassLoader loader = (ClassLoader) AccessController.doPrivileged( ClassLoader loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
List<URL> urls = getResourceURLs(resource, loader); List<URL> urls = getResourceURLs(resource, loader);
if (urls != null) { if (urls != null) {
@ -249,7 +249,7 @@ public class PersistenceProductDerivation
String[] prefixes = ProductDerivations.getConfigurationPrefixes(); String[] prefixes = ProductDerivations.getConfigurationPrefixes();
String rsrc = null; String rsrc = null;
for (int i = 0; i < prefixes.length && StringUtils.isEmpty(rsrc); i++) for (int i = 0; i < prefixes.length && StringUtils.isEmpty(rsrc); i++)
rsrc = (String) AccessController.doPrivileged(J2DoPrivHelper rsrc = AccessController.doPrivileged(J2DoPrivHelper
.getPropertyAction(prefixes[i] + ".properties")); .getPropertyAction(prefixes[i] + ".properties"));
boolean explicit = !StringUtils.isEmpty(rsrc); boolean explicit = !StringUtils.isEmpty(rsrc);
String anchor = null; String anchor = null;
@ -284,11 +284,11 @@ public class PersistenceProductDerivation
throws IOException { throws IOException {
Enumeration<URL> urls = null; Enumeration<URL> urls = null;
try { try {
urls = (Enumeration) AccessController.doPrivileged( urls = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction(loader, rsrc)); J2DoPrivHelper.getResourcesAction(loader, rsrc));
if (!urls.hasMoreElements()) { if (!urls.hasMoreElements()) {
if (!rsrc.startsWith("META-INF")) if (!rsrc.startsWith("META-INF"))
urls = (Enumeration) AccessController.doPrivileged( urls = AccessController.doPrivileged(
J2DoPrivHelper.getResourcesAction( J2DoPrivHelper.getResourcesAction(
loader, "META-INF/" + rsrc)); loader, "META-INF/" + rsrc));
if (!urls.hasMoreElements()) if (!urls.hasMoreElements())
@ -315,7 +315,7 @@ public class PersistenceProductDerivation
String name, Map m, ClassLoader loader, boolean explicit) String name, Map m, ClassLoader loader, boolean explicit)
throws IOException { throws IOException {
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
List<URL> urls = getResourceURLs(rsrc, loader); List<URL> urls = getResourceURLs(rsrc, loader);
@ -401,7 +401,7 @@ public class PersistenceProductDerivation
return true; return true;
if (loader == null) if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged( loader = AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction()); J2DoPrivHelper.getContextClassLoaderAction());
try { try {
if (PersistenceProviderImpl.class.isAssignableFrom if (PersistenceProviderImpl.class.isAssignableFrom
@ -513,7 +513,7 @@ public class PersistenceProductDerivation
public void parse(File file) public void parse(File file)
throws IOException { throws IOException {
try { try {
_source = (URL) AccessController.doPrivileged(J2DoPrivHelper _source = AccessController.doPrivileged(J2DoPrivHelper
.toURLAction(file)); .toURLAction(file));
} catch (PrivilegedActionException pae) { } catch (PrivilegedActionException pae) {
throw (MalformedURLException) pae.getException(); throw (MalformedURLException) pae.getException();

View File

@ -95,8 +95,8 @@ public class PersistenceUnitInfoImpl
} }
public ClassLoader getNewTempClassLoader() { public ClassLoader getNewTempClassLoader() {
return (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper return AccessController.doPrivileged(J2DoPrivHelper
.newTemporaryClassLoaderAction((ClassLoader) AccessController .newTemporaryClassLoaderAction(AccessController
.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()))); .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())));
} }
@ -203,11 +203,11 @@ public class PersistenceUnitInfoImpl
} }
public void addJarFileName(String name) { public void addJarFileName(String name) {
MultiClassLoader loader = (MultiClassLoader) AccessController MultiClassLoader loader = AccessController
.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
loader.addClassLoader(getClass().getClassLoader()); loader.addClassLoader(getClass().getClassLoader());
loader.addClassLoader(MultiClassLoader.THREAD_LOADER); loader.addClassLoader(MultiClassLoader.THREAD_LOADER);
URL url = (URL) AccessController.doPrivileged( URL url = AccessController.doPrivileged(
J2DoPrivHelper.getResourceAction(loader, name)); J2DoPrivHelper.getResourceAction(loader, name));
if (url != null) { if (url != null) {
addJarFile(url); addJarFile(url);
@ -215,14 +215,14 @@ public class PersistenceUnitInfoImpl
} }
// jar file is not a resource; check classpath // jar file is not a resource; check classpath
String[] cp = ((String) AccessController.doPrivileged( String[] cp = (AccessController.doPrivileged(
J2DoPrivHelper.getPropertyAction("java.class.path"))) J2DoPrivHelper.getPropertyAction("java.class.path")))
.split(J2DoPrivHelper.getPathSeparator()); .split(J2DoPrivHelper.getPathSeparator());
for (int i = 0; i < cp.length; i++) { for (int i = 0; i < cp.length; i++) {
if (cp[i].equals(name) if (cp[i].equals(name)
|| cp[i].endsWith(File.separatorChar + name)) { || cp[i].endsWith(File.separatorChar + name)) {
try { try {
addJarFile((URL) AccessController addJarFile(AccessController
.doPrivileged(J2DoPrivHelper .doPrivileged(J2DoPrivHelper
.toURLAction(new File(cp[i])))); .toURLAction(new File(cp[i]))));
return; return;

View File

@ -1105,13 +1105,13 @@ public class XMLPersistenceMetaDataParser
String cap = StringUtils.capitalize(name); String cap = StringUtils.capitalize(name);
type = meta.getDescribedType(); type = meta.getDescribedType();
try { try {
member = (Method) AccessController.doPrivileged( member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
type, "get" + cap, type, "get" + cap,
(Class[]) null));// varargs disambiguate (Class[]) null));// varargs disambiguate
} catch (Exception excep) { } catch (Exception excep) {
try { try {
member = (Method) AccessController.doPrivileged( member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction( J2DoPrivHelper.getDeclaredMethodAction(
type, "is" + cap, (Class[]) null)); type, "is" + cap, (Class[]) null));
} catch (Exception excep2) { } catch (Exception excep2) {
@ -1120,7 +1120,7 @@ public class XMLPersistenceMetaDataParser
} }
type = ((Method) member).getReturnType(); type = ((Method) member).getReturnType();
} else { } else {
member = (Field) AccessController.doPrivileged( member = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredFieldAction( J2DoPrivHelper.getDeclaredFieldAction(
meta.getDescribedType(), name)); meta.getDescribedType(), name));
type = ((Field) member).getType(); type = ((Field) member).getType();

View File

@ -80,9 +80,9 @@ public class XMLFileHandler {
*/ */
public Collection load(ClassMetaData meta) { public Collection load(ClassMetaData meta) {
File f = getFile(meta); File f = getFile(meta);
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(f))).booleanValue() || J2DoPrivHelper.existsAction(f))).booleanValue() ||
((Long) AccessController.doPrivileged( (AccessController.doPrivileged(
J2DoPrivHelper.lengthAction(f))).longValue() == 0) J2DoPrivHelper.lengthAction(f))).longValue() == 0)
return Collections.EMPTY_SET; return Collections.EMPTY_SET;
try { try {
@ -133,7 +133,7 @@ public class XMLFileHandler {
throw new InternalException(); throw new InternalException();
File f = getFile(meta); File f = getFile(meta);
if (!((Boolean) AccessController.doPrivileged( if (!(AccessController.doPrivileged(
J2DoPrivHelper.existsAction(f.getParentFile()))).booleanValue()) J2DoPrivHelper.existsAction(f.getParentFile()))).booleanValue())
AccessController.doPrivileged( AccessController.doPrivileged(
J2DoPrivHelper.mkdirsAction(f.getParentFile())); J2DoPrivHelper.mkdirsAction(f.getParentFile()));