Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced deprecated methods and calls #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion functional-tests/src/test/idl/corba/poapolicies/Hello.idl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -37,7 +38,7 @@ module Util {
// invocation path more extensively (example, ones that
// throw exceptions etc)

interface Factory {
interface ServantFactory {
Object create(in string intfName, in string implName, in CreationMethods how);
void overAndOut();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand All @@ -20,11 +21,11 @@
package corba.poapolicies;

import Util.CreationMethods;
import Util.FactoryPOA;
import Util.ServantFactoryPOA;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;

public class BasicObjectFactoryImpl extends FactoryPOA
public class BasicObjectFactoryImpl extends ServantFactoryPOA
{
final boolean useServantToReference = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand All @@ -22,10 +23,10 @@
import HelloStuff.Hello;
import HelloStuff.HelloHelper;
import Util.CreationMethods;
import Util.Factory;
import Util.ServantFactory;

public class HelloClient {
public static Hello createHello(CreationMethods c, Factory f) {
public static Hello createHello(CreationMethods c, ServantFactory f) {
System.out.println("createHello");
String id = HelloHelper.id();
System.out.println("id: " + id);
Expand Down Expand Up @@ -60,7 +61,7 @@ public static void main(String[] args) {
System.out.println("Client starting");

Utility u = new Utility(args);
Factory f = u.readFactory();
ServantFactory f = u.readFactory();

System.out.println("readFactory");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,7 +20,7 @@

package corba.poapolicies;

import Util.FactoryHelper;
import Util.ServantFactoryHelper;
import org.omg.PortableServer.POA;

class Waiter extends Thread {
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void main(String[] args) {

byte[] id = thePOA.activate_object(theFactory);

u.writeFactory(FactoryHelper.narrow(thePOA.servant_to_reference(theFactory)));
u.writeFactory(ServantFactoryHelper.narrow(thePOA.servant_to_reference(theFactory)));

thePOA.the_POAManager().activate();

Expand Down
9 changes: 5 additions & 4 deletions functional-tests/src/test/java/corba/poapolicies/Utility.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -76,12 +77,12 @@ public org.omg.CORBA.Object readObjref(String file) {
return null;
}

public void writeFactory(Util.Factory ref) {
writeObjref(ref, "Factory");
public void writeFactory(Util.ServantFactory ref) {
writeObjref(ref, "ServantFactory");
}

public Util.Factory readFactory() {
return Util.FactoryHelper.narrow(readObjref("Factory"));
public Util.ServantFactory readFactory() {
return Util.ServantFactoryHelper.narrow(readObjref("ServantFactory"));
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,6 +20,20 @@

package com.sun.corba.ee.impl.presentation.rmi.codegen;

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.glassfish.pfl.basic.contain.Pair;
import org.glassfish.pfl.dynamic.codegen.spi.Expression;
import org.glassfish.pfl.dynamic.codegen.spi.MethodInfo;
import org.glassfish.pfl.dynamic.codegen.spi.Primitives;
import org.glassfish.pfl.dynamic.codegen.spi.Type;
import org.glassfish.pfl.dynamic.codegen.spi.Utility;
import org.glassfish.pfl.dynamic.codegen.spi.Variable;

import static java.lang.reflect.Modifier.ABSTRACT;
import static java.lang.reflect.Modifier.PRIVATE;
import static java.lang.reflect.Modifier.PUBLIC;
Expand Down Expand Up @@ -48,27 +63,13 @@
import static org.glassfish.pfl.dynamic.codegen.spi.Wrapper._void;
import static org.glassfish.pfl.dynamic.codegen.spi.Wrapper.splitClassName;

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.glassfish.pfl.basic.contain.Pair;
import org.glassfish.pfl.dynamic.codegen.spi.Expression;
import org.glassfish.pfl.dynamic.codegen.spi.MethodInfo;
import org.glassfish.pfl.dynamic.codegen.spi.Primitives;
import org.glassfish.pfl.dynamic.codegen.spi.Type;
import org.glassfish.pfl.dynamic.codegen.spi.Utility;
import org.glassfish.pfl.dynamic.codegen.spi.Variable;

/** Generate a proxy with a specified base class.
/** Generate a proxy with a specified base class.
*/
public class CodegenProxyCreator {
private String className ;
private Type superClass ;
private List<Type> interfaces ;
private List<MethodInfo> methods ;
private final String className ;
private final Type superClass ;
private final List<Type> interfaces ;
private final List<MethodInfo> methods ;

private static final Properties debugProps = new Properties() ;
private static final Properties emptyProps = new Properties() ;
Expand All @@ -85,84 +86,19 @@ public CodegenProxyCreator( String className, Class sc,
this.className = className ;
this.superClass = Type.type( sc ) ;

this.interfaces = new ArrayList<Type>() ;
this.interfaces = new ArrayList<>() ;
for (Class cls : interfaces) {
this.interfaces.add( Type.type( cls ) ) ;
}

this.methods = new ArrayList<MethodInfo>() ;
this.methods = new ArrayList<>() ;
for (Method method : methods) {
this.methods.add( Utility.getMethodInfo( method ) ) ;
}
}

/** Construct a generator for a proxy class
* that implements the given interfaces and extends superClass.
* superClass must satisfy the following requirements:
* <ol>
* <li>It must have an accessible no args constructor</li>
* <li>It must have a method satisfying the signature
* <code> Object invoke( int methodNumber, Object[] args ) throws Throwable
* </code>
* </li>
* <li>The invoke method described above must be accessible
* to the generated class (generally either public or
* protected.</li>
* </ol>
* <p>
* Each method in methods is implemented by a method that:
* <ol>
* <li>Creates an array sized to hold the args</li>
* <li>Wraps args of primitive type in the appropriate wrapper.</li>
* <li>Copies each arg or wrapper arg into the array.</li>
* <li>Calls invoke with a method number corresponding to the
* index of the method in methods. Note that the invoke implementation
* must use the same method array to figure out which method has been
* invoked.</li>
* <li>Return the result (if any), extracting values from wrappers
* as needed to handle a return value of a primitive type.</li>
* </ol>
* <p>
* Note that the generated methods ignore exceptions.
* It is assumed that the invoke method may throw any
* desired exception.
* @param pd the protection domain of the generated class
* @param cl the classloader in which to generate the class
* @param debug if true, generate debug messages
* @param ps a PrintStream to which the debug messages should be written
* @return Generator for class
* @deprecated use {@link #create(Class, boolean, PrintStream)}
*/
@Deprecated
public Class<?> create( ProtectionDomain pd, ClassLoader cl, boolean debug, PrintStream ps ) {

Pair<String,String> nm = splitClassName( className ) ;

_clear() ;
_setClassLoader( cl ) ;
_package( nm.first() ) ;
_class( PUBLIC, nm.second(), superClass, interfaces ) ;

_constructor( PUBLIC ) ;
_body() ;
_expr(_super());
_end() ;

_method( PRIVATE, _Object(), "writeReplace" ) ;
_body() ;
_return(_call(_this(), "selfAsBaseClass" )) ;
_end() ;

int ctr=0 ;
for (MethodInfo method : methods)
createMethod( ctr++, method ) ;

_end() ; // of _class

return _generate( cl, pd, debug ? debugProps : emptyProps, ps ) ;
}

/** Construct a generator for a proxy class
/**
* Construct a generator for a proxy class
* that implements the given interfaces and extends superClass.
* superClass must satisfy the following requirements:
* <ol>
Expand Down Expand Up @@ -218,8 +154,9 @@ public Class<?> create( Class<?> anchorClass, boolean debug, PrintStream ps ) {
_end() ;

int ctr=0 ;
for (MethodInfo method : methods)
for (MethodInfo method : methods) {
createMethod( ctr++, method ) ;
}

_end() ; // of _class

Expand All @@ -231,17 +168,18 @@ public Class<?> create( Class<?> anchorClass, boolean debug, PrintStream ps ) {
private static void createMethod( int mnum, MethodInfo method ) {
Type rtype = method.returnType() ;
_method( method.modifiers() & ~ABSTRACT, rtype, method.name()) ;
List<Expression> args = new ArrayList<Expression>() ;
for (Variable var : method.arguments() )

List<Expression> args = new ArrayList<>() ;
for (Variable var : method.arguments() ) {
args.add( _arg( var.type(), var.ident() ) ) ;
}

_body() ;
List<Expression> wrappedArgs = new ArrayList<Expression>() ;
List<Expression> wrappedArgs = new ArrayList<>() ;
for (Expression arg : args) {
wrappedArgs.add( Primitives.wrap( arg ) ) ;
}

Expression invokeArgs = _define( objectArrayType, "args",
_new_array_init( _Object(), wrappedArgs ) ) ;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand All @@ -23,11 +24,10 @@ public class IDLLeadingUnderscoresTest {

//
// Set of idl names corresponding to alphabetically sorted set of
// interface methods. See TestIDLNameTranslator for sorting details.
// interface methods. See TestIDLNameTranslator for sorting details.
//
static final String[] IDL_NAMES = {

"J_",
static final String[] IDL_NAMES = {

"J_0",
"J_J_",
"J__",
Expand All @@ -36,15 +36,13 @@ public class IDLLeadingUnderscoresTest {
"J_a",
"J_jj"
};

public static String[] getIDLNames() {
return IDL_NAMES;
}

public interface IDLLeadingUnderscores extends java.rmi.Remote {

void _() throws java.rmi.RemoteException;

void _0() throws java.rmi.RemoteException;

void _J_() throws java.rmi.RemoteException;
Expand All @@ -55,10 +53,10 @@ public interface IDLLeadingUnderscores extends java.rmi.Remote {

void __a() throws java.rmi.RemoteException;

void _a() throws java.rmi.RemoteException;
void _a() throws java.rmi.RemoteException;

void _jj() throws java.rmi.RemoteException;

void _jj() throws java.rmi.RemoteException;

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -427,7 +428,7 @@ private void init()
"corba.dynamicrmiiiop.TestInterfaceProxy",
baseClass, interfaces, methods ) ;

proxyClass = pc.create( pd, loader, DEBUG, System.out ) ;
proxyClass = pc.create(this.getClass(), DEBUG, System.out ) ;
}

try {
Expand Down
3 changes: 2 additions & 1 deletion test/src/share/classes/corba/tbbc/Sample.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -80,7 +81,7 @@ public static void main( String[] args ) {
}

Class genClass = Sample.class ;
Class cls = _generate( genClass.getClassLoader(), genClass.getProtectionDomain(), null ) ;
Class cls = _generate( genClass, null ) ;

try {
Method m = cls.getDeclaredMethod( "main", String[].class ) ;
Expand Down