java.rmi.MarshalledObject Java Examples
The following examples show how to use
java.rmi.MarshalledObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivatableImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public ActivatableImpl(ActivationID id, MarshalledObject mobj) throws RemoteException { super(id, 0); ClassLoader thisLoader = ActivatableImpl.class.getClassLoader(); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); System.err.println("implLoader: " + thisLoader); System.err.println("ccl: " + ccl); /* * the context class loader is the ccl from when this object * was exported. If the bug has been fixed, the ccl will be * the same as the class loader of this class. */ classLoaderOk = (thisLoader == ccl); }
Example #2
Source File: ActivatableImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public ActivatableImpl(ActivationID id, MarshalledObject mobj) throws RemoteException { super(id, 0); ClassLoader thisLoader = ActivatableImpl.class.getClassLoader(); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); System.err.println("implLoader: " + thisLoader); System.err.println("ccl: " + ccl); /* * the context class loader is the ccl from when this object * was exported. If the bug has been fixed, the ccl will be * the same as the class loader of this class. */ classLoaderOk = (thisLoader == ccl); }
Example #3
Source File: ActivatableImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public ActivatableImpl(ActivationID id, MarshalledObject mobj) throws RemoteException { super(id, 0); ClassLoader thisLoader = ActivatableImpl.class.getClassLoader(); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); System.err.println("implLoader: " + thisLoader); System.err.println("ccl: " + ccl); /* * the context class loader is the ccl from when this object * was exported. If the bug has been fixed, the ccl will be * the same as the class loader of this class. */ classLoaderOk = (thisLoader == ccl); }
Example #4
Source File: Activation.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
synchronized MarshalledObject<? extends Remote> activate(ActivationID id, boolean force, ActivationInstantiator inst) throws RemoteException, ActivationException { MarshalledObject<? extends Remote> nstub = stub; if (removed) { throw new UnknownObjectException("object removed"); } else if (!force && nstub != null) { return nstub; } nstub = inst.newInstance(id, desc); stub = nstub; /* * stub could be set to null by a group reset, so return * the newstub here to prevent returning null. */ return nstub; }
Example #5
Source File: RMIConnector.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException { if (logger.debugOn()) logger.debug("setAttribute", "name=" + name + ", attribute name=" + attribute.getName()); final MarshalledObject<Attribute> sAttribute = new MarshalledObject<Attribute>(attribute); final ClassLoader old = pushDefaultClassLoader(); try { connection.setAttribute(name, sAttribute, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.setAttribute(name, sAttribute, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #6
Source File: RMIConnector.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public Set<ObjectName> queryNames(ObjectName name, QueryExp query) throws IOException { if (logger.debugOn()) logger.debug("queryNames", "name=" + name + ", query=" + query); final MarshalledObject<QueryExp> sQuery = new MarshalledObject<QueryExp>(query); final ClassLoader old = pushDefaultClassLoader(); try { return connection.queryNames(name, sQuery, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.queryNames(name, sQuery, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #7
Source File: RMIConnector.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #8
Source File: MOFilterTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Test that MarshalledObject inherits the ObjectInputFilter from * the stream it was deserialized from. */ @Test(dataProvider="FilterCases") static void delegatesToMO(boolean withFilter) { try { Serializable testobj = Integer.valueOf(5); MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj); Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object"); byte[] bytes = writeObjects(mo); try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais)) { CountingFilter filter1 = new CountingFilter(); ObjectInputFilter.Config.setObjectInputFilter(ois, withFilter ? filter1 : null); MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject(); int count = filter1.getCount(); actualMO.get(); int expectedCount = withFilter ? count + 2 : count; int actualCount = filter1.getCount(); Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()"); } } catch (IOException ioe) { Assert.fail("Unexpected IOException", ioe); } catch (ClassNotFoundException cnf) { Assert.fail("Deserializing", cnf); } }
Example #9
Source File: RMIConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private <T> T unwrap(final MarshalledObject<?> mo, final ClassLoader cl1, final ClassLoader cl2, final Class<T> wrappedClass, Subject delegationSubject) throws IOException { if (mo == null) { return null; } try { ClassLoader orderCL = AccessController.doPrivileged( new PrivilegedExceptionAction<ClassLoader>() { public ClassLoader run() throws Exception { return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(), new OrderClassLoaders(cl1, cl2)); } } ); return unwrap(mo, orderCL, wrappedClass,delegationSubject); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) { throw (IOException) e; } if (e instanceof ClassNotFoundException) { throw new UnmarshalException(e.toString(), e); } logger.warning("unwrap", "Failed to unmarshall object: " + e); logger.debug("unwrap", e); } return null; }
Example #10
Source File: RMIConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") // MarshalledObject public Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException { final QueryExp queryValue; final boolean debug=logger.debugOn(); if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); try { final Object params[] = new Object[] { name, queryValue }; if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +", name="+name +", query="+query); return cast( doPrivilegedOperation( QUERY_MBEANS, params, delegationSubject)); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) throw (IOException) e; throw newIOException("Got unexpected server exception: " + e, e); } }
Example #11
Source File: Chaining.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void test(Throwable t, String msg, Throwable cause) throws Exception { check(t, msg, cause); Throwable[] pair = new Throwable[]{t, cause}; pair = (Throwable[]) new MarshalledObject(pair).get(); check(pair[0], msg, pair[1]); }
Example #12
Source File: MarshalAfterUnexport2.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4513223\n"); Remote impl2 = null; try { Remote impl = new MarshalAfterUnexport2(); System.err.println( "created impl extending URO (with a UnicastServerRef2): " + impl); Receiver stub = (Receiver) RemoteObject.toStub(impl); System.err.println("stub for impl: " + stub); UnicastRemoteObject.unexportObject(impl, true); System.err.println("unexported impl"); impl2 = new MarshalAfterUnexport2(); Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); System.err.println("marshalling unexported object:"); MarshalledObject mobj = new MarshalledObject(impl); System.err.println("passing unexported object via RMI-JRMP:"); stub2.receive(stub); System.err.println("TEST PASSED"); } finally { if (impl2 != null) { try { UnicastRemoteObject.unexportObject(impl2, true); } catch (Throwable t) { } } } }
Example #13
Source File: LoadProxyClasses.java From hottub with GNU General Public License v2.0 | 5 votes |
private static Proxy unmarshalProxyClass(Proxy proxy, ClassLoader fnnLoader, ClassLoader expectedLoader, int n, LoadChecker checker) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException { FnnUnmarshal fnnUnmarshal = (FnnUnmarshal) fnnLoader.loadClass("FnnClass").newInstance(); Proxy unmarshalled = (Proxy) fnnUnmarshal.unmarshal(new MarshalledObject(proxy)); ClassLoader unmarshalledLoader = unmarshalled.getClass().getClassLoader(); if (checker != null) { checker.checkLoad(unmarshalled, expectedLoader); } else { if (unmarshalledLoader != expectedLoader) { TestLibrary.bomb("case" + n + ": proxy class not " + "placed into incorrect loader: " + unmarshalledLoader); } else { System.err.println("\ncase" + n + ": proxy class correctly" + " placed into expected loader: " + expectedLoader); } } return proxy; }
Example #14
Source File: RMIConnector.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected Integer addListenerForMBeanRemovedNotif() throws IOException, InstanceNotFoundException { NotificationFilterSupport clientFilter = new NotificationFilterSupport(); clientFilter.enableType( MBeanServerNotification.UNREGISTRATION_NOTIFICATION); MarshalledObject<NotificationFilter> sFilter = new MarshalledObject<NotificationFilter>(clientFilter); Integer[] listenerIDs; final ObjectName[] names = new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME}; final MarshalledObject<NotificationFilter>[] filters = Util.cast(new MarshalledObject<?>[] {sFilter}); final Subject[] subjects = new Subject[] {null}; try { listenerIDs = connection.addNotificationListeners(names, filters, subjects); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); listenerIDs = connection.addNotificationListeners(names, filters, subjects); } return listenerIDs[0]; }
Example #15
Source File: RMIConnector.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #16
Source File: ActivationGroupImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
ActiveEntry(Remote impl) throws ActivationException { this.impl = impl; try { this.mobj = new MarshalledObject<Remote>(impl); } catch (IOException e) { throw new ActivationException("failed to marshal remote object", e); } }
Example #17
Source File: RegistryFilterTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static XX createMarshalledObject() { try { return new XX(new MarshalledObject<>(null)); } catch (IOException ioe) { return new XX(ioe); } }
Example #18
Source File: RMIConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") // MarshalledObject public Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException { final QueryExp queryValue; final boolean debug=logger.debugOn(); if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject); try { final Object params[] = new Object[] { name, queryValue }; if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +", name="+name +", query="+query); return cast( doPrivilegedOperation( QUERY_MBEANS, params, delegationSubject)); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) throw (IOException) e; throw newIOException("Got unexpected server exception: " + e, e); } }
Example #19
Source File: StubClassesPermitted.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * implementation of CanCreateStubs */ public StubClassesPermitted (ActivationID id, MarshalledObject mo) throws RemoteException { // register/export anonymously super(id, 0); // obtain reference to the test registry registry = java.rmi.registry.LocateRegistry. getRegistry(registryPort); }
Example #20
Source File: Activation.java From hottub with GNU General Public License v2.0 | 5 votes |
public MarshalledObject<? extends Remote> activate(ActivationID id, boolean force) throws ActivationException, UnknownObjectException, RemoteException { checkShutdown(); return getGroupEntry(id).activate(id, force); }
Example #21
Source File: RMIConnectionImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") // MarshalledObject public Set<ObjectName> queryNames(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException { final QueryExp queryValue; final boolean debug=logger.debugOn(); if (debug) logger.debug("queryNames", "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject); try { final Object params[] = new Object[] { name, queryValue }; if (debug) logger.debug("queryNames", "connectionId=" + connectionId +", name="+name +", query="+query); return cast( doPrivilegedOperation( QUERY_NAMES, params, delegationSubject)); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) throw (IOException) e; throw newIOException("Got unexpected server exception: " + e, e); } }
Example #22
Source File: Compare.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static MarshalledObject setupObjects(String lengthStr, File file) throws Throwable { int listLength = Integer.parseInt(lengthStr); made = marshalledList(listLength); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); read = (MarshalledObject) in.readObject(); in.close(); return read; }
Example #23
Source File: RegistryFilterTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static XX createMarshalledObject() { try { return new XX(new MarshalledObject<>(null)); } catch (IOException ioe) { return new XX(ioe); } }
Example #24
Source File: Activation.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public MarshalledObject<? extends Remote> activate(ActivationID id, boolean force) throws ActivationException, UnknownObjectException, RemoteException { checkShutdown(); return getGroupEntry(id).activate(id, force); }
Example #25
Source File: RMIConnector.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { if (logger.debugOn()) logger.debug("removeNotificationListener" + "(ObjectName,ObjectName,NotificationFilter,Object)", "name=" + name + ", listener=" + listener + ", filter=" + filter + ", handback=" + handback); final MarshalledObject<NotificationFilter> sFilter = new MarshalledObject<NotificationFilter>(filter); final MarshalledObject<Object> sHandback = new MarshalledObject<Object>(handback); final ClassLoader old = pushDefaultClassLoader(); try { connection.removeNotificationListener(name, listener, sFilter, sHandback, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.removeNotificationListener(name, listener, sFilter, sHandback, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #26
Source File: RMIConnector.java From Java8CN with Apache License 2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", params=" + objects(params) + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #27
Source File: RMIConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static <T> T unwrap(final MarshalledObject<?> mo, final ClassLoader cl, final Class<T> wrappedClass) throws IOException { if (mo == null) { return null; } try { final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl)); try { return wrappedClass.cast(mo.get()); } catch (ClassNotFoundException cnfe) { throw new UnmarshalException(cnfe.toString(), cnfe); } finally { AccessController.doPrivileged(new SetCcl(old)); } } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) { throw (IOException) e; } if (e instanceof ClassNotFoundException) { throw new UnmarshalException(e.toString(), e); } logger.warning("unwrap", "Failed to unmarshall object: " + e); logger.debug("unwrap", e); } return null; }
Example #28
Source File: ActivationGroupImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
ActiveEntry(Remote impl) throws ActivationException { this.impl = impl; try { this.mobj = new MarshalledObject<Remote>(impl); } catch (IOException e) { throw new ActivationException("failed to marshal remote object", e); } }
Example #29
Source File: RMIConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") // MarshalledObject public Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException { final QueryExp queryValue; final boolean debug=logger.debugOn(); if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); try { final Object params[] = new Object[] { name, queryValue }; if (debug) logger.debug("queryMBeans", "connectionId=" + connectionId +", name="+name +", query="+query); return cast( doPrivilegedOperation( QUERY_MBEANS, params, delegationSubject)); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) throw (IOException) e; throw newIOException("Got unexpected server exception: " + e, e); } }
Example #30
Source File: Activation.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public MarshalledObject<? extends Remote> activate(ActivationID id, boolean force) throws ActivationException, UnknownObjectException, RemoteException { checkShutdown(); return getGroupEntry(id).activate(id, force); }