Skip to content

Commit 9203902

Browse files
committed
Replaced deprecated methods and calls
- Factory renamed to ServantFactory - name based on javadoc - Factory caused compilation error because it is a keyword - CodegenProxyCreator.create removed - deprecated, because it called deprecated PFL methods which did not work on JDK17+ - IDLLeadingUnderscoresTest - removed test for _() method name - Forbidden in JDK21+ - See JEP 443 - TestCodegenProxyCreator, Sample - using different method than the deprecated one Signed-off-by: David Matějček <[email protected]>
1 parent 40da3f9 commit 9203902

File tree

9 files changed

+61
-118
lines changed

9 files changed

+61
-118
lines changed

functional-tests/src/test/idl/corba/poapolicies/Hello.idl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -37,7 +38,7 @@ module Util {
3738
// invocation path more extensively (example, ones that
3839
// throw exceptions etc)
3940

40-
interface Factory {
41+
interface ServantFactory {
4142
Object create(in string intfName, in string implName, in CreationMethods how);
4243
void overAndOut();
4344
};

functional-tests/src/test/java/corba/poapolicies/BasicObjectFactoryImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -20,11 +21,11 @@
2021
package corba.poapolicies;
2122

2223
import Util.CreationMethods;
23-
import Util.FactoryPOA;
24+
import Util.ServantFactoryPOA;
2425
import org.omg.PortableServer.POA;
2526
import org.omg.PortableServer.Servant;
2627

27-
public class BasicObjectFactoryImpl extends FactoryPOA
28+
public class BasicObjectFactoryImpl extends ServantFactoryPOA
2829
{
2930
final boolean useServantToReference = true;
3031

functional-tests/src/test/java/corba/poapolicies/HelloClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -22,10 +23,10 @@
2223
import HelloStuff.Hello;
2324
import HelloStuff.HelloHelper;
2425
import Util.CreationMethods;
25-
import Util.Factory;
26+
import Util.ServantFactory;
2627

2728
public class HelloClient {
28-
public static Hello createHello(CreationMethods c, Factory f) {
29+
public static Hello createHello(CreationMethods c, ServantFactory f) {
2930
System.out.println("createHello");
3031
String id = HelloHelper.id();
3132
System.out.println("id: " + id);
@@ -60,7 +61,7 @@ public static void main(String[] args) {
6061
System.out.println("Client starting");
6162

6263
Utility u = new Utility(args);
63-
Factory f = u.readFactory();
64+
ServantFactory f = u.readFactory();
6465

6566
System.out.println("readFactory");
6667

functional-tests/src/test/java/corba/poapolicies/HelloServer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -19,7 +20,7 @@
1920

2021
package corba.poapolicies;
2122

22-
import Util.FactoryHelper;
23+
import Util.ServantFactoryHelper;
2324
import org.omg.PortableServer.POA;
2425

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

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

85-
u.writeFactory(FactoryHelper.narrow(thePOA.servant_to_reference(theFactory)));
86+
u.writeFactory(ServantFactoryHelper.narrow(thePOA.servant_to_reference(theFactory)));
8687

8788
thePOA.the_POAManager().activate();
8889

functional-tests/src/test/java/corba/poapolicies/Utility.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -76,12 +77,12 @@ public org.omg.CORBA.Object readObjref(String file) {
7677
return null;
7778
}
7879

79-
public void writeFactory(Util.Factory ref) {
80-
writeObjref(ref, "Factory");
80+
public void writeFactory(Util.ServantFactory ref) {
81+
writeObjref(ref, "ServantFactory");
8182
}
8283

83-
public Util.Factory readFactory() {
84-
return Util.FactoryHelper.narrow(readObjref("Factory"));
84+
public Util.ServantFactory readFactory() {
85+
return Util.ServantFactoryHelper.narrow(readObjref("ServantFactory"));
8586
}
8687
}
8788

orbmain/src/main/java/com/sun/corba/ee/impl/presentation/rmi/codegen/CodegenProxyCreator.java

Lines changed: 32 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -19,6 +20,20 @@
1920

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

23+
import java.io.PrintStream;
24+
import java.lang.reflect.Method;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
import java.util.Properties;
28+
29+
import org.glassfish.pfl.basic.contain.Pair;
30+
import org.glassfish.pfl.dynamic.codegen.spi.Expression;
31+
import org.glassfish.pfl.dynamic.codegen.spi.MethodInfo;
32+
import org.glassfish.pfl.dynamic.codegen.spi.Primitives;
33+
import org.glassfish.pfl.dynamic.codegen.spi.Type;
34+
import org.glassfish.pfl.dynamic.codegen.spi.Utility;
35+
import org.glassfish.pfl.dynamic.codegen.spi.Variable;
36+
2237
import static java.lang.reflect.Modifier.ABSTRACT;
2338
import static java.lang.reflect.Modifier.PRIVATE;
2439
import static java.lang.reflect.Modifier.PUBLIC;
@@ -48,27 +63,13 @@
4863
import static org.glassfish.pfl.dynamic.codegen.spi.Wrapper._void;
4964
import static org.glassfish.pfl.dynamic.codegen.spi.Wrapper.splitClassName;
5065

51-
import java.io.PrintStream;
52-
import java.lang.reflect.Method;
53-
import java.security.ProtectionDomain;
54-
import java.util.ArrayList;
55-
import java.util.List;
56-
import java.util.Properties;
57-
import org.glassfish.pfl.basic.contain.Pair;
58-
import org.glassfish.pfl.dynamic.codegen.spi.Expression;
59-
import org.glassfish.pfl.dynamic.codegen.spi.MethodInfo;
60-
import org.glassfish.pfl.dynamic.codegen.spi.Primitives;
61-
import org.glassfish.pfl.dynamic.codegen.spi.Type;
62-
import org.glassfish.pfl.dynamic.codegen.spi.Utility;
63-
import org.glassfish.pfl.dynamic.codegen.spi.Variable;
64-
65-
/** Generate a proxy with a specified base class.
66+
/** Generate a proxy with a specified base class.
6667
*/
6768
public class CodegenProxyCreator {
68-
private String className ;
69-
private Type superClass ;
70-
private List<Type> interfaces ;
71-
private List<MethodInfo> methods ;
69+
private final String className ;
70+
private final Type superClass ;
71+
private final List<Type> interfaces ;
72+
private final List<MethodInfo> methods ;
7273

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

88-
this.interfaces = new ArrayList<Type>() ;
89+
this.interfaces = new ArrayList<>() ;
8990
for (Class cls : interfaces) {
9091
this.interfaces.add( Type.type( cls ) ) ;
9192
}
9293

93-
this.methods = new ArrayList<MethodInfo>() ;
94+
this.methods = new ArrayList<>() ;
9495
for (Method method : methods) {
9596
this.methods.add( Utility.getMethodInfo( method ) ) ;
9697
}
9798
}
9899

99-
/** Construct a generator for a proxy class
100-
* that implements the given interfaces and extends superClass.
101-
* superClass must satisfy the following requirements:
102-
* <ol>
103-
* <li>It must have an accessible no args constructor</li>
104-
* <li>It must have a method satisfying the signature
105-
* <code> Object invoke( int methodNumber, Object[] args ) throws Throwable
106-
* </code>
107-
* </li>
108-
* <li>The invoke method described above must be accessible
109-
* to the generated class (generally either public or
110-
* protected.</li>
111-
* </ol>
112-
* <p>
113-
* Each method in methods is implemented by a method that:
114-
* <ol>
115-
* <li>Creates an array sized to hold the args</li>
116-
* <li>Wraps args of primitive type in the appropriate wrapper.</li>
117-
* <li>Copies each arg or wrapper arg into the array.</li>
118-
* <li>Calls invoke with a method number corresponding to the
119-
* index of the method in methods. Note that the invoke implementation
120-
* must use the same method array to figure out which method has been
121-
* invoked.</li>
122-
* <li>Return the result (if any), extracting values from wrappers
123-
* as needed to handle a return value of a primitive type.</li>
124-
* </ol>
125-
* <p>
126-
* Note that the generated methods ignore exceptions.
127-
* It is assumed that the invoke method may throw any
128-
* desired exception.
129-
* @param pd the protection domain of the generated class
130-
* @param cl the classloader in which to generate the class
131-
* @param debug if true, generate debug messages
132-
* @param ps a PrintStream to which the debug messages should be written
133-
* @return Generator for class
134-
* @deprecated use {@link #create(Class, boolean, PrintStream)}
135-
*/
136-
@Deprecated
137-
public Class<?> create( ProtectionDomain pd, ClassLoader cl, boolean debug, PrintStream ps ) {
138-
139-
Pair<String,String> nm = splitClassName( className ) ;
140-
141-
_clear() ;
142-
_setClassLoader( cl ) ;
143-
_package( nm.first() ) ;
144-
_class( PUBLIC, nm.second(), superClass, interfaces ) ;
145-
146-
_constructor( PUBLIC ) ;
147-
_body() ;
148-
_expr(_super());
149-
_end() ;
150-
151-
_method( PRIVATE, _Object(), "writeReplace" ) ;
152-
_body() ;
153-
_return(_call(_this(), "selfAsBaseClass" )) ;
154-
_end() ;
155-
156-
int ctr=0 ;
157-
for (MethodInfo method : methods)
158-
createMethod( ctr++, method ) ;
159-
160-
_end() ; // of _class
161-
162-
return _generate( cl, pd, debug ? debugProps : emptyProps, ps ) ;
163-
}
164-
165-
/** Construct a generator for a proxy class
100+
/**
101+
* Construct a generator for a proxy class
166102
* that implements the given interfaces and extends superClass.
167103
* superClass must satisfy the following requirements:
168104
* <ol>
@@ -218,8 +154,9 @@ public Class<?> create( Class<?> anchorClass, boolean debug, PrintStream ps ) {
218154
_end() ;
219155

220156
int ctr=0 ;
221-
for (MethodInfo method : methods)
157+
for (MethodInfo method : methods) {
222158
createMethod( ctr++, method ) ;
159+
}
223160

224161
_end() ; // of _class
225162

@@ -231,17 +168,18 @@ public Class<?> create( Class<?> anchorClass, boolean debug, PrintStream ps ) {
231168
private static void createMethod( int mnum, MethodInfo method ) {
232169
Type rtype = method.returnType() ;
233170
_method( method.modifiers() & ~ABSTRACT, rtype, method.name()) ;
234-
235-
List<Expression> args = new ArrayList<Expression>() ;
236-
for (Variable var : method.arguments() )
171+
172+
List<Expression> args = new ArrayList<>() ;
173+
for (Variable var : method.arguments() ) {
237174
args.add( _arg( var.type(), var.ident() ) ) ;
175+
}
238176

239177
_body() ;
240-
List<Expression> wrappedArgs = new ArrayList<Expression>() ;
178+
List<Expression> wrappedArgs = new ArrayList<>() ;
241179
for (Expression arg : args) {
242180
wrappedArgs.add( Primitives.wrap( arg ) ) ;
243181
}
244-
182+
245183
Expression invokeArgs = _define( objectArrayType, "args",
246184
_new_array_init( _Object(), wrappedArgs ) ) ;
247185

orbmain/src/test/java/corba/dynamicrmiiiop/testclasses/IDLLeadingUnderscoresTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -23,11 +24,10 @@ public class IDLLeadingUnderscoresTest {
2324

2425
//
2526
// Set of idl names corresponding to alphabetically sorted set of
26-
// interface methods. See TestIDLNameTranslator for sorting details.
27+
// interface methods. See TestIDLNameTranslator for sorting details.
2728
//
28-
static final String[] IDL_NAMES = {
29-
30-
"J_",
29+
static final String[] IDL_NAMES = {
30+
3131
"J_0",
3232
"J_J_",
3333
"J__",
@@ -36,15 +36,13 @@ public class IDLLeadingUnderscoresTest {
3636
"J_a",
3737
"J_jj"
3838
};
39-
39+
4040
public static String[] getIDLNames() {
4141
return IDL_NAMES;
4242
}
4343

4444
public interface IDLLeadingUnderscores extends java.rmi.Remote {
4545

46-
void _() throws java.rmi.RemoteException;
47-
4846
void _0() throws java.rmi.RemoteException;
4947

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

5654
void __a() throws java.rmi.RemoteException;
5755

58-
void _a() throws java.rmi.RemoteException;
56+
void _a() throws java.rmi.RemoteException;
57+
58+
void _jj() throws java.rmi.RemoteException;
5959

60-
void _jj() throws java.rmi.RemoteException;
61-
6260
}
6361

6462
}

test/src/share/classes/corba/dynamicrmiiiop/TestCodegenProxyCreator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -427,7 +428,7 @@ private void init()
427428
"corba.dynamicrmiiiop.TestInterfaceProxy",
428429
baseClass, interfaces, methods ) ;
429430

430-
proxyClass = pc.create( pd, loader, DEBUG, System.out ) ;
431+
proxyClass = pc.create(this.getClass(), DEBUG, System.out ) ;
431432
}
432433

433434
try {

test/src/share/classes/corba/tbbc/Sample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2020 Oracle and/or its affiliates.
34
*
45
* This program and the accompanying materials are made available under the
@@ -80,7 +81,7 @@ public static void main( String[] args ) {
8081
}
8182

8283
Class genClass = Sample.class ;
83-
Class cls = _generate( genClass.getClassLoader(), genClass.getProtectionDomain(), null ) ;
84+
Class cls = _generate( genClass, null ) ;
8485

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

0 commit comments

Comments
 (0)